897 lines
32 KiB
C#
897 lines
32 KiB
C#
///////////////////////////////////////////////////////////
|
|
// PurchaseOrderListDetailed.cs
|
|
// Implementation of Class PurchaseOrderListDetailed
|
|
// CSLA type: Read only collection
|
|
// Created on: 24-Dec-2008
|
|
// Object design: John
|
|
// Coded: 24-Dec-2008
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
using System.Collections.Generic;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
#pragma warning disable 1591
|
|
/// <summary>
|
|
/// Read only list of <see cref="PurchaseOrderListDetailed.PurchaseOrderListDetailedInfo"/> objects used for reporting.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class PurchaseOrderListDetailed : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Properties
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct PurchaseOrderListDetailedInfo
|
|
{
|
|
internal GridNameValueCellItem mPONumber; //and ID
|
|
internal GridNameValueCellItem mClient; //and ID
|
|
internal GridNameValueCellItem mVendor; //and ID
|
|
internal GridNameValueCellItem mProject; //and ID //case 49
|
|
|
|
internal string mReferenceNumber;
|
|
//internal decimal mFreight;
|
|
//internal decimal mAdditionalCharges;
|
|
//internal bool mOrdered;
|
|
internal SmartDate mOrderedDate;
|
|
internal SmartDate mExpectedReceiveDate;
|
|
//internal DateTime mActualReceiveDate;
|
|
//internal bool mClosed;
|
|
internal DateTime mCreated;
|
|
internal DateTime mModified;
|
|
|
|
|
|
|
|
internal PurchaseOrderStatus mStatus;
|
|
|
|
|
|
|
|
[SqlColumnNameAttribute("aPurchaseOrder.aPONumber",
|
|
"aPurchaseOrder.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.PurchaseOrder)]
|
|
public GridNameValueCellItem LT_PurchaseOrder_Label_PONumber
|
|
{
|
|
get
|
|
{
|
|
return mPONumber;
|
|
}
|
|
}
|
|
|
|
[SqlColumnNameAttribute("aVendor.aName",
|
|
"aVendor.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Vendor)]
|
|
public GridNameValueCellItem LT_O_Vendor
|
|
{
|
|
get
|
|
{
|
|
return mVendor;
|
|
}
|
|
}
|
|
|
|
//case 49
|
|
[SqlColumnNameAttribute("aProject.aName",
|
|
"aProject.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Project)]
|
|
public GridNameValueCellItem LT_O_Project
|
|
{
|
|
get
|
|
{
|
|
return mProject;
|
|
}
|
|
}
|
|
|
|
|
|
[SqlColumnNameAttribute("aClient.aName",
|
|
"aClient.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Client)]
|
|
public GridNameValueCellItem LT_PurchaseOrder_Label_DropShipToClientID
|
|
{
|
|
get
|
|
{
|
|
return mClient;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_PurchaseOrder_Label_ReferenceNumber
|
|
{
|
|
get
|
|
{
|
|
return mReferenceNumber;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.ListPurchaseOrderStatus)]
|
|
public PurchaseOrderStatus LT_PurchaseOrder_Label_Status
|
|
{
|
|
get
|
|
{
|
|
return mStatus;
|
|
}
|
|
}
|
|
|
|
|
|
[Display(DisplayType.DateTime)]
|
|
public object LT_PurchaseOrder_Label_OrderedDate
|
|
{
|
|
get
|
|
{
|
|
return mOrderedDate.DBValue;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.DateTime)]
|
|
public object LT_PurchaseOrder_Label_ExpectedReceiveDate
|
|
{
|
|
get
|
|
{
|
|
return mExpectedReceiveDate.DBValue;
|
|
}
|
|
}
|
|
|
|
|
|
[SqlColumnNameAttribute("aPurchaseOrder.aCreated"), Display(DisplayType.DateTime)]
|
|
public DateTime LT_Common_Label_Created
|
|
{
|
|
get
|
|
{
|
|
return mCreated;
|
|
}
|
|
}
|
|
|
|
[SqlColumnNameAttribute("aPurchaseOrder.aModified"),Display(DisplayType.DateTime)]
|
|
public DateTime LT_Common_Label_Modified
|
|
{
|
|
get
|
|
{
|
|
return mModified;
|
|
}
|
|
}
|
|
|
|
|
|
//case 867
|
|
internal string mCustom1;
|
|
internal string mCustom2;
|
|
internal string mCustom3;
|
|
internal string mCustom4;
|
|
internal string mCustom5;
|
|
internal string mCustom6;
|
|
internal string mCustom7;
|
|
internal string mCustom8;
|
|
internal string mCustom9;
|
|
internal string mCustom0;
|
|
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom1 { get { return mCustom1; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom2 { get { return mCustom2; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom3 { get { return mCustom3; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom4 { get { return mCustom4; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom5 { get { return mCustom5; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom6 { get { return mCustom6; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom7 { get { return mCustom7; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom8 { get { return mCustom8; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom9 { get { return mCustom9; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_Custom0 { get { return mCustom0; } }
|
|
|
|
|
|
|
|
|
|
//PART STUFF
|
|
|
|
internal GridNameValueCellItem mName; //and ID
|
|
internal GridNameValueCellItem mPartNumber; //and ID
|
|
internal GridNameValueCellItem mPartCategory; //and ID
|
|
internal GridNameValueCellItem mManufacturer; //and ID
|
|
internal GridNameValueCellItem mWholesaler; //and ID
|
|
internal GridNameValueCellItem mAlternativeWholesaler; //and ID
|
|
internal GridNameValueCellItem mUnitOfMeasure; //and ID
|
|
internal GridNameValueCellItem mPartAssembly; //and ID
|
|
internal GridNameValueCellItem mUPC; //and ID if possible
|
|
|
|
internal string mManufacturerNumber;//manufacturer part number
|
|
internal string mWholesalerNumber;//wholesaler part number
|
|
internal string mAlternativeWholesalerNumber;//Alternative wholesaler part number
|
|
|
|
|
|
internal bool mTrackSerialNumber;
|
|
internal bool mActive;
|
|
|
|
[SqlColumnNameAttribute("aPart.aName",
|
|
"aPart.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Part)]
|
|
public GridNameValueCellItem LT_O_Part { get { return mName; } }
|
|
|
|
[SqlColumnNameAttribute("aPart.aPartNumber",
|
|
"aPart.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Part)]
|
|
public GridNameValueCellItem LT_Part_Label_PartNumber { get { return mPartNumber; } }
|
|
|
|
[SqlColumnNameAttribute("aPartCategory.aName",
|
|
"aPartCategory.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.PartCategory)]
|
|
public GridNameValueCellItem LT_O_PartCategory { get { return mPartCategory; } }
|
|
|
|
[SqlColumnNameAttribute("aManufacturers.aName",
|
|
"aManufacturers.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Vendor)]
|
|
public GridNameValueCellItem LT_Part_Label_ManufacturerID { get { return mManufacturer; } }
|
|
|
|
[SqlColumnNameAttribute("aWholesalers.aName",
|
|
"aWholesalers.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Vendor)]
|
|
public GridNameValueCellItem LT_Part_Label_WholesalerID { get { return mWholesaler; } }
|
|
|
|
[SqlColumnNameAttribute("AALTERNATIVEWHOLESALERS.aName",
|
|
"AALTERNATIVEWHOLESALERS.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Vendor)]
|
|
public GridNameValueCellItem LT_Part_Label_AlternativeWholesalerID { get { return mAlternativeWholesaler; } }
|
|
|
|
[SqlColumnNameAttribute("aUnitOfMeasure.aName",
|
|
"aUnitOfMeasure.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.UnitOfMeasure)]
|
|
public GridNameValueCellItem LT_O_UnitOfMeasure { get { return mUnitOfMeasure; } }
|
|
|
|
[SqlColumnNameAttribute("aPartAssembly.aName",
|
|
"aPartAssembly.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.PartAssembly)]
|
|
public GridNameValueCellItem LT_O_PartAssembly { get { return mPartAssembly; } }
|
|
|
|
[SqlColumnNameAttribute("aPart.aUPC",
|
|
"aPart.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Part)]
|
|
public GridNameValueCellItem LT_Part_Label_UPC { get { return mUPC; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_ManufacturerNumber { get { return mManufacturerNumber; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_WholesalerNumber { get { return mWholesalerNumber; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_AlternativeWholesalerNumber { get { return mAlternativeWholesalerNumber; } }
|
|
|
|
|
|
[Display(DisplayType.TrueFalse)]
|
|
public bool LT_Part_Label_TrackSerialNumber { get { return mTrackSerialNumber; } }
|
|
|
|
[Display(DisplayType.TrueFalse)]
|
|
public bool LT_Part_Label_Active { get { return mActive; } }
|
|
|
|
|
|
internal GridNameValueCellItem mPartWarehouseID;
|
|
[SqlColumnNameAttribute("aPartWarehouse.aName",
|
|
"APURCHASEORDERITEM.aPartWarehouseID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.PartWarehouse)]
|
|
public GridNameValueCellItem LT_O_PartWarehouse { get { return mPartWarehouseID; } }
|
|
|
|
|
|
//quantities
|
|
internal decimal mQuantityOrdered;
|
|
[Display(DisplayType.DecimalNumber)]
|
|
public decimal LT_PurchaseOrderItem_Label_QuantityOrdered { get { return mQuantityOrdered; } }
|
|
|
|
internal decimal mQuantityReceived;
|
|
[Display(DisplayType.DecimalNumber)]
|
|
public decimal LT_PurchaseOrderItem_Label_QuantityReceived { get { return mQuantityReceived; } }
|
|
|
|
|
|
//poitem stuff
|
|
internal string mRequestorInitials;
|
|
[SqlColumnNameAttribute("aRequestorUser.aInitials"), Display(DisplayType.Text)]
|
|
public string LT_PurchaseOrderItem_Label_PartRequestedByID
|
|
{
|
|
get
|
|
{
|
|
return mRequestorInitials;
|
|
}
|
|
}
|
|
|
|
internal int mWorkorderNumber;
|
|
[Display(DisplayType.WholeNumber), SqlColumnNameAttribute("AWORKORDERSERVICE.ASERVICENUMBER")]
|
|
public int LT_PurchaseOrderItem_Label_WorkorderNumber { get { return mWorkorderNumber; } }
|
|
|
|
internal GridNameValueCellItem mTaxCodeID;
|
|
[SqlColumnNameAttribute("aTaxCode.aName","aTaxCode.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.TaxCode)]
|
|
public GridNameValueCellItem LT_O_TaxCode { get { return mTaxCodeID; } }
|
|
|
|
internal decimal mTaxA;
|
|
[Display(DisplayType.Currency),SqlColumnNameAttribute("grid")]
|
|
public decimal LT_TaxCode_Label_TaxA { get { return mTaxA; } }
|
|
|
|
internal decimal mTaxB;
|
|
[Display(DisplayType.Currency), SqlColumnNameAttribute("grid")]
|
|
public decimal LT_TaxCode_Label_TaxB { get { return mTaxB; } }
|
|
|
|
internal decimal mLineTotal;
|
|
[Display(DisplayType.Currency), SqlColumnNameAttribute("grid")]
|
|
public decimal LT_PurchaseOrderItem_Label_LineTotal { get { return mLineTotal; } }
|
|
|
|
internal decimal mNetTotal;
|
|
[Display(DisplayType.Currency), SqlColumnNameAttribute("grid")]
|
|
public decimal LT_PurchaseOrderItem_Label_NetTotal { get { return mNetTotal; } }
|
|
|
|
internal decimal mPurchaseOrderCost;
|
|
[Display(DisplayType.Currency)]
|
|
public decimal LT_PurchaseOrderItem_Label_PurchaseOrderCost { get { return mPurchaseOrderCost; } }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(PurchaseOrderListDetailedInfo obj)
|
|
{
|
|
return this.mPONumber.Value.Equals(obj.mPONumber.Value);
|
|
}
|
|
|
|
}//end PurchaseOrderListDetailedInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
protected PurchaseOrderListDetailed()
|
|
{
|
|
// AllowSort=false;
|
|
// AllowFind=true;
|
|
// AllowEdit=false;
|
|
// AllowNew=false;
|
|
// AllowRemove=false;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Business properties and methods
|
|
|
|
/// <summary>
|
|
/// Get item by index
|
|
/// </summary>
|
|
/// <param name="Item"></param>
|
|
public PurchaseOrderListDetailedInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (PurchaseOrderListDetailedInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns display text that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public string this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (PurchaseOrderListDetailedInfo child in List)
|
|
{
|
|
if(child.mPONumber.Value==ItemID) return child.ToString();
|
|
}
|
|
return "Missing: "+ItemID.ToString();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region contains
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(PurchaseOrderListDetailedInfo obj)
|
|
{
|
|
foreach (PurchaseOrderListDetailedInfo child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Reporting and shared UI editor helpers
|
|
|
|
/// <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 "PurchaseOrderListDetailed";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the Detailed report key
|
|
/// which is used to determine which reports and objects
|
|
/// will be used for detailed reports
|
|
///
|
|
/// If empty string then indicates there is no detailed report object or reports
|
|
/// </summary>
|
|
public static string DetailedReportKey
|
|
{
|
|
get
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Base object that this list is reporting on
|
|
/// used by shared UI editor to instantiate new objects
|
|
/// when user selects new in UI elements that display this list
|
|
///
|
|
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
|
|
/// </summary>
|
|
public static RootObjectTypes BaseObjectType
|
|
{
|
|
get
|
|
{
|
|
return RootObjectTypes.PurchaseOrder;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locale key so that generic list editor
|
|
/// UI code knows what title to give the list in a
|
|
/// grid
|
|
/// </summary>
|
|
public string LocaleKey
|
|
{
|
|
get
|
|
{
|
|
return "UI.Go.Inventory.PurchaseOrdersDetailed";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The Type of the struct used to store list records
|
|
/// Used to fetch the custom display attributes of the fields
|
|
/// contained within the record to modify the grid display accordingly
|
|
/// <see cref="DisplayAttribute"/>
|
|
/// </summary>
|
|
public static Type ListRecordType
|
|
{
|
|
get
|
|
{
|
|
return typeof(PurchaseOrderListDetailedInfo);
|
|
}
|
|
}
|
|
|
|
/// <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 "LT_PurchaseOrder_Label_PONumber";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Same as IDField but for detailed reports
|
|
/// </summary>
|
|
public static string IDFieldDetailed
|
|
{
|
|
get
|
|
{
|
|
return IDField;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Internal method used by list factory
|
|
/// </summary>
|
|
internal static PurchaseOrderListDetailed Get(string Filter, int MaxRecords, List<Guid> IDList)
|
|
{
|
|
return (PurchaseOrderListDetailed)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords));
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Takes an xml column list and where criteria
|
|
/// and returns a list filtered and sorted accordingly
|
|
/// </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>list of <see cref="PurchaseOrderListDetailed.PurchaseOrderListDetailedInfo"/> objects</returns>
|
|
public static PurchaseOrderListDetailed GetListByCriteria(string xmlCriteria)
|
|
{
|
|
return (PurchaseOrderListDetailed) DataPortal.Fetch(new Criteria(xmlCriteria,null,-1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes a single ID and returns a "list" of one object
|
|
/// </summary>
|
|
/// <param name="PurchaseOrderID">ID of PurchaseOrder object</param>
|
|
/// <returns>list of <see cref="PurchaseOrderListDetailed.PurchaseOrderListDetailedInfo"/> objects</returns>
|
|
public static PurchaseOrderListDetailed GetListForSingleItem(Guid PurchaseOrderID)
|
|
{
|
|
//Case 556
|
|
List<Guid> l = new List<Guid>();
|
|
l.Add(PurchaseOrderID);
|
|
return GetListFromIDList(l);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get list by items indicated in IDList
|
|
/// </summary>
|
|
/// <param name="IDList">Generic list of Guid's</param>
|
|
/// <returns>list of <see cref="PurchaseOrderListDetailed.PurchaseOrderListDetailedInfo"/> objects</returns>
|
|
public static PurchaseOrderListDetailed GetListFromIDList(List<Guid> IDList)
|
|
{
|
|
//case 556
|
|
//Handle empty list
|
|
if (IDList.Count == 0)
|
|
return new PurchaseOrderListDetailed();
|
|
return (PurchaseOrderListDetailed)DataPortal.Fetch(new Criteria("", IDList, -1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return an empty list
|
|
/// used for initializing grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static PurchaseOrderListDetailed GetEmptyList()
|
|
{
|
|
return new PurchaseOrderListDetailed();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
Criteria crit = (Criteria)Criteria;
|
|
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
DBCommandWrapper cm = null;
|
|
//Base query
|
|
string q=
|
|
//************************************************************
|
|
|
|
"SELECT ~MAXRECS~ " +
|
|
" APURCHASEORDER.AID, " +
|
|
" APURCHASEORDER.APONUMBER, " +
|
|
" APURCHASEORDER.ASTATUS, " +
|
|
" ACLIENT.AID AS ACLIENTID, " +
|
|
" ACLIENT.ANAME AS ACLIENTNAME, " +
|
|
" APURCHASEORDER.AREFERENCENUMBER, " +
|
|
" AVENDOR.AID AS AVENDORID, " +
|
|
" AVENDOR.ANAME AS AVENDORNAME, " +
|
|
" APROJECT.AID AS APROJECTID, " +
|
|
" APROJECT.ANAME AS APROJECTNAME, " +
|
|
" APURCHASEORDER.AORDEREDDATE, " +
|
|
" APURCHASEORDER.AEXPECTEDRECEIVEDATE, " +
|
|
" APURCHASEORDER.ACREATED AS ACREATEDDATE, " +
|
|
" APURCHASEORDER.AMODIFIED AS AMODIFIEDDATE, " +
|
|
|
|
//case 867
|
|
" aPurchaseOrder.aCustom1, " +
|
|
" aPurchaseOrder.aCustom2, aPurchaseOrder.aCustom3, " +
|
|
" aPurchaseOrder.aCustom4, " +
|
|
" aPurchaseOrder.aCustom5, aPurchaseOrder.aCustom6, " +
|
|
" aPurchaseOrder.aCustom7, aPurchaseOrder.aCustom8, " +
|
|
" aPurchaseOrder.aCustom9, " +
|
|
" aPurchaseOrder.aCustom0, " +
|
|
|
|
" APART.AID AS APARTID, " +
|
|
" APART.ANAME AS APARTNAME, " +
|
|
" APART.APARTNUMBER, " +
|
|
" APARTCATEGORY.ANAME AS APARTCATEGORYNAME, " +
|
|
" APARTCATEGORY.AID AS APARTCATEGORYID, " +
|
|
" AMANUFACTURERS.ANAME AS AMANUFACTURERNAME, " +
|
|
" AMANUFACTURERS.AID AS AMANUFACTURERID, " +
|
|
" AWHOLESALERS.ANAME AS AWHOLESALERNAME, " +
|
|
" AWHOLESALERS.AID AS AWHOLESALERID, " +
|
|
" APART.AMANUFACTURERNUMBER, " +
|
|
" APART.AWHOLESALERNUMBER, " +
|
|
" AALTERNATIVEWHOLESALERS.ANAME AS AALTERNATIVEWHOLESALERNAME, " +
|
|
" AALTERNATIVEWHOLESALERS.AID AS AALTERNATIVEWHOLESALERID, " +
|
|
" APART.AALTERNATIVEWHOLESALERNUMBER, " +
|
|
|
|
" APART.ARETAIL, " +
|
|
" AUNITOFMEASURE.ANAME AS AUNITOFMEASURENAME, " +
|
|
" AUNITOFMEASURE.AID AS AUNITOFMEASUREID, " +
|
|
" APARTASSEMBLY.ANAME AS APARTASSEMBLYNAME, " +
|
|
" APARTASSEMBLY.AID AS APARTASSEMBLYID, " +
|
|
" APART.AUPC, " +
|
|
" APART.ATRACKSERIALNUMBER, " +
|
|
" APART.AACTIVE AS APARTACTIVE, " +
|
|
" APURCHASEORDERITEM.AQUANTITYORDERED, " +
|
|
" APURCHASEORDERITEM.AQUANTITYRECEIVED, " +
|
|
" APARTWAREHOUSE.ANAME AS APARTWAREHOUSENAME, " +
|
|
" APARTWAREHOUSE.AID AS APARTWAREHOUSEID, " +
|
|
" AWORKORDERSERVICE.ASERVICENUMBER, " +
|
|
" AREQUESTORUSER.AINITIALS AS AREQUESTORINITIALS, " +
|
|
" APURCHASEORDERITEM.APURCHASEORDERCOST, " +
|
|
" ATAXCODE.AID AS ATAXCODEID, " +
|
|
" ATAXCODE.ANAME AS ATAXCODENAME " +
|
|
|
|
"FROM " +
|
|
" APURCHASEORDER " +
|
|
|
|
" LEFT OUTER JOIN AVENDOR ON (APURCHASEORDER.AVENDORID = AVENDOR.AID) " +
|
|
" LEFT OUTER JOIN APROJECT ON (APURCHASEORDER.APROJECTID = APROJECT.AID) " +
|
|
" LEFT OUTER JOIN APURCHASEORDERITEM ON (APURCHASEORDER.AID = APURCHASEORDERITEM.APURCHASEORDERID) " +
|
|
" LEFT OUTER JOIN ACLIENT ON (APURCHASEORDER.ADROPSHIPTOCLIENTID = ACLIENT.AID) " +
|
|
" INNER JOIN APART ON (APURCHASEORDERITEM.APARTID = APART.AID) " +
|
|
" LEFT OUTER JOIN APARTASSEMBLY ON (APART.APARTASSEMBLYID = APARTASSEMBLY.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR AMANUFACTURERS ON (APART.AMANUFACTURERID = AMANUFACTURERS.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR AWHOLESALERS ON (APART.AWHOLESALERID = AWHOLESALERS.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR AALTERNATIVEWHOLESALERS ON (APART.AALTERNATIVEWHOLESALERID = AALTERNATIVEWHOLESALERS.AID) " +
|
|
" LEFT OUTER JOIN AUNITOFMEASURE ON (APART.AUNITOFMEASUREID = AUNITOFMEASURE.AID) " +
|
|
" LEFT OUTER JOIN APARTCATEGORY ON (APART.APARTCATEGORYID = APARTCATEGORY.AID) " +
|
|
" INNER JOIN APARTWAREHOUSE ON (APURCHASEORDERITEM.APARTWAREHOUSEID = APARTWAREHOUSE.AID) " +
|
|
" LEFT OUTER JOIN AUSER AREQUESTORUSER ON (APURCHASEORDERITEM.APARTREQUESTEDBYID = AREQUESTORUSER.AID) " +
|
|
" LEFT OUTER JOIN ATAXCODE ON (APURCHASEORDERITEM.APURCHASETAXCODEID = ATAXCODE.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERITEMPARTREQUEST ON (APURCHASEORDERITEM.AWORKORDERITEMPARTREQUESTID = AWORKORDERITEMPARTREQUEST.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERITEM ON (AWORKORDERITEMPARTREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " ;
|
|
//************************************************************
|
|
|
|
if (crit.MaxRecords > 0)
|
|
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
|
|
else
|
|
q = q.Replace("~MAXRECS~", "");
|
|
|
|
//List or grid criteria?
|
|
if (crit.IDList != null)
|
|
{
|
|
//Case 556
|
|
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() + " " +
|
|
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML));
|
|
}
|
|
else
|
|
{
|
|
//Changed: 12-July-2006 the getgridcolumncriteria fragment was being called with addwhereclause parameter false instead of true
|
|
//Grid criteria
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(q +
|
|
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML,true) + " " +
|
|
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML));
|
|
}
|
|
|
|
|
|
TaxCodeList taxlist = TaxCodeList.GetList();
|
|
|
|
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
PurchaseOrderListDetailedInfo info=new PurchaseOrderListDetailedInfo();
|
|
|
|
info.mPONumber=new GridNameValueCellItem(
|
|
dr.GetGuid("aID"),
|
|
dr.GetInt32("aPONumber").ToString(),
|
|
RootObjectTypes.PurchaseOrder);
|
|
|
|
info.mClient=new GridNameValueCellItem(
|
|
dr.GetGuid("aClientID"),
|
|
dr.GetString("aClientName"),
|
|
RootObjectTypes.Client);
|
|
|
|
info.mVendor=new GridNameValueCellItem(
|
|
dr.GetGuid("aVendorID"),
|
|
dr.GetString("aVendorName"),
|
|
RootObjectTypes.Vendor);
|
|
//case 49
|
|
info.mProject = new GridNameValueCellItem(
|
|
dr.GetGuid("aProjectID"),
|
|
dr.GetString("aProjectName"),
|
|
RootObjectTypes.Project);
|
|
|
|
info.mReferenceNumber=dr.GetString("aReferenceNumber");
|
|
info.mOrderedDate=DBUtil.ToLocal(dr.GetSmartDate("aOrderedDate"));
|
|
info.mExpectedReceiveDate=DBUtil.ToLocal(dr.GetSmartDate("aExpectedReceiveDate"));
|
|
info.mCreated=DBUtil.ToLocal(dr.GetDateTime("aCreatedDate"));
|
|
info.mModified=DBUtil.ToLocal(dr.GetDateTime("aModifiedDate"));
|
|
|
|
info.mStatus=(PurchaseOrderStatus)dr.GetInt16("aStatus");
|
|
//case 867
|
|
info.mCustom0 = dr.GetString("aCustom0");
|
|
info.mCustom1 = dr.GetString("aCustom1");
|
|
info.mCustom2 = dr.GetString("aCustom2");
|
|
info.mCustom3 = dr.GetString("aCustom3");
|
|
info.mCustom4 = dr.GetString("aCustom4");
|
|
info.mCustom5 = dr.GetString("aCustom5");
|
|
info.mCustom6 = dr.GetString("aCustom6");
|
|
info.mCustom7 = dr.GetString("aCustom7");
|
|
info.mCustom8 = dr.GetString("aCustom8");
|
|
info.mCustom9 = dr.GetString("aCustom9");
|
|
|
|
//Part stuff
|
|
info.mName = new GridNameValueCellItem(
|
|
dr.GetGuid("APARTID"),
|
|
dr.GetString("APARTNAME"),
|
|
RootObjectTypes.Part);
|
|
|
|
info.mPartNumber = new GridNameValueCellItem(
|
|
dr.GetGuid("APARTID"),
|
|
dr.GetString("aPartNumber"),
|
|
RootObjectTypes.Part);
|
|
|
|
info.mPartCategory = new GridNameValueCellItem(
|
|
dr.GetGuid("aPartCategoryID"),
|
|
dr.GetString("aPartCategoryName"),
|
|
RootObjectTypes.PartCategory);
|
|
|
|
info.mManufacturer = new GridNameValueCellItem(
|
|
dr.GetGuid("aManufacturerID"),
|
|
dr.GetString("aManufacturerName"),
|
|
RootObjectTypes.Vendor);
|
|
|
|
info.mWholesaler = new GridNameValueCellItem(
|
|
dr.GetGuid("aWholesalerID"),
|
|
dr.GetString("aWholesalerName"),
|
|
RootObjectTypes.Vendor);
|
|
|
|
info.mAlternativeWholesaler = new GridNameValueCellItem(
|
|
dr.GetGuid("AALTERNATIVEWHOLESALERID"),
|
|
dr.GetString("AALTERNATIVEWHOLESALERNAME"),
|
|
RootObjectTypes.Vendor);
|
|
|
|
info.mUnitOfMeasure = new GridNameValueCellItem(
|
|
dr.GetGuid("aUnitOfMeasureID"),
|
|
dr.GetString("aUnitOfMeasureName"),
|
|
RootObjectTypes.UnitOfMeasure);
|
|
|
|
info.mPartAssembly = new GridNameValueCellItem(
|
|
dr.GetGuid("aPartAssemblyID"),
|
|
dr.GetString("aPartAssemblyName"),
|
|
RootObjectTypes.PartAssembly);
|
|
|
|
info.mUPC = new GridNameValueCellItem(
|
|
dr.GetGuid("APARTID"),
|
|
dr.GetString("aUPC"),
|
|
RootObjectTypes.Part);
|
|
|
|
info.mManufacturerNumber = dr.GetString("aManufacturerNumber");//manufacturer part number
|
|
info.mWholesalerNumber = dr.GetString("aWholeSalerNumber");//wholesaler part number
|
|
info.mAlternativeWholesalerNumber = dr.GetString("AALTERNATIVEWHOLESALERNUMBER");//AALTERNATIVEWHOLESALERNUMBER Alternative wholesaler part number
|
|
|
|
info.mTrackSerialNumber = dr.GetBoolean("aTrackSerialNumber");
|
|
info.mActive = dr.GetBoolean("APARTACTIVE");
|
|
|
|
info.mPartWarehouseID = new GridNameValueCellItem(
|
|
dr.GetGuid("aPartWarehouseID"),
|
|
dr.GetString("aPartWarehouseName"),
|
|
RootObjectTypes.PartWarehouse);
|
|
|
|
//Quantities
|
|
info.mQuantityOrdered = dr.GetDecimal("aQuantityOrdered");
|
|
info.mQuantityReceived = dr.GetDecimal("aQuantityReceived");
|
|
|
|
//poitem stuff
|
|
info.mPurchaseOrderCost = dr.GetDecimal("APURCHASEORDERCOST");
|
|
info.mRequestorInitials = dr.GetString("aRequestorInitials");
|
|
info.mWorkorderNumber = dr.GetInt32("ASERVICENUMBER");
|
|
info.mTaxCodeID = new GridNameValueCellItem(
|
|
dr.GetGuid("aTaxCodeID"),
|
|
dr.GetString("ATAXCODENAME"),
|
|
RootObjectTypes.TaxCode);
|
|
|
|
if (info.mTaxCodeID.Value != Guid.Empty)
|
|
{
|
|
TaxCodeList.TaxCodeListInfo t = taxlist[info.mTaxCodeID.Value];
|
|
decimal dNet=info.mQuantityOrdered*info.mPurchaseOrderCost;
|
|
decimal dTaxA=0M;
|
|
decimal dTaxB=0M;
|
|
//If tax A exempt then no further processing needs to be done
|
|
//as both taxes already set at zero, otherwise...
|
|
if(!t.TaxAExempt)
|
|
{
|
|
//Tax A is always just tax A percent times net...
|
|
dTaxA=t.TaxA*dNet;
|
|
|
|
//Tax B on the other hand could be simple or tax on tax...
|
|
if(!t.TaxOnTax)
|
|
{
|
|
//simple
|
|
dTaxB=t.TaxB*dNet;
|
|
}
|
|
else
|
|
{
|
|
//tax on tax
|
|
dTaxB=(dNet+dTaxA)*t.TaxB;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//set line total and taxes display values
|
|
info.mTaxA=dTaxA;
|
|
info.mTaxB=dTaxB;
|
|
info.mNetTotal=dNet;
|
|
info.mLineTotal=dNet+dTaxA+dTaxB;
|
|
}
|
|
|
|
InnerList.Add(info);
|
|
//*******************************************
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if(dr!=null) dr.Close();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
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 PurchaseOrderListDetailed
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL |