284 lines
8.4 KiB
C#
284 lines
8.4 KiB
C#
///////////////////////////////////////////////////////////
|
|
// Bool.cs
|
|
// Implementation of Class PurchaseOrderReceiptDetailedReportData
|
|
// CSLA type: Read-only object
|
|
// Created on: 29-Dec-2005
|
|
// Object design: John
|
|
// Coded: 29-Dec-2005
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using CSLA.Data;
|
|
using GZTW.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
/// <summary>
|
|
/// Detailed read only data used for reporting purposes.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class PurchaseOrderReceiptDetailedReportData : ReadOnlyBase
|
|
{
|
|
|
|
#region Attributes
|
|
private ReportDataSet ds;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Private constructor to prevent direct instantiation
|
|
/// </summary>
|
|
private PurchaseOrderReceiptDetailedReportData()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <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 "PurchaseOrderReceiptDetailed";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get list
|
|
/// </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><see cref="ReportDataSet"/></returns>
|
|
public static ReportDataSet GetItems(string xmlCriteria)
|
|
{
|
|
|
|
return ((PurchaseOrderReceiptDetailedReportData)DataPortal.Fetch(new Criteria(xmlCriteria,Guid.Empty))).ds;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes a single ID and returns a "list" of one object
|
|
/// </summary>
|
|
/// <param name="PurchaseOrderReceiptID">ID of PurchaseOrderReceipt object</param>
|
|
/// <returns><see cref="ReportDataSet"/></returns>
|
|
public static ReportDataSet GetItem(Guid PurchaseOrderReceiptID)
|
|
{
|
|
return ((PurchaseOrderReceiptDetailedReportData)DataPortal.Fetch(new Criteria("",PurchaseOrderReceiptID))).ds;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Initialize data set
|
|
|
|
private void InitDS()
|
|
{
|
|
ds=new ReportDataSet();
|
|
|
|
System.IO.Stream s=Assembly.GetExecutingAssembly().GetManifestResourceStream("GZTW.AyaNova.BLL.PurchaseOrderReceiptDetailedSchema.xsd");
|
|
ds.ReadXmlSchema(s);
|
|
ds.ShowOnlyStartingWith="PurchaseOrderReceipt";
|
|
|
|
}
|
|
|
|
#endregion initalize data set
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
|
|
InitDS();
|
|
|
|
|
|
|
|
Criteria crit = (Criteria)Criteria;
|
|
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
#region Cached objects
|
|
|
|
//Users
|
|
UserPickList users=UserPickList.GetList(false);
|
|
|
|
|
|
|
|
#endregion cached objects
|
|
|
|
DBCommandWrapper cm = null;
|
|
|
|
#region Query
|
|
string q=
|
|
//***********************************************************************************************************
|
|
"SELECT aPurchaseOrderReceipt.aID, aPurchaseOrderReceipt.aCreator AS aCreatorID, " +
|
|
"aPurchaseOrderReceipt.aReceivedDate, " +
|
|
"aVendor.aID AS aVendorID, aVendor.aName AS aVendorName FROM aPurchaseOrderReceipt " +
|
|
"LEFT OUTER JOIN aVendor ON " +
|
|
"aPurchaseOrderReceipt.aVendorID = aVendor.aID ";
|
|
|
|
//***********************************************************************************************************
|
|
;
|
|
|
|
//Built in order for reporting
|
|
string qOrderBy=
|
|
" aPurchaseOrderReceipt.aID ";
|
|
|
|
//One item or grid criteria?
|
|
if(crit.ID!=Guid.Empty)
|
|
{
|
|
//One item:
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(q + " WHERE (aPurchaseOrderReceipt.aID=@ID) ORDER BY " + qOrderBy);
|
|
cm.AddInParameter("@ID",DbType.Guid,crit.ID);
|
|
}
|
|
else
|
|
{
|
|
//string strCrit=AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML,false);
|
|
//Grid criteria
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(q +
|
|
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML,true) + " " +
|
|
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML) );
|
|
}
|
|
|
|
#endregion query
|
|
|
|
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
|
|
|
|
DataRow r=null;
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
|
|
#region PurchaseOrderReceipt level
|
|
|
|
r=ds.Tables["PurchaseOrderReceipt"].NewRow();
|
|
r["ID"]=dr.GetGuid("aID");
|
|
r["LT_Common_Label_Creator"]=users[dr.GetGuid("aCreatorID")];
|
|
r["LT_PurchaseOrderReceipt_Label_ReceivedDate"]=DBUtil.ToLocal(dr.GetSmartDate("aReceivedDate")).Date;
|
|
r["LT_O_Vendor"]=dr.GetString("aVendorName");
|
|
ds.Tables["PurchaseOrderReceipt"].Rows.Add(r);
|
|
|
|
#endregion purchase order receipt level
|
|
|
|
#region Item Level
|
|
SafeDataReader dritems=DBUtil.GetReaderFromSQLString(
|
|
"SELECT aPurchaseOrderReceiptItem.aID, aPartWarehouse.aName " +
|
|
"AS aPartWarehouseName, aPurchaseOrderReceiptItem.aQuantityReceived, " +
|
|
" aPurchaseOrderReceiptItem.aReceiptCost, " +
|
|
" aVendor.aName " +
|
|
"AS aMANUFACTURERNAME, aPart.aName, aPart.aPartNumber " +
|
|
"AS aPARTNUMBER, aPart.aUPC, aPart.aRetail, aPartCategory.aName " +
|
|
"AS aPARTCATEGORYNAME, aPartAssembly.aName " +
|
|
"AS aPARTASSEMBLYNAME, aPurchaseOrder.aPONumber " +
|
|
"FROM aPurchaseOrderReceiptItem LEFT " +
|
|
"OUTER JOIN aPurchaseOrder ON aPurchaseOrderReceiptItem.aPurchaseOrderID " +
|
|
"= aPurchaseOrder.aID " +
|
|
"LEFT OUTER JOIN aPart ON aPurchaseOrderReceiptItem.aPartID " +
|
|
"= aPart.aID LEFT OUTER " +
|
|
"JOIN aPartWarehouse ON aPurchaseOrderReceiptItem.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 WHERE (aPurchaseOrderReceiptItem.aPurchaseOrderReceiptID " +
|
|
"= @ID) " ,dr.GetGuid("aID"));
|
|
|
|
|
|
while(dritems.Read())
|
|
{
|
|
r=ds.Tables["Item"].NewRow();
|
|
r["ItemID"]=dritems.GetGuid("aID");
|
|
r["LT_O_PartWarehouse"]=dritems.GetString("aPartWarehouseName");
|
|
r["LT_O_Part"]=Part.PartDisplayFormatter(
|
|
dritems.GetString("aName"),
|
|
dritems.GetString("aPARTNUMBER"),
|
|
dritems.GetString("aUPC"),
|
|
dritems.GetString("aMANUFACTURERNAME"),
|
|
dritems.GetString("aPARTCATEGORYNAME"),
|
|
dritems.GetString("aPARTASSEMBLYNAME"),
|
|
AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat);
|
|
r["LT_PurchaseOrderReceiptItem_Label_QuantityReceived"]=dritems.GetDecimal("aQuantityReceived");
|
|
r["PurchaseOrderReceiptID"]=dr.GetGuid("aID");
|
|
r["LT_PurchaseOrderReceiptItem_Label_ReceiptCost"]=dritems.GetDecimal("aReceiptCost");
|
|
|
|
//case 765
|
|
r["LT_Part_Label_Retail"] = dritems.GetDecimal("aRetail");
|
|
|
|
r["LT_PurchaseOrder_Label_PONumber"]=dritems.GetInt32("aPONumber").ToString();
|
|
ds.Tables["Item"].Rows.Add(r);
|
|
|
|
#region Serial numbers Level
|
|
|
|
SafeDataReader drsn=DBUtil.GetReaderFromSQLString(
|
|
"SELECT aSerialNumber FROM " +
|
|
"aPartSerial WHERE (aPurchaseOrderReceiptItemID " +
|
|
"= @ID)" ,dritems.GetGuid("aID"));
|
|
|
|
|
|
while(drsn.Read())
|
|
{
|
|
r=ds.Tables["SN"].NewRow();
|
|
r["ParentItemID"]=dritems.GetGuid("aID");
|
|
r["LT_Common_Label_SerialNumber"]=drsn.GetString("aSerialNumber");
|
|
|
|
ds.Tables["SN"].Rows.Add(r);
|
|
}
|
|
drsn.Close();
|
|
#endregion Serial number level fields
|
|
|
|
}
|
|
dritems.Close();
|
|
#endregion item level fields
|
|
|
|
//*******************************************
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if(dr!=null) dr.Close();
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
public Guid ID;
|
|
public string CriteriaXML;
|
|
|
|
public Criteria( string _CriteriaXML, Guid _ID)
|
|
{
|
|
CriteriaXML=_CriteriaXML;
|
|
ID=_ID;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end Bool
|
|
|
|
}//end Boolspace GZTW.AyaNova.BLL |