246 lines
5.4 KiB
C#
246 lines
5.4 KiB
C#
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
#pragma warning disable 1591
|
|
|
|
/// <summary>
|
|
/// Read only list of <see cref="PurchaseOrderListReceivableForVendor.PurchaseOrderListReceivableForVendorInfo"/> objects representing <see cref="PurchaseOrder"/> objects
|
|
/// ready to be received for a particular vendor
|
|
/// </summary>
|
|
[Serializable]
|
|
public class PurchaseOrderListReceivableForVendor : ReadOnlyCollectionBase
|
|
{
|
|
|
|
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Properties
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct PurchaseOrderListReceivableForVendorInfo
|
|
{
|
|
internal Guid mID;
|
|
internal int mPONumber;
|
|
internal string mReferenceNumber;
|
|
internal DateTime mOrderedDate;
|
|
internal SmartDate mExpectedReceiveDate;
|
|
|
|
public Guid ID
|
|
{
|
|
get
|
|
{
|
|
return mID;
|
|
}
|
|
}
|
|
|
|
public int LT_PurchaseOrder_Label_PONumber
|
|
{
|
|
get
|
|
{
|
|
return mPONumber;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public string LT_PurchaseOrder_Label_ReferenceNumber
|
|
{
|
|
get
|
|
{
|
|
return mReferenceNumber;
|
|
}
|
|
}
|
|
|
|
|
|
public DateTime LT_PurchaseOrder_Label_OrderedDate
|
|
{
|
|
get
|
|
{
|
|
return mOrderedDate;
|
|
}
|
|
}
|
|
|
|
public object LT_PurchaseOrder_Label_ExpectedReceiveDate
|
|
{
|
|
get
|
|
{
|
|
return mExpectedReceiveDate.DBValue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(PurchaseOrderListReceivableForVendorInfo obj)
|
|
{
|
|
return this.mID.Equals(obj.mID);
|
|
}
|
|
|
|
}//end PurchaseOrderListReceivableForVendorInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected PurchaseOrderListReceivableForVendor()
|
|
{
|
|
// 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 PurchaseOrderListReceivableForVendorInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (PurchaseOrderListReceivableForVendorInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns display text that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public string this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (PurchaseOrderListReceivableForVendorInfo child in List)
|
|
{
|
|
if(child.mID==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(PurchaseOrderListReceivableForVendorInfo obj)
|
|
{
|
|
foreach (PurchaseOrderListReceivableForVendorInfo child in List)
|
|
{
|
|
if(child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Get all items for vendor
|
|
/// </summary>
|
|
/// <param name="Vendor"></param>
|
|
/// <returns>list of <see cref="PurchaseOrderListReceivableForVendor.PurchaseOrderListReceivableForVendorInfo"/> objects</returns>
|
|
public static PurchaseOrderListReceivableForVendor GetList(Guid Vendor)
|
|
{
|
|
return (PurchaseOrderListReceivableForVendor) DataPortal.Fetch(new Criteria(Vendor));
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Return an empty list
|
|
/// used for initializing grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static PurchaseOrderListReceivableForVendor GetEmptyList()
|
|
{
|
|
return new PurchaseOrderListReceivableForVendor();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
|
|
Criteria crit = (Criteria)Criteria;
|
|
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
dr=DBUtil.GetReaderFromSQLString(
|
|
//************************************************************
|
|
"SELECT aID, aPONumber, aReferenceNumber, " +
|
|
"aOrderedDate, aExpectedReceiveDate FROM aPurchaseOrder " +
|
|
"WHERE (aStatus = 2 OR aStatus = 3) AND (aVendorID " +
|
|
"= @ID) " +
|
|
"ORDER BY aOrderedDate",crit.Vendor
|
|
//************************************************************
|
|
);
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
PurchaseOrderListReceivableForVendorInfo info=new PurchaseOrderListReceivableForVendorInfo();
|
|
info.mID=dr.GetGuid("aID");
|
|
info.mPONumber=dr.GetInt32("aPONumber");
|
|
info.mReferenceNumber=dr.GetString("aReferenceNumber");
|
|
info.mOrderedDate=DBUtil.ToLocal(dr.GetDateTime("aOrderedDate"));
|
|
info.mExpectedReceiveDate=DBUtil.ToLocal(dr.GetSmartDate("aExpectedReceiveDate"));
|
|
InnerList.Add(info);
|
|
//*******************************************
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if(dr!=null) dr.Close();
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
|
|
public Guid Vendor;
|
|
|
|
public Criteria( Guid _Vendor)
|
|
{
|
|
Vendor=_Vendor;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end PurchaseOrderListReceivableForVendor
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL |