549 lines
21 KiB
C#
549 lines
21 KiB
C#
///////////////////////////////////////////////////////////
|
|
// Bool.cs
|
|
// Implementation of Class PurchaseOrderDetailedReportData
|
|
// CSLA type: Read-only object
|
|
// Created on: 21-Dec-2005
|
|
// Object design: John
|
|
// Coded: 21-Dec-2005
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using CSLA.Data;
|
|
using GZTW.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
/// <summary>
|
|
/// Read only list of detailed purchase order data used for reporting
|
|
/// </summary>
|
|
[Serializable]
|
|
public class PurchaseOrderDetailedReportData : ReadOnlyBase
|
|
{
|
|
|
|
#region Attributes
|
|
private ReportDataSet ds;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Private constructor to prevent direct instantiation
|
|
/// </summary>
|
|
private PurchaseOrderDetailedReportData()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Internal method used by list factory
|
|
/// </summary>
|
|
internal static ReportDataSet Get(string Filter, int MaxRecords, List<Guid> IDList)
|
|
{
|
|
return ((PurchaseOrderDetailedReportData)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords))).ds;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the report key which is a property of
|
|
/// reports used to link all reports that can be used
|
|
/// with a particular data source.
|
|
/// </summary>
|
|
public static string ReportKey
|
|
{
|
|
get
|
|
{
|
|
return "PurchaseOrderDetailed";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Field that contains the ID of the objects
|
|
/// that are the basis of this list.
|
|
///
|
|
/// Used for compiling an ID list for reporting from user
|
|
/// selections in a grid.
|
|
/// </summary>
|
|
public static string IDField
|
|
{
|
|
get
|
|
{
|
|
return PurchaseOrderList.IDField;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Same as IDField but for detailed reports
|
|
/// </summary>
|
|
public static string IDFieldDetailed
|
|
{
|
|
get
|
|
{
|
|
return IDField;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get list
|
|
/// </summary>
|
|
/// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
|
|
/// <returns><see cref="ReportDataSet"/></returns>
|
|
public static ReportDataSet GetItems(string xmlCriteria)
|
|
{
|
|
|
|
return ((PurchaseOrderDetailedReportData)DataPortal.Fetch(new Criteria(xmlCriteria,null,-1))).ds;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes a single ID and returns a "list" of one object
|
|
/// </summary>
|
|
/// <param name="PurchaseOrderID">ID of PurchaseOrder object</param>
|
|
/// <returns></returns>
|
|
public static ReportDataSet GetItem(Guid PurchaseOrderID)
|
|
{
|
|
//Case 556
|
|
List<Guid> l = new List<Guid>();
|
|
l.Add(PurchaseOrderID);
|
|
return GetListFromIDList(l);
|
|
|
|
//return ((PurchaseOrderDetailedReportData)DataPortal.Fetch(new Criteria("",PurchaseOrderID,-1))).ds;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get's all workorders in the provided List of workorder id's
|
|
/// (used for pick and choose printing etc)
|
|
/// </summary>
|
|
/// <param name="WorkorderIDList">Generic list of Guid's of workorders</param>
|
|
/// <returns></returns>
|
|
public static ReportDataSet GetListFromIDList(List<Guid> WorkorderIDList)
|
|
{//case 555
|
|
//Handle empty list
|
|
//Different than workorderservicelist because
|
|
//returns a reportdataset not the object
|
|
if (WorkorderIDList.Count == 0)
|
|
{
|
|
PurchaseOrderDetailedReportData d = new PurchaseOrderDetailedReportData();
|
|
d.InitDS();
|
|
return d.ds;
|
|
}
|
|
return ((PurchaseOrderDetailedReportData)DataPortal.Fetch(new Criteria("", WorkorderIDList, -1))).ds;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Initialize data set
|
|
|
|
private void InitDS()
|
|
{
|
|
ds=new ReportDataSet();
|
|
|
|
System.IO.Stream s=Assembly.GetExecutingAssembly().GetManifestResourceStream("GZTW.AyaNova.BLL.PurchaseOrderDetailedSchema.xsd");
|
|
ds.ReadXmlSchema(s);
|
|
ds.ShowOnlyStartingWith="PurchaseOrder";
|
|
|
|
}
|
|
|
|
#endregion initalize data set
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
|
|
InitDS();
|
|
|
|
|
|
|
|
Criteria crit = (Criteria)Criteria;
|
|
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
#region Cached objects
|
|
//task completion types
|
|
string OpenNotYetOrdered=LocalizedTextTable.GetLocalizedTextDirect("PurchaseOrder.Label.PurchaseOrderStatus.OpenNotYetOrdered");
|
|
string OpenOrdered=LocalizedTextTable.GetLocalizedTextDirect("PurchaseOrder.Label.PurchaseOrderStatus.OpenOrdered");
|
|
string OpenPartialReceived=LocalizedTextTable.GetLocalizedTextDirect("PurchaseOrder.Label.PurchaseOrderStatus.OpenPartialReceived");
|
|
string ClosedPartialReceived=LocalizedTextTable.GetLocalizedTextDirect("PurchaseOrder.Label.PurchaseOrderStatus.ClosedPartialReceived");
|
|
string ClosedFullReceived=LocalizedTextTable.GetLocalizedTextDirect("PurchaseOrder.Label.PurchaseOrderStatus.ClosedFullReceived");
|
|
string ClosedNoneReceived=LocalizedTextTable.GetLocalizedTextDirect("PurchaseOrder.Label.PurchaseOrderStatus.ClosedNoneReceived");
|
|
|
|
//Tax codes cache
|
|
TaxCodeList taxlist=TaxCodeList.GetList();
|
|
|
|
//Users
|
|
UserPickList users=UserPickList.GetList(false);
|
|
|
|
//Service rates
|
|
RatePickList rates=RatePickList.GetList(false);
|
|
|
|
//case 3118
|
|
//units of measure
|
|
UnitOfMeasurePickList unitsofmeasure = UnitOfMeasurePickList.GetList(false);
|
|
|
|
#endregion cached objects
|
|
|
|
DBCommandWrapper cm = null;
|
|
|
|
#region Query
|
|
string q=
|
|
//***********************************************************************************************************
|
|
"SELECT ~MAXRECS~ aPurchaseOrder.aID, aPurchaseOrder.aPONumber, aPurchaseOrder.aStatus, " +
|
|
"aPurchaseOrder.aVendorMemo, aPurchaseOrder.aNotes, aClient.aID AS aClientID, " +
|
|
"aClient.aName AS aClientName, " +
|
|
"aPurchaseOrder.aReferenceNumber, " +
|
|
"aProject.aID AS aProjectID, aProject.aName AS aProjectName, " +//case 49
|
|
"aVendor.aID AS aVendorID, aVendor.aName " +
|
|
"AS aVendorName, aVendor.AACCOUNTNUMBER AS aVendorAccount, aPurchaseOrder.aOrderedDate, " +
|
|
"aPurchaseOrder.aExpectedReceiveDate, " +
|
|
"aPurchaseOrder.aCreated AS aCreatedDate, aPurchaseOrder.aCreator AS aCreatorID, " +
|
|
"aPurchaseOrder.aModified AS aModifiedDate, aCreatorUser.aInitials " +
|
|
"AS aCreatorInitials, aModifierUser.aInitials " +
|
|
"AS aModifierInitials, " +
|
|
//case 867
|
|
" aPurchaseOrder.aCustom1, " +
|
|
" aPurchaseOrder.aCustom2, aPurchaseOrder.aCustom3, " +
|
|
" aPurchaseOrder.aCustom4, " +
|
|
" aPurchaseOrder.aCustom5, aPurchaseOrder.aCustom6, " +
|
|
" aPurchaseOrder.aCustom7, aPurchaseOrder.aCustom8, " +
|
|
" aPurchaseOrder.aCustom9, " +
|
|
" aPurchaseOrder.aCustom0 " +
|
|
|
|
"FROM aPurchaseOrder " +
|
|
"LEFT OUTER JOIN aUser aModifierUser ON aPurchaseOrder.aModifier " +
|
|
"= aModifierUser.aID LEFT OUTER " +
|
|
"JOIN aUser aCreatorUser ON aPurchaseOrder.aCreator " +
|
|
"= aCreatorUser.aID LEFT OUTER JOIN aClient " +
|
|
"ON aPurchaseOrder.aDropShipToClientID = aClient.aID " +
|
|
"LEFT OUTER JOIN aVendor ON aPurchaseOrder.aVendorID " +
|
|
"= aVendor.aID " +
|
|
"LEFT OUTER JOIN aProject ON aPurchaseOrder.aProjectID " +//case 49
|
|
"= aProject.aID "
|
|
|
|
//***********************************************************************************************************
|
|
;
|
|
|
|
if (crit.MaxRecords > 0)
|
|
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
|
|
else
|
|
q = q.Replace("~MAXRECS~", "");
|
|
|
|
//Built in order for reporting
|
|
string qOrderBy=
|
|
" aPurchaseOrder.aID ";
|
|
|
|
if (crit.IDList != null)
|
|
{
|
|
|
|
//Case 555
|
|
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
|
|
sbIN.Append(" WHERE (aPurchaseOrder.aID in (");
|
|
foreach (Guid gItem in crit.IDList)
|
|
{
|
|
sbIN.Append("'");
|
|
sbIN.Append("{");
|
|
sbIN.Append(gItem.ToString().ToUpperInvariant());
|
|
sbIN.Append("}");
|
|
sbIN.Append("',");
|
|
}
|
|
sbIN.Length = sbIN.Length - 1;
|
|
sbIN.Append(")) ");
|
|
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(q + sbIN.ToString() + " ORDER BY " + qOrderBy);
|
|
|
|
}
|
|
else
|
|
{
|
|
//case 1688 was not set to true for addwhere clause and unused strCrit found here as well
|
|
//string strCrit=AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML,false);
|
|
//Grid criteria
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(q +
|
|
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML,true) + " " +
|
|
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML) );
|
|
}
|
|
|
|
#endregion query
|
|
|
|
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
|
|
|
|
DataRow r=null;
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
|
|
#region PurchaseOrder level
|
|
|
|
r=ds.Tables["PurchaseOrder"].NewRow();
|
|
r["LT_PurchaseOrder_Label_ID"]=dr.GetGuid("aID");
|
|
r["LT_PurchaseOrder_Label_PONumber"]=dr.GetInt32("aPONumber").ToString();
|
|
r["LT_O_Vendor"]=dr.GetString("aVendorName");
|
|
r["LT_O_Project"] = dr.GetString("aProjectName");
|
|
r["LT_PurchaseOrder_Label_DropShipToClientID"]=dr.GetString("aClientName");
|
|
r["LT_PurchaseOrder_Label_ReferenceNumber"]=dr.GetString("aReferenceNumber");
|
|
r["LT_PurchaseOrder_Label_VendorMemo"]=dr.GetString("aVendorMemo");
|
|
r["LT_PurchaseOrder_Label_Notes"]=dr.GetString("aNotes");
|
|
r["LT_Vendor_Label_AccountNumber"]=dr.GetString("aVendorAccount");
|
|
switch((PurchaseOrderStatus)dr.GetInt16("aStatus"))
|
|
{
|
|
case PurchaseOrderStatus.OpenNotYetOrdered:
|
|
r["LT_PurchaseOrder_Label_Status"]=OpenNotYetOrdered;
|
|
break;
|
|
case PurchaseOrderStatus.OpenOrdered:
|
|
r["LT_PurchaseOrder_Label_Status"]=OpenOrdered;
|
|
break;
|
|
case PurchaseOrderStatus.OpenPartialReceived:
|
|
r["LT_PurchaseOrder_Label_Status"]=OpenPartialReceived;
|
|
break;
|
|
case PurchaseOrderStatus.ClosedPartialReceived:
|
|
r["LT_PurchaseOrder_Label_Status"]=ClosedPartialReceived;
|
|
break;
|
|
case PurchaseOrderStatus.ClosedFullReceived:
|
|
r["LT_PurchaseOrder_Label_Status"]=ClosedFullReceived;
|
|
break;
|
|
case PurchaseOrderStatus.ClosedNoneReceived:
|
|
r["LT_PurchaseOrder_Label_Status"]=ClosedNoneReceived;
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
r["LT_PurchaseOrder_Label_OrderedDate"]=DBUtil.ToLocal(dr.GetSmartDate("aOrderedDate")).Date;
|
|
r["LT_PurchaseOrder_Label_ExpectedReceiveDate"]=DBUtil.ToLocal(dr.GetSmartDate("aExpectedReceiveDate")).Date;
|
|
r["LT_Common_Label_Created"]=DBUtil.ToLocal(dr.GetDateTime("aCreatedDate")).Date;
|
|
r["LT_Common_Label_Creator"]=users[dr.GetGuid("aCreatorID")];
|
|
|
|
r["LT_PurchaseOrder_Label_Custom1"] = dr.GetString("aCustom1");
|
|
r["LT_PurchaseOrder_Label_Custom2"] = dr.GetString("aCustom2");
|
|
r["LT_PurchaseOrder_Label_Custom3"] = dr.GetString("aCustom3");
|
|
r["LT_PurchaseOrder_Label_Custom4"] = dr.GetString("aCustom4");
|
|
r["LT_PurchaseOrder_Label_Custom5"] = dr.GetString("aCustom5");
|
|
r["LT_PurchaseOrder_Label_Custom6"] = dr.GetString("aCustom6");
|
|
r["LT_PurchaseOrder_Label_Custom7"] = dr.GetString("aCustom7");
|
|
r["LT_PurchaseOrder_Label_Custom8"] = dr.GetString("aCustom8");
|
|
r["LT_PurchaseOrder_Label_Custom9"] = dr.GetString("aCustom9");
|
|
r["LT_PurchaseOrder_Label_Custom0"] = dr.GetString("aCustom0");
|
|
|
|
|
|
ds.Tables["PurchaseOrder"].Rows.Add(r);
|
|
|
|
|
|
|
|
#endregion purchase order level
|
|
|
|
|
|
#region Vendor addresses and contact info
|
|
//Case 195
|
|
//vendor ID is guid.empty in some cases
|
|
Guid gtempid = dr.GetGuid("aVendorID");
|
|
if (gtempid != Guid.Empty)
|
|
{
|
|
Vendor v = Vendor.GetItemNoMRU(gtempid);
|
|
r = ds.Tables["VendorPhysicalAddress"].NewRow();
|
|
r["PurchaseOrderID"] = dr.GetGuid("aID");
|
|
r["LT_Address_Label_FullAddress"] = v.GoToAddress.FullAddress;
|
|
ds.Tables["VendorPhysicalAddress"].Rows.Add(r);
|
|
|
|
r = ds.Tables["VendorPostalAddressAndContact"].NewRow();
|
|
r["PurchaseOrderID"] = dr.GetGuid("aID");
|
|
r["LT_Contact_Label_FullContact"] = v.GetPrimaryContactDefaultContactInfo();
|
|
r["LT_Address_Label_FullAddress"] = v.MailToAddress.FullAddress;
|
|
ds.Tables["VendorPostalAddressAndContact"].Rows.Add(r);
|
|
}
|
|
#endregion Vendor postal address
|
|
|
|
#region Client address and contact info
|
|
Guid gClient=dr.GetGuid("aClientID");
|
|
if(gClient!=Guid.Empty)
|
|
{
|
|
Client c=Client.GetItemNoMRU(gClient);
|
|
r=ds.Tables["ClientPhysicalAddress"].NewRow();
|
|
r["PurchaseOrderID"]=dr.GetGuid("aID");
|
|
r["LT_Address_Label_FullAddress"]=c.GoToAddress.FullAddress;
|
|
ds.Tables["ClientPhysicalAddress"].Rows.Add(r);
|
|
|
|
r=ds.Tables["ClientPostalAddressAndContact"].NewRow();
|
|
r["PurchaseOrderID"]=dr.GetGuid("aID");
|
|
r["LT_Address_Label_FullAddress"]=c.MailToAddress.FullAddress;
|
|
r["LT_Contact_Label_FullContact"]=c.GetPrimaryContactDefaultContactInfo();
|
|
ds.Tables["ClientPostalAddressAndContact"].Rows.Add(r);
|
|
|
|
}
|
|
#endregion Client address and contact info
|
|
|
|
|
|
|
|
#region Item Level
|
|
SafeDataReader dritems=DBUtil.GetReaderFromSQLString(
|
|
"SELECT aPartCategory.aName AS aPartCategoryName, " +
|
|
" aPartManufacturers.aName AS aPartManufacturerName, " +
|
|
" aPartAssembly.aName AS aPartAssemblyName, aPart.aName " +
|
|
"AS aPartName, aPart.aPartNumber, " +
|
|
" aPart.aUPC, aPurchaseOrderItem.aPartID, " +
|
|
"aPurchaseOrderItem.aPurchaseOrderID, aPurchaseOrderItem.aID, " +
|
|
" aPurchaseOrderItem.aQuantityOrdered, " +
|
|
" aPurchaseOrderItem.aPurchaseOrderCost, " +
|
|
" aPurchaseOrderItem.aQuantityReceived, aPartWarehouse.aName " +
|
|
"AS aPartWarehouseName, aWorkorderService.aServiceNumber, " +
|
|
" aPurchaseOrderItem.aPartRequestedByID, " +
|
|
" aPurchaseOrderItem.aClosed, " +
|
|
" aPurchaseOrderItem.aPurchaseTaxCodeID, aPart.aManufacturerNumber, " +
|
|
" aPart.aWholesalerNumber, " +
|
|
" APART.AUNITOFMEASUREID, " +//case 3118
|
|
" aPart.AALTERNATIVEWHOLESALERNUMBER " +
|
|
|
|
"FROM " +
|
|
" APURCHASEORDERITEM " +
|
|
" LEFT OUTER JOIN APART ON (APURCHASEORDERITEM.APARTID=APART.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR aPartManufacturers ON (APART.AMANUFACTURERID=aPartManufacturers.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERITEMPARTREQUEST ON (AWORKORDERITEMPARTREQUEST.AID=APURCHASEORDERITEM.AWORKORDERITEMPARTREQUESTID) " +
|
|
" LEFT OUTER JOIN AWORKORDERITEM ON (AWORKORDERITEMPARTREQUEST.AWORKORDERITEMID=AWORKORDERITEM.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID=AWORKORDERSERVICE.AWORKORDERID) " +
|
|
" LEFT OUTER JOIN APARTCATEGORY ON (APART.APARTCATEGORYID=APARTCATEGORY.AID) " +
|
|
" LEFT OUTER JOIN APARTASSEMBLY ON (APART.APARTASSEMBLYID=APARTASSEMBLY.AID) " +
|
|
" LEFT OUTER JOIN APARTWAREHOUSE ON (APURCHASEORDERITEM.APARTWAREHOUSEID=APARTWAREHOUSE.AID) " +
|
|
|
|
"WHERE aPurchaseOrderItem.aPurchaseOrderID=@ID",dr.GetGuid("aID"));
|
|
while(dritems.Read())
|
|
{
|
|
r=ds.Tables["Item"].NewRow();
|
|
r["ID"]=dritems.GetGuid("aID");
|
|
r["LT_PurchaseOrderItem_Label_QuantityReceived"]=dritems.GetDecimal("aQuantityReceived");
|
|
r["LT_PurchaseOrderItem_Label_QuantityOrdered"]=dritems.GetDecimal("aQuantityOrdered");
|
|
r["LT_PurchaseOrderItem_Label_PartRequestedByID"]=users[dritems.GetGuid("aPartRequestedByID")];
|
|
r["LT_PurchaseOrderItem_Label_WorkorderNumber"]=dritems.GetInt32("aServiceNumber")==0?"":dritems.GetInt32("aServiceNumber").ToString();
|
|
r["LT_PurchaseOrderItem_Label_PurchaseOrderCost"]=dritems.GetDecimal("aPurchaseOrderCost");
|
|
r["LT_O_PartWarehouse"]=dritems.GetString("aPartWarehouseName");
|
|
r["LT_PurchaseOrderItem_Label_Closed"]=dritems.GetBoolean("aClosed");
|
|
r["PurchaseOrderID"]=dritems.GetGuid("aPurchaseOrderID");
|
|
|
|
|
|
//Taxes from cache
|
|
Guid gTaxID=dritems.GetGuid("aPurchaseTaxCodeID");
|
|
|
|
if(gTaxID!=Guid.Empty)
|
|
{
|
|
TaxCodeList.TaxCodeListInfo ti=taxlist[gTaxID];
|
|
r["LT_O_TaxCode"]=ti.Name;
|
|
r["LT_TaxCode_Label_TaxA"]=ti.TaxA;
|
|
r["LT_TaxCode_Label_TaxB"]=ti.TaxB;
|
|
r["LT_TaxCode_Label_TaxAExempt"]=ti.TaxAExempt;
|
|
r["LT_TaxCode_Label_TaxBExempt"]=ti.TaxBExempt;
|
|
r["LT_TaxCode_Label_TaxOnTax"]=ti.TaxOnTax;
|
|
}
|
|
else
|
|
{
|
|
r["LT_O_TaxCode"]="";
|
|
r["LT_TaxCode_Label_TaxA"]=0m;
|
|
r["LT_TaxCode_Label_TaxB"]=0m;
|
|
r["LT_TaxCode_Label_TaxAExempt"]=true;
|
|
r["LT_TaxCode_Label_TaxBExempt"]=true;
|
|
r["LT_TaxCode_Label_TaxOnTax"]=false;
|
|
|
|
}
|
|
|
|
|
|
r["LT_O_Part"]=Part.PartDisplayFormatter(
|
|
dritems.GetString("aPartName"),
|
|
dritems.GetString("aPartNumber"),
|
|
dritems.GetString("aUPC"),
|
|
dritems.GetString("aPartManufacturerName"),
|
|
dritems.GetString("aPartCategoryName"),
|
|
dritems.GetString("aPartAssemblyName"),
|
|
AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat);
|
|
|
|
r["LT_Part_Label_ManufacturerNumber"]=dritems.GetString("aManufacturerNumber");
|
|
r["LT_Part_Label_WholesalerNumber"]=dritems.GetString("aWholesalerNumber");
|
|
r["LT_Part_Label_AlternativeWholesalerNumber"]=dritems.GetString("AALTERNATIVEWHOLESALERNUMBER");
|
|
|
|
//case 3118
|
|
r["LT_O_UnitOfMeasure"] = String.Empty;
|
|
Guid gUofM = dritems.GetGuid("AUNITOFMEASUREID");
|
|
if(gUofM!=Guid.Empty)
|
|
{
|
|
if(unitsofmeasure.Contains(gUofM))
|
|
r["LT_O_UnitOfMeasure"] = unitsofmeasure[gUofM].Name;
|
|
}
|
|
|
|
|
|
#region Calculated values
|
|
|
|
decimal net=0;
|
|
decimal quantity=(decimal)r["LT_PurchaseOrderItem_Label_QuantityOrdered"];
|
|
decimal price=(decimal)r["LT_PurchaseOrderItem_Label_PurchaseOrderCost"];
|
|
|
|
net = decimal.Round(quantity * price, 2, MidpointRounding.AwayFromZero);
|
|
|
|
r["LT_UI_Label_NetValue"]=net;
|
|
r["LT_TaxCode_Label_TaxAValue"] = decimal.Round(net * (decimal)r["LT_TaxCode_Label_TaxA"], 2, MidpointRounding.AwayFromZero);
|
|
if((bool)(r["LT_TaxCode_Label_TaxOnTax"]))
|
|
{
|
|
r["LT_TaxCode_Label_TaxBValue"]=decimal.Round(
|
|
(net+(decimal)r["LT_TaxCode_Label_TaxAValue"])*
|
|
(decimal)r["LT_TaxCode_Label_TaxB"], 2, MidpointRounding.AwayFromZero);
|
|
}
|
|
else
|
|
{
|
|
r["LT_TaxCode_Label_TaxBValue"] = decimal.Round(net * (decimal)r["LT_TaxCode_Label_TaxB"], 2, MidpointRounding.AwayFromZero);
|
|
}
|
|
|
|
r["LT_UI_Label_LineTotal"]=net+(decimal)r["LT_TaxCode_Label_TaxBValue"]+(decimal)r["LT_TaxCode_Label_TaxAValue"];
|
|
#endregion
|
|
|
|
ds.Tables["Item"].Rows.Add(r);
|
|
}
|
|
|
|
#endregion item level fields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//*******************************************
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if(dr!=null) dr.Close();
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
//Case 555
|
|
public List<Guid> IDList;
|
|
public string CriteriaXML;
|
|
public int MaxRecords;
|
|
public Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords)
|
|
{
|
|
CriteriaXML = _CriteriaXML;
|
|
IDList = _IDList;
|
|
MaxRecords = _MaxRecords;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}//end Bool
|
|
|
|
}//end Boolspace GZTW.AyaNova.BLL |