public LotAttribute GetLotAttributeByPartNum(string Company, string PartNum) { LotAttribute objLotAttribute = null; //PO Header info string cmdQry = string.Format("select AttBatch,AttMfgBatch,AttMfgLot,AttHeat " + ",AttFirmware,AttBeforeDt,AttMfgDt,AttCureDt,AttExpDt " + "from erp.Part " + "Where Company=\'{0}\' and PartNum=\'{1}\' and TrackLots=1 " , Company, PartNum); using (SqlConnection connection = new SqlConnection(EpicorConStr)) { connection.Open(); SqlCommand command = new SqlCommand(cmdQry, connection); using (SqlDataReader reader = command.ExecuteReader()) { objLotAttribute = new LotAttribute(); while (reader.Read()) { objLotAttribute.AttBatch = reader["AttBatch"].ToString(); objLotAttribute.AttMfgBatch = reader["AttMfgBatch"].ToString(); objLotAttribute.AttMfgLot = reader["AttMfgLot"].ToString(); objLotAttribute.AttHeat = reader["AttHeat"].ToString(); objLotAttribute.AttFirmware = reader["AttFirmware"].ToString(); objLotAttribute.AttBeforeDt = reader["AttBeforeDt"].ToString(); objLotAttribute.AttMfgDt = reader["AttMfgDt"].ToString(); objLotAttribute.AttCureDt = reader["AttCureDt"].ToString(); objLotAttribute.AttExpDt = reader["AttExpDt"].ToString(); } } } return(objLotAttribute); }
public List <PODetail> GetPODtlByPONum(int PONum, string Company) { List <PODetail> objPODtls = null; //PO Header info string cmdQry = string.Format("Select a.Company,a.PONum,a.POLine,a.PartNum,a.LineDesc,a.XOrderQty,a.IUM,a.OrderQty,a.PUM, " + "a.HHRcvdQty_c as ReceivedQty,(a.OrderQty-a.HHRcvdQty_c) as Qty " + ",a.HHIsRcvFull_c,a.HHRcvStatus_c,b.TrackLots,c.PrimWhse,d.BinNum " + "from PODetail a inner join erp.Part b " + "on a.Company=b.Company and a.PartNum=b.PartNum " + "left join erp.PartPlant c on a.Company=c.Company and a.PartNum=c.PartNum " + "left join erp.PartBinInfo d on c.Company=d.Company and c.PartNum=d.PartNum and c.PrimWhse=d.WarehouseCode " + "Where a.Company=\'{0}\' and a.PONum={1} and a.HHIsRcvFull_c=0 " , Company, PONum); using (SqlConnection connection = new SqlConnection(EpicorConStr)) { connection.Open(); SqlCommand command = new SqlCommand(cmdQry, connection); using (SqlDataReader reader = command.ExecuteReader()) { objPODtls = new List <PODetail>(); while (reader.Read()) { PODetail objPODtl = new PODetail(); objPODtl.Company = reader["Company"].ToString(); objPODtl.PONum = Convert.ToInt32(reader["PONum"]); objPODtl.POLine = Convert.ToInt32(reader["POLine"]); objPODtl.PartNum = reader["PartNum"].ToString(); objPODtl.PartDesc = reader["LineDesc"].ToString(); objPODtl.TrackLot = Convert.ToBoolean(reader["TrackLots"]); objPODtl.XOrdQty = Convert.ToDecimal(reader["XOrderQty"]); objPODtl.IUM = reader["IUM"].ToString(); objPODtl.OrdQty = Convert.ToDecimal(reader["OrderQty"]); objPODtl.PUM = reader["PUM"].ToString(); objPODtl.PrevRcvQty = Convert.ToDecimal(reader["ReceivedQty"]); objPODtl.Qty = Convert.ToDecimal(reader["Qty"]); objPODtl.IsReceivedFull = Convert.ToBoolean(reader["HHIsRcvFull_c"]); objPODtl.ReceiveStatus = reader["HHRcvStatus_c"].ToString(); objPODtl.UomCode = reader["PUM"].ToString(); objPODtl.WarehouseCode = reader["PrimWhse"] == null?"": reader["PrimWhse"].ToString(); objPODtl.BinNum = reader["BinNum"] == null ? "" : reader["BinNum"].ToString(); objPODtls.Add(objPODtl); } } } if (objPODtls != null && objPODtls.Any()) { foreach (var objRow in objPODtls) { LotAttribute objLotAttribute = GetLotAttributeByPartNum(objRow.Company, objRow.PartNum); if (objLotAttribute != null) { objLotAttribute.Company = objRow.Company; objLotAttribute.PONum = objRow.PONum; objLotAttribute.POLine = objRow.POLine; objLotAttribute.PartNum = objRow.PartNum; objRow.LotAttribute = objLotAttribute; } } } return(objPODtls); }