491 lines
17 KiB
C#
491 lines
17 KiB
C#
///////////////////////////////////////////////////////////
|
|
// PartInventoryAdjustmentListDetailed.cs
|
|
// Implementation of Class PartInventoryAdjustmentListDetailed
|
|
// CSLA type: Read only collection
|
|
// Created on: 26-Nov-2010
|
|
// Object design: John
|
|
// Coded: 26-Nov-2010
|
|
///////////////////////////////////////////////////////////
|
|
|
|
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="PartInventoryAdjustmentListDetailed.PartInventoryAdjustmentListDetailedInfo"/> objects used in grid lists detailed reports
|
|
/// </summary>
|
|
[Serializable]
|
|
public class PartInventoryAdjustmentListDetailed : ReadOnlyCollectionBase
|
|
{
|
|
|
|
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Properties
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct PartInventoryAdjustmentListDetailedInfo
|
|
{
|
|
|
|
internal GridNameValueCellItem mAdjustmentNumber; //and ID
|
|
internal string mReasonForAdjustment;
|
|
internal SmartDate mDateAdjusted;
|
|
|
|
[SqlColumnNameAttribute("aPartInventoryAdjustment.AADJUSTMENTNUMBER", "aPartInventoryAdjustment.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.PartInventoryAdjustment)]
|
|
public GridNameValueCellItem LT_PartInventoryAdjustment_Label_AdjustmentNumber
|
|
{
|
|
get
|
|
{
|
|
return mAdjustmentNumber;
|
|
}
|
|
}
|
|
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_PartInventoryAdjustment_Label_ReasonForAdjustment
|
|
{
|
|
get
|
|
{
|
|
return mReasonForAdjustment;
|
|
}
|
|
}
|
|
|
|
[Display(DisplayType.DateTime)]
|
|
public object LT_PartInventoryAdjustment_Label_DateAdjusted
|
|
{
|
|
get
|
|
{
|
|
return mDateAdjusted.DBValue;
|
|
}
|
|
}
|
|
|
|
internal GridNameValueCellItem mCreator;
|
|
[SqlColumnNameAttribute("aUser.aLastName", "aPartInventoryAdjustment.aCreator"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.User)]
|
|
public GridNameValueCellItem LT_Common_Label_Creator { get { return this.mCreator; } }
|
|
|
|
//Item level
|
|
internal GridNameValueCellItem mPartWarehouseID;
|
|
[SqlColumnNameAttribute("aPartWarehouse.aName", "APARTINVENTORYADJUSTMENTITEM.APARTWAREHOUSEID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.PartWarehouse)]
|
|
public GridNameValueCellItem LT_O_PartWarehouse { get { return mPartWarehouseID; } }
|
|
|
|
|
|
internal GridNameValueCellItem mPartName; //and ID
|
|
[SqlColumnNameAttribute("aPart.aName",
|
|
"aPart.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Part)]
|
|
public GridNameValueCellItem LT_O_Part { get { return mPartName; } }
|
|
|
|
|
|
internal decimal mQuantityAdjustment;
|
|
[Display(DisplayType.DecimalNumber)]
|
|
public decimal LT_PartInventoryAdjustmentItem_Label_QuantityAdjustment { get { return mQuantityAdjustment; } }
|
|
|
|
//Serials level
|
|
internal string mPartSerial;
|
|
[SqlColumnNameAttribute("aPartSerial.aSerialNumber"), Display(DisplayType.Text)]
|
|
public string LT_Common_Label_SerialNumber { get { return mPartSerial; } }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(PartInventoryAdjustmentListDetailedInfo obj)
|
|
{
|
|
return this.mAdjustmentNumber.Value.Equals(obj.mAdjustmentNumber.Value);
|
|
}
|
|
|
|
}//end PartInventoryAdjustmentListDetailedInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected PartInventoryAdjustmentListDetailed()
|
|
{
|
|
// 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 PartInventoryAdjustmentListDetailedInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (PartInventoryAdjustmentListDetailedInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns display text that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public string this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (PartInventoryAdjustmentListDetailedInfo child in List)
|
|
{
|
|
if(child.mAdjustmentNumber.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(PartInventoryAdjustmentListDetailedInfo obj)
|
|
{
|
|
foreach (PartInventoryAdjustmentListDetailedInfo 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 "PartInventoryAdjustmentListDetailed";
|
|
}
|
|
}
|
|
|
|
/// <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.PartInventoryAdjustment;
|
|
}
|
|
}
|
|
|
|
/// <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.PartInventoryAdjustmentsDetailed";
|
|
}
|
|
}
|
|
|
|
/// <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(PartInventoryAdjustmentListDetailedInfo);
|
|
}
|
|
}
|
|
|
|
/// <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_PartInventoryAdjustment_Label_AdjustmentNumber";
|
|
}
|
|
}
|
|
/// <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 PartInventoryAdjustmentListDetailed Get(string Filter, int MaxRecords, List<Guid> IDList)
|
|
{
|
|
return (PartInventoryAdjustmentListDetailed)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get all PartInventoryAdjustment (filtered by crit)
|
|
/// </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="PartInventoryAdjustmentListDetailed.PartInventoryAdjustmentListDetailedInfo"/> objects</returns>
|
|
|
|
public static PartInventoryAdjustmentListDetailed GetList(string xmlCriteria)
|
|
{
|
|
return (PartInventoryAdjustmentListDetailed) DataPortal.Fetch(new Criteria(xmlCriteria,null,-1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes a single ID and returns a "list" of one object
|
|
/// </summary>
|
|
/// <param name="PartInventoryAdjustmentID">ID of PartInventoryAdjustment object</param>
|
|
/// <returns>list of <see cref="PartInventoryAdjustmentListDetailed.PartInventoryAdjustmentListDetailedInfo"/> objects</returns>
|
|
public static PartInventoryAdjustmentListDetailed GetListForSingleItem(Guid PartInventoryAdjustmentID)
|
|
{
|
|
//Case 556
|
|
List<Guid> l = new List<Guid>();
|
|
l.Add(PartInventoryAdjustmentID);
|
|
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="PartInventoryAdjustmentListDetailed.PartInventoryAdjustmentListDetailedInfo"/> objects</returns>
|
|
public static PartInventoryAdjustmentListDetailed GetListFromIDList(List<Guid> IDList)
|
|
{
|
|
//case 556
|
|
//Handle empty list
|
|
if (IDList.Count == 0)
|
|
return new PartInventoryAdjustmentListDetailed();
|
|
return (PartInventoryAdjustmentListDetailed)DataPortal.Fetch(new Criteria("", IDList, -1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return an empty list
|
|
/// used for initializing grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static PartInventoryAdjustmentListDetailed GetEmptyList()
|
|
{
|
|
return new PartInventoryAdjustmentListDetailed();
|
|
}
|
|
|
|
|
|
#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;
|
|
string q =
|
|
//************************************************************
|
|
"SELECT ~MAXRECS~ APARTINVENTORYADJUSTMENT.AID AS APIAID, APARTINVENTORYADJUSTMENT.ACREATOR AS APIACREATOR, " +
|
|
" APARTINVENTORYADJUSTMENT.ADATEADJUSTED, " +
|
|
" APARTINVENTORYADJUSTMENT.AADJUSTMENTNUMBER, " +
|
|
" APARTINVENTORYADJUSTMENT.AREASONFORADJUSTMENT, " +
|
|
" APARTWAREHOUSE.ANAME AS APARTWAREHOUSENAME, APARTWAREHOUSE.AID AS APARTWAREHOUSEID, " +
|
|
" AVENDOR.ANAME AS AMANUFACTURERNAME, APART.ANAME AS APARTNAME, APART.AID AS APARTID, " +
|
|
" APART.APARTNUMBER, APART.AUPC, APARTCATEGORY.ANAME AS APARTCATEGORYNAME, " +
|
|
" APARTASSEMBLY.ANAME AS APARTASSEMBLYNAME, " +
|
|
" APARTINVENTORYADJUSTMENTITEM.AQUANTITYADJUSTMENT, ASERIALNUMBER, " +
|
|
" AUSER.AFIRSTNAME, AUSER.ALASTNAME, " +
|
|
" AUSER.AINITIALS, AUSER.AEMPLOYEENUMBER, AREGION.ANAME AS AREGIONNAME " +
|
|
|
|
" FROM APARTINVENTORYADJUSTMENTITEM " +
|
|
" APARTINVENTORYADJUSTMENTITEM " +
|
|
" RIGHT OUTER JOIN APARTINVENTORYADJUSTMENT ON (APARTINVENTORYADJUSTMENTITEM.APARTINVENTORYADJUSTMENTID = APARTINVENTORYADJUSTMENT.AID) " +
|
|
" LEFT OUTER JOIN AUSER ON (APARTINVENTORYADJUSTMENT.ACREATOR = AUSER.AID) " +
|
|
" LEFT OUTER JOIN AREGION ON (AUSER.AREGIONID=AREGION.AID) " +
|
|
" LEFT OUTER JOIN APARTSERIAL ON (APARTINVENTORYADJUSTMENTITEM.AID = APARTSERIAL.AADJUSTMENTID) " +
|
|
" LEFT JOIN APART ON APARTINVENTORYADJUSTMENTITEM.APARTID = APART.AID " +
|
|
" LEFT JOIN APARTWAREHOUSE ON APARTINVENTORYADJUSTMENTITEM.APARTWAREHOUSEID = APARTWAREHOUSE.AID " +
|
|
" LEFT OUTER JOIN APARTASSEMBLY ON APART.APARTASSEMBLYID = APARTASSEMBLY.AID " +
|
|
" LEFT OUTER JOIN AVENDOR ON APART.AMANUFACTURERID = AVENDOR.AID " +
|
|
" LEFT OUTER JOIN APARTCATEGORY ON APART.APARTCATEGORYID = APARTCATEGORY.AID ";
|
|
|
|
if (crit.MaxRecords > 0)
|
|
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
|
|
else
|
|
q = q.Replace("~MAXRECS~", "");
|
|
|
|
if (crit.IDList != null)
|
|
{
|
|
//Case 556
|
|
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
|
|
sbIN.Append(" WHERE (aPartInventoryAdjustment.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
|
|
{
|
|
//Grid criteria
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(q +
|
|
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML,true) + " " +
|
|
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML));
|
|
}
|
|
|
|
|
|
|
|
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
PartInventoryAdjustmentListDetailedInfo info=new PartInventoryAdjustmentListDetailedInfo();
|
|
|
|
info.mAdjustmentNumber=new GridNameValueCellItem(
|
|
dr.GetGuid("APIAID"),
|
|
dr.GetInt32("AADJUSTMENTNUMBER").ToString(),
|
|
RootObjectTypes.PartInventoryAdjustment);
|
|
|
|
info.mReasonForAdjustment=dr.GetString("aReasonForAdjustment");
|
|
info.mDateAdjusted=DBUtil.ToLocal(dr.GetSmartDate("aDateAdjusted"));
|
|
|
|
info.mCreator = new GridNameValueCellItem(
|
|
dr.GetGuid("APIACREATOR"),
|
|
User.NameFormatter(dr.GetString("aFirstName"), dr.GetString("aLastName"),
|
|
dr.GetString("aInitials"), dr.GetString("aEmployeeNumber"), dr.GetString("AREGIONNAME"),
|
|
AyaBizUtils.GlobalSettings.DefaultScheduleableUserNameDisplayFormat),
|
|
RootObjectTypes.User);
|
|
|
|
//Items level
|
|
info.mPartWarehouseID = new GridNameValueCellItem(
|
|
dr.GetGuid("aPartWarehouseID"),
|
|
dr.GetString("aPartWarehouseName"),
|
|
RootObjectTypes.PartWarehouse);
|
|
|
|
info.mPartName = new GridNameValueCellItem(
|
|
dr.GetGuid("APARTID"),
|
|
Part.PartDisplayFormatter(
|
|
dr.GetString("APARTNAME"),
|
|
dr.GetString("aPARTNUMBER"),
|
|
dr.GetString("aUPC"),
|
|
dr.GetString("aMANUFACTURERNAME"),
|
|
dr.GetString("aPARTCATEGORYNAME"),
|
|
dr.GetString("aPARTASSEMBLYNAME"),
|
|
AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat),
|
|
RootObjectTypes.Part);
|
|
|
|
info.mQuantityAdjustment = dr.GetDecimal("aQuantityAdjustment");
|
|
|
|
//sn level
|
|
info.mPartSerial = dr.GetString("aSerialNumber");
|
|
|
|
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 PartInventoryAdjustmentListDetailed
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL |