144 lines
4.1 KiB
C#
144 lines
4.1 KiB
C#
///////////////////////////////////////////////////////////
|
|
// Bool.cs
|
|
// Implementation of Class PartInventoryValuesFetcher
|
|
// CSLA type: Read-only object
|
|
// Created on: 29-Dec-2007
|
|
// Object design: John
|
|
// Coded: John 29-Dec-2007
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using CSLA.Data;
|
|
using GZTW.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
|
|
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
/// <summary>
|
|
/// Used to quickly fetch a various inventory related values
|
|
/// for a particular part over all warehouses combined
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public class PartInventoryValuesFetcher : ReadOnlyBase//v8port: this is only used by QBI, it's probably redundant or should be combined
|
|
{
|
|
|
|
private decimal mQuantityOnHand = 0;
|
|
private decimal mQuantityOnOrder = 0;
|
|
private decimal mQtyOnOrderCommitted = 0;
|
|
private decimal mMinStockLevel = 0;
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Private constructor to prevent direct instantiation
|
|
/// </summary>
|
|
private PartInventoryValuesFetcher()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region Business properties
|
|
/// <summary>
|
|
/// Quantity in stock in all warehouses
|
|
/// </summary>
|
|
public decimal QuantityOnHand { get { return mQuantityOnHand; } }
|
|
/// <summary>
|
|
/// Quantity on open <see cref="PurchaseOrder"/> objects
|
|
/// </summary>
|
|
public decimal QuantityOnOrder { get { return mQuantityOnOrder; } }
|
|
/// <summary>
|
|
/// Quantity on open <see cref="PurchaseOrder"/> objects spoken for on current <see cref="WorkorderItemPartRequest"/> objects
|
|
/// </summary>
|
|
public decimal QtyOnOrderCommitted { get { return mQtyOnOrderCommitted; } }
|
|
/// <summary>
|
|
/// Desired minimum quantity to keep in stock
|
|
/// </summary>
|
|
public decimal MinStockLevel { get { return mMinStockLevel; } }
|
|
#endregion
|
|
|
|
#region Static methods
|
|
|
|
/// <summary>
|
|
/// Retrieve a snapshot of current
|
|
/// inventory values
|
|
/// </summary>
|
|
/// <param name="PartID">ID of part</param>
|
|
/// <returns>PartInventoryValuesFetcher object</returns>
|
|
public static PartInventoryValuesFetcher GetItem(Guid PartID)
|
|
{
|
|
|
|
return (PartInventoryValuesFetcher)DataPortal.Fetch(new Criteria(PartID));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param Bool="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
Criteria crit = (Criteria)Criteria;
|
|
|
|
DBCommandWrapper cm = DBUtil.DB.GetSqlStringCommandWrapper(
|
|
"SELECT aQuantityOnHand, aQuantityOnOrder,aMinStockLevel, " +
|
|
"aQtyOnOrderCommitted FROM aPartByWarehouseInventory " +
|
|
"WHERE (aPartID = @PartID)"
|
|
);
|
|
cm.AddInParameter("@PartID", DbType.Guid, crit.PartID);
|
|
|
|
|
|
SafeDataReader dr = null;
|
|
|
|
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
|
|
|
|
while (dr.Read())
|
|
{
|
|
|
|
mQuantityOnHand += dr.GetDecimal("aQuantityOnHand");
|
|
mQuantityOnOrder += dr.GetDecimal("aQuantityOnOrder");
|
|
mQtyOnOrderCommitted += dr.GetDecimal("aQtyOnOrderCommitted");
|
|
mMinStockLevel += dr.GetDecimal("aMinStockLevel");
|
|
}
|
|
dr.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
public Guid PartID;
|
|
|
|
|
|
public Criteria(Guid _PartID)
|
|
{
|
|
PartID = _PartID;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end Bool
|
|
|
|
}//end Boolspace GZTW.AyaNova.BLL |