540 lines
19 KiB
C#
540 lines
19 KiB
C#
///////////////////////////////////////////////////////////
|
|
// WorkorderItemPartRequestList.cs
|
|
// Implementation of Class WorkorderItemPartRequestList
|
|
// CSLA type: Read only collection
|
|
// Created on: 26-Oct-2005
|
|
// Object design: Joyce
|
|
// Coded: 26-Oct-2005
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
using System.Collections.Generic;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
#pragma warning disable 1591
|
|
/// <summary>
|
|
/// Read only list of <see cref="WorkorderItemPartRequestList.WorkorderItemPartRequestListInfo"/> objects representing <see cref="WorkorderItemPartRequest"/> objects.
|
|
/// Used in Grid and reporting.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class WorkorderItemPartRequestList : ReadOnlyCollectionBase
|
|
{
|
|
|
|
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Read only list of parts requested on workorders
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct WorkorderItemPartRequestListInfo
|
|
{
|
|
|
|
internal GridNameValueCellItem mPartNumber;
|
|
internal GridNameValueCellItem mPartName;
|
|
internal string mPartManufacturerPartNumber;
|
|
internal GridNameValueCellItem mPartManufacturer;
|
|
internal string mPartWholesalerPartNumber;
|
|
internal GridNameValueCellItem mPartWholesaler;
|
|
|
|
//Displays workorder number, but contains link to workorderitempartrequest
|
|
internal GridNameValueCellItem mWorkorderItemPartRequest;
|
|
internal SmartDate mPartRequestedDate;
|
|
internal GridNameValueCellItem mPartWarehouse;
|
|
internal GridNameValueCellItem mPOWholesaler;
|
|
internal GridNameValueCellItem mPO;
|
|
internal SmartDate mPOOrderedDate;
|
|
internal SmartDate mPOExpectedReceiveDate;
|
|
internal decimal mQuantity;
|
|
|
|
//case 23
|
|
internal bool mClosed;
|
|
|
|
[Display(DisplayType.DecimalNumber)]
|
|
public decimal LT_WorkorderItemPartRequest_Label_Quantity
|
|
{get{return mQuantity;}}
|
|
|
|
|
|
[SqlColumnNameAttribute("aPart.aPartNumber","aWorkorderItemPartRequest.aPartID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Part)]
|
|
public GridNameValueCellItem LT_Part_Label_PartNumber
|
|
{get{return mPartNumber;}}
|
|
|
|
[SqlColumnNameAttribute("aPart.aName","aWorkorderItemPartRequest.aPartID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Part)]
|
|
public GridNameValueCellItem LT_Part_Label_Name
|
|
{get{return mPartName;}}
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_ManufacturerNumber
|
|
{get{return mPartManufacturerPartNumber;}}
|
|
|
|
[SqlColumnNameAttribute("aMANUFACTURER.aName","aPart.aManufacturerID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Vendor)]
|
|
public GridNameValueCellItem LT_Part_Label_ManufacturerID
|
|
{get{return mPartManufacturer;}}
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Part_Label_WholesalerNumber
|
|
{get{return mPartWholesalerPartNumber;}}
|
|
|
|
[SqlColumnNameAttribute("aWHOLESALER.aName", "aPart.aWholesalerID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Vendor)]
|
|
public GridNameValueCellItem LT_Vendor_Label_VendorType_Wholesaler
|
|
{get{return mPartWholesaler;}}
|
|
|
|
//Shows Workorder number but links to workorderitempartrequest
|
|
[SqlColumnNameAttribute("aWorkorderService.aServiceNumber","aWorkorderItemPartRequest.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.WorkorderItemPartRequest)]
|
|
public GridNameValueCellItem LT_O_Workorder
|
|
{get{return mWorkorderItemPartRequest;}}
|
|
|
|
//Creation date of workorderitempartrequest
|
|
[SqlColumnNameAttribute("aWorkorderItemPartRequest.aCreated"),Display(DisplayType.DateTime)]
|
|
public object LT_Common_Label_Created
|
|
{get{return mPartRequestedDate.DBValue;}}
|
|
|
|
[SqlColumnNameAttribute("aPartWarehouse.aName","aWorkorderItemPartRequest.aPartWarehouseID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.PartWarehouse)]
|
|
public GridNameValueCellItem LT_O_PartWarehouse
|
|
{get{return mPartWarehouse;}}
|
|
|
|
[SqlColumnNameAttribute("aPOVENDOR.aName","aPurchaseOrder.aVendorID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Vendor)]
|
|
public GridNameValueCellItem LT_PurchaseOrderItem_Label_UI_OrderedFrom
|
|
{get{return mPOWholesaler;}}
|
|
|
|
[SqlColumnNameAttribute("aPurchaseOrder.aPONumber","aPurchaseOrder.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.PurchaseOrder)]
|
|
public GridNameValueCellItem LT_PurchaseOrder_Label_PONumber
|
|
{get{return mPO;}}
|
|
|
|
[Display(DisplayType.DateTime)]
|
|
public object LT_PurchaseOrder_Label_OrderedDate
|
|
{get{return mPOOrderedDate.DBValue;}}
|
|
|
|
[Display(DisplayType.DateTime)]
|
|
public object LT_PurchaseOrder_Label_ExpectedReceiveDate
|
|
{get{return mPOExpectedReceiveDate.DBValue;}}
|
|
|
|
|
|
//Case 23
|
|
[Display(DisplayType.TrueFalse)]
|
|
public bool LT_Workorder_Label_Closed { get { return mClosed; } }
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(WorkorderItemPartRequestListInfo obj)
|
|
{
|
|
return this.mWorkorderItemPartRequest.Value.Equals(obj.mWorkorderItemPartRequest.Value);
|
|
}
|
|
|
|
}//end WorkorderItemPartRequestListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
private RelativeTimeFormatter rtfm=null;
|
|
|
|
protected WorkorderItemPartRequestList()
|
|
{
|
|
|
|
rtfm=RelativeTimeFormatter.GetItem(User.CurrentUserLanguage);
|
|
// 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 WorkorderItemPartRequestListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (WorkorderItemPartRequestListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region contains
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(WorkorderItemPartRequestListInfo obj)
|
|
{
|
|
foreach (WorkorderItemPartRequestListInfo 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 "WorkorderItemPartRequestList";
|
|
}
|
|
}
|
|
|
|
/// <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.WorkorderItemPartRequest;
|
|
}
|
|
}
|
|
|
|
/// <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 "WorkorderItemPartRequest.Label.List";
|
|
}
|
|
}
|
|
|
|
/// <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(WorkorderItemPartRequestListInfo);
|
|
}
|
|
}
|
|
|
|
/// <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_O_Workorder";
|
|
}
|
|
}
|
|
/// <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 WorkorderItemPartRequestList Get(string Filter, int MaxRecords, List<Guid> IDList)
|
|
{
|
|
return (WorkorderItemPartRequestList)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get all WorkorderItemPartRequest (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="WorkorderItemPartRequestList.WorkorderItemPartRequestListInfo"/> objects</returns>
|
|
public static WorkorderItemPartRequestList GetList(string xmlCriteria)
|
|
{
|
|
return (WorkorderItemPartRequestList) DataPortal.Fetch(new Criteria(xmlCriteria, null, -1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes a single ID and returns a "list" of one object
|
|
/// </summary>
|
|
/// <param name="WorkorderItemPartRequestID">ID of WorkorderItemPartRequest</param>
|
|
/// <returns>list of <see cref="WorkorderItemPartRequestList.WorkorderItemPartRequestListInfo"/> objects</returns>
|
|
public static WorkorderItemPartRequestList GetListForSingleItem(Guid WorkorderItemPartRequestID)
|
|
{
|
|
//Case 556
|
|
List<Guid> l = new List<Guid>();
|
|
l.Add(WorkorderItemPartRequestID);
|
|
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="WorkorderItemPartRequestList.WorkorderItemPartRequestListInfo"/> objects</returns>
|
|
public static WorkorderItemPartRequestList GetListFromIDList(List<Guid> IDList)
|
|
{
|
|
//case 556
|
|
//Handle empty list
|
|
if (IDList.Count == 0)
|
|
return new WorkorderItemPartRequestList();
|
|
return (WorkorderItemPartRequestList)DataPortal.Fetch(new Criteria("", IDList, -1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return an empty list
|
|
/// used for initializing grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static WorkorderItemPartRequestList GetEmptyList()
|
|
{
|
|
return new WorkorderItemPartRequestList();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
|
|
Criteria crit = (Criteria)Criteria;
|
|
|
|
SafeDataReader dr = null;
|
|
|
|
try
|
|
{
|
|
|
|
//************************************************************
|
|
string q = "SELECT ~MAXRECS~ aWorkorderItemPartRequest.aPartID, aWorkorderItemPartRequest.aQuantity, aPart.aName " +
|
|
"AS aPARTNAME, aPart.aPartNumber AS " +
|
|
"aPARTNUMBER, aPart.aManufacturerNumber, aPart.aWholesalerNumber, " +
|
|
" aPart.aManufacturerID AS aPARTMANUFACTURERID, " +
|
|
"aMANUFACTURER.aName AS aPARTMANUFACTURERNAME, aPart.aWholesalerID AS aPARTWHOLESALERID, " +
|
|
" aWHOLESALER.aName AS aPARTWHOLESALERNAME, " +
|
|
" aWorkorderItemPartRequest.aID AS aPARTREQUESTID, " +
|
|
//case 23
|
|
" aWorkorder.aClosed, " +
|
|
|
|
" aWorkorderService.aServiceNumber AS aWORKORDERNUMBER, " +
|
|
" aWorkorderItemPartRequest.aCreated " +
|
|
"AS aCreatedDate, aWorkorderItemPartRequest.aPartWarehouseID, " +
|
|
" aPartWarehouse.aName AS " +
|
|
"aPARTWAREHOUSENAME, aPurchaseOrder.aVendorID " +
|
|
"AS aPURCHASEORDERVENDORID, aPOVENDOR.aName AS aPURCHASEORDERVENDORNAME, " +
|
|
" aPurchaseOrder.aID AS aPURCHASEORDERID, " +
|
|
" aPurchaseOrder.aPONumber, aPurchaseOrder.aOrderedDate, " +
|
|
" aPurchaseOrder.aExpectedReceiveDate " +
|
|
|
|
"FROM " +
|
|
"AWORKORDERITEMPARTREQUEST " +
|
|
" LEFT OUTER JOIN APARTWAREHOUSE ON (AWORKORDERITEMPARTREQUEST.APARTWAREHOUSEID=APARTWAREHOUSE.AID) " +
|
|
" LEFT OUTER JOIN APURCHASEORDERITEM ON (AWORKORDERITEMPARTREQUEST.APURCHASEORDERITEMID=APURCHASEORDERITEM.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERITEM ON (AWORKORDERITEMPARTREQUEST.AWORKORDERITEMID=AWORKORDERITEM.AID) " +
|
|
" LEFT OUTER JOIN APART ON (AWORKORDERITEMPARTREQUEST.APARTID=APART.AID) " +
|
|
" LEFT OUTER JOIN APURCHASEORDER ON (APURCHASEORDERITEM.APURCHASEORDERID=APURCHASEORDER.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR aPOVENDOR ON (APURCHASEORDER.AVENDORID=aPOVENDOR.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR aWHOLESALER ON (APART.AWHOLESALERID=aWHOLESALER.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR aMANUFACTURER ON (APART.AMANUFACTURERID=aMANUFACTURER.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID=AWORKORDERSERVICE.AWORKORDERID) " +
|
|
//Case 23
|
|
" LEFT OUTER JOIN AWORKORDER ON (AWORKORDERITEM.AWORKORDERID=AWORKORDER.AID) ";
|
|
|
|
|
|
if (crit.IDList != null)
|
|
{
|
|
//Case 556
|
|
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
|
|
sbIN.Append(" WHERE (aWorkorderItemPartRequest.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(")) ");
|
|
|
|
q = q.Replace("~MAXRECS~", "") + sbIN.ToString() + AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
q=q+ AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML, true) + " " +
|
|
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
|
|
//************************************************************
|
|
|
|
if (crit.MaxRecords > 0)
|
|
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
|
|
else
|
|
q = q.Replace("~MAXRECS~", "");
|
|
}
|
|
|
|
|
|
|
|
dr=DBUtil.GetReaderFromSQLString(q);
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
WorkorderItemPartRequestListInfo info=new WorkorderItemPartRequestListInfo();
|
|
|
|
info.mPartManufacturer=new GridNameValueCellItem(
|
|
dr.GetGuid("aPARTMANUFACTURERID"),
|
|
dr.GetString("aPARTMANUFACTURERNAME"),
|
|
RootObjectTypes.Vendor
|
|
);
|
|
|
|
info.mPartManufacturerPartNumber=dr.GetString("aManufacturerNumber");
|
|
|
|
info.mPartName=new GridNameValueCellItem(
|
|
dr.GetGuid("aPartID"),
|
|
dr.GetString("aPARTNAME"),
|
|
RootObjectTypes.Part
|
|
);
|
|
|
|
info.mPartNumber=new GridNameValueCellItem(
|
|
dr.GetGuid("aPartID"),
|
|
dr.GetString("aPARTNUMBER"),
|
|
RootObjectTypes.Part
|
|
);
|
|
|
|
info.mPartRequestedDate=DBUtil.ToLocal(dr.GetSmartDate("aCreatedDate"));
|
|
|
|
info.mPartWarehouse=new GridNameValueCellItem(
|
|
dr.GetGuid("aPartWarehouseID"),
|
|
dr.GetString("aPARTWAREHOUSENAME"),
|
|
RootObjectTypes.PartWarehouse
|
|
);
|
|
|
|
info.mPartWholesaler=new GridNameValueCellItem(
|
|
dr.GetGuid("aPARTWHOLESALERID"),
|
|
dr.GetString("aPARTWHOLESALERNAME"),
|
|
RootObjectTypes.Vendor
|
|
);
|
|
|
|
info.mPartWholesalerPartNumber=dr.GetString("aWholesalerNumber");
|
|
|
|
info.mPO=new GridNameValueCellItem(
|
|
dr.GetGuid("aPURCHASEORDERID"),
|
|
dr.GetInt32("aPONumber")==0?"":dr.GetInt32("aPONumber").ToString(),
|
|
RootObjectTypes.PurchaseOrder
|
|
);
|
|
|
|
info.mPOExpectedReceiveDate=DBUtil.ToLocal(dr.GetSmartDate("aExpectedReceiveDate"));
|
|
|
|
info.mPOOrderedDate=DBUtil.ToLocal(dr.GetSmartDate("aOrderedDate"));
|
|
|
|
info.mPOWholesaler=new GridNameValueCellItem(
|
|
dr.GetGuid("aPURCHASEORDERVENDORID"),
|
|
dr.GetString("aPURCHASEORDERVENDORNAME"),
|
|
RootObjectTypes.Vendor
|
|
);
|
|
|
|
info.mWorkorderItemPartRequest=new GridNameValueCellItem(
|
|
dr.GetGuid("aPARTREQUESTID"),
|
|
dr.GetInt32("aWORKORDERNUMBER").ToString(),
|
|
RootObjectTypes.WorkorderItemPartRequest
|
|
);
|
|
|
|
info.mQuantity=dr.GetDecimal("aQuantity");
|
|
|
|
//case 23
|
|
info.mClosed = dr.GetBoolean("aClosed");
|
|
|
|
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 WorkorderItemPartRequestList
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL |