234 lines
7.2 KiB
C#
234 lines
7.2 KiB
C#
///////////////////////////////////////////////////////////
|
|
// PartRestockRequiredByVendorList.cs
|
|
// Implementation of Class PartRestockRequiredByVendorList
|
|
// CSLA type: Read only collection
|
|
// Created on: 25-Oct-2005
|
|
// Object design: John
|
|
// Coded: 25-Oct-2005
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
#pragma warning disable 1591
|
|
/// <summary>
|
|
/// Read only list of <see cref="PartRestockRequiredByVendorList.PartRestockRequiredByVendorListInfo"/> objects representing
|
|
/// Parts that are below their restock level by vendor.
|
|
/// Used in purchase order entry screen.
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public class PartRestockRequiredByVendorList : ReadOnlyCollectionBase
|
|
{
|
|
|
|
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Log fields
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct PartRestockRequiredByVendorListInfo
|
|
{
|
|
// Partid, warehouseid, show MinStockLevel , onhand, onorder , Required
|
|
|
|
internal Guid mPartID;
|
|
internal string mPartName;
|
|
internal Guid mPartWarehouseID;
|
|
internal string mPartWarehouseName;
|
|
internal decimal mMinStockLevel;
|
|
internal decimal mQuantityOnHand;
|
|
internal decimal mQuantityOnOrder;
|
|
internal decimal mQuantityRequired;
|
|
internal decimal mPartCost;
|
|
|
|
public Guid PartID {get{return mPartID;}}
|
|
[SqlColumnNameAttribute("aPart.aName")]
|
|
public string LT_O_Part {get{return mPartName;}}
|
|
public Guid PartWarehouseID {get{return mPartWarehouseID;}}
|
|
public string LT_O_PartWarehouse {get{return mPartWarehouseName;}}
|
|
public decimal LT_PartByWarehouseInventory_Label_MinStockLevel {get{return mMinStockLevel;}}
|
|
public decimal LT_PartByWarehouseInventory_Label_QuantityOnHand {get{return mQuantityOnHand;}}
|
|
public decimal LT_PartByWarehouseInventory_Label_QuantityOnOrder {get{return mQuantityOnOrder;}}
|
|
public decimal REQUIRED {get{return mQuantityRequired;}}
|
|
public decimal PartCost {get{return mPartCost;}}
|
|
//LT_PartByWarehouseInventory_Label_ReorderQuantity
|
|
|
|
|
|
}//end PartRestockRequiredByVendorListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
protected PartRestockRequiredByVendorList()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Business properties and methods
|
|
|
|
/// <summary>
|
|
/// Get item by index
|
|
/// </summary>
|
|
/// <param name="Item"></param>
|
|
public PartRestockRequiredByVendorListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (PartRestockRequiredByVendorListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Static methods
|
|
|
|
/// <summary>
|
|
/// Get list by wholesaler
|
|
/// </summary>
|
|
/// <param name="WholesalerID"></param>
|
|
/// <returns>list of <see cref="PartRestockRequiredByVendorList.PartRestockRequiredByVendorListInfo"/> objects</returns>
|
|
public static PartRestockRequiredByVendorList GetList(Guid WholesalerID)
|
|
{
|
|
return (PartRestockRequiredByVendorList) DataPortal.Fetch(new Criteria(WholesalerID));
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Return an empty list
|
|
/// used for initializing grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static PartRestockRequiredByVendorList GetEmptyList()
|
|
{
|
|
return new PartRestockRequiredByVendorList();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
// //Get a part list to use for displaying in grid
|
|
// PartPickList ppl=PartPickList.GetList();
|
|
|
|
Criteria crit = (Criteria)Criteria;
|
|
SafeDataReader dr = null;
|
|
|
|
try
|
|
{
|
|
dr=DBUtil.GetReaderFromSQLString(
|
|
//************************************************************
|
|
"SELECT aPartByWarehouseInventory.aMinStockLevel, " +
|
|
" aPart.aName AS aPARTNAME, aPart.aPartNumber,aPart.aID AS aPARTID, " +
|
|
"aPart.aUPC, aPart.aCost, " +
|
|
|
|
" aPartManufacturers.aName AS aPartManufacturerName, " +
|
|
" aPartCategory.aName AS aPartCategoryName, " +
|
|
" aPartAssembly.aName AS aPartAssemblyName, " +
|
|
|
|
"aVendor.aName AS aWHOLESALERNAME, aPartWarehouse.aID AS aWAREHOUSEID, aPartWarehouse.aName " +
|
|
"AS aWAREHOUSENAME, aPartByWarehouseInventory.aQuantityOnHand, " +
|
|
" aPartByWarehouseInventory.aQuantityOnOrder, " +
|
|
" aPartByWarehouseInventory.aMinStockLevel " +
|
|
"- (aPartByWarehouseInventory.aQuantityOnHand " +
|
|
"+ aPartByWarehouseInventory.aQuantityOnOrder) " +
|
|
"AS aREQUIRED, aPart.aWholesalerID " +
|
|
"FROM " +
|
|
" APARTBYWAREHOUSEINVENTORY " +
|
|
" LEFT OUTER JOIN APART ON (APARTBYWAREHOUSEINVENTORY.APARTID=APART.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR ON (APART.AWHOLESALERID=AVENDOR.AID) " +
|
|
|
|
" LEFT OUTER JOIN APARTCATEGORY ON (APART.APARTCATEGORYID=APARTCATEGORY.AID) " +
|
|
" LEFT OUTER JOIN APARTASSEMBLY ON (APART.APARTASSEMBLYID=APARTASSEMBLY.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR aPartManufacturers ON (APART.AMANUFACTURERID=aPartManufacturers.AID) " +
|
|
|
|
|
|
" LEFT OUTER JOIN APARTWAREHOUSE ON (APARTBYWAREHOUSEINVENTORY.APARTWAREHOUSEID=APARTWAREHOUSE.AID) " +
|
|
"WHERE (aPart.aWholesalerID = @ID) " +
|
|
"AND (aPartByWarehouseInventory.aMinStockLevel > 0) " +
|
|
"AND (aPartByWarehouseInventory.aMinStockLevel " +
|
|
"- (aPartByWarehouseInventory.aQuantityOnHand " +
|
|
"+ aPartByWarehouseInventory.aQuantityOnOrder) > 0) ",
|
|
crit.WholesalerID
|
|
|
|
//************************************************************
|
|
);
|
|
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
PartRestockRequiredByVendorListInfo info=new PartRestockRequiredByVendorListInfo();
|
|
info.mMinStockLevel=dr.GetDecimal("aMinStockLevel");
|
|
info.mPartID=dr.GetGuid("aPARTID");
|
|
|
|
info.mPartName= Part.PartDisplayFormatter(
|
|
dr.GetString("aPARTNAME"),
|
|
dr.GetString("aPartNumber"),
|
|
dr.GetString("aUPC"),
|
|
dr.GetString("aPartManufacturerName"),
|
|
dr.GetString("aPartCategoryName"),
|
|
dr.GetString("aPartAssemblyName"),
|
|
AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat
|
|
);
|
|
|
|
|
|
info.mPartWarehouseID=dr.GetGuid("aWAREHOUSEID");
|
|
info.mPartWarehouseName=dr.GetString("aWAREHOUSENAME");
|
|
info.mQuantityOnHand=dr.GetDecimal("aQuantityOnHand");
|
|
info.mQuantityOnOrder=dr.GetDecimal("aQuantityOnOrder");
|
|
info.mQuantityRequired=dr.GetDecimal("aREQUIRED");
|
|
info.mPartCost=dr.GetDecimal("aCost");
|
|
|
|
|
|
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 WholesalerID;
|
|
|
|
public Criteria( Guid _WholesalerID)
|
|
{
|
|
WholesalerID=_WholesalerID;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end PartRestockRequiredByVendorList
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL |