public static List <POHistoryobj> GetReceivedItems(int PONumber) { try { SqlCommand cmd = new SqlCommand("SELECT Type,PONumber,ItemNumber,EnteredBy,Quantity,Cost,LocalSKU,SuppliersSKU FROM POHistory Where Type = 'R' AND PONumber =" + PONumber.ToString(), cn); SqlDataReader dr = cmd.ExecuteReader(); List <POHistoryobj> polist = new List <POHistoryobj>(); while (dr.Read()) { POHistoryobj poh = new POHistoryobj(); poh.Type = dr["Type"] == DBNull.Value ? "" : Convert.ToString(dr["Type"]); poh.PONumber = dr["PONumber"] == DBNull.Value ? 0 : Convert.ToInt32(dr["PONumber"]); poh.ItemNumber = dr["ItemNumber"] == DBNull.Value ? 0 : Convert.ToInt32(dr["ItemNumber"]); poh.EnteredBy = dr["EnteredBy"] == DBNull.Value ? "" : Convert.ToString(dr["EnteredBy"]); poh.Quantity = dr["Quantity"] == DBNull.Value ? 0 : Convert.ToInt32(dr["Quantity"]); poh.Cost = dr["Cost"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["Cost"]); poh.LocalSKU = dr["LocalSKU"] == DBNull.Value ? "" : Convert.ToString(dr["LocalSKU"]); poh.SuppliersSKU = dr["SuppliersSKU"] == DBNull.Value ? "" : Convert.ToString(dr["SuppliersSKU"]); polist.Add(poh); } dr.Close(); dr.Dispose(); dr = null; foreach (POHistoryobj item in polist) { item.ItemName = Inventory.GetItemName(item.LocalSKU); } return(polist); } catch (Exception) { return(new List <POHistoryobj>()); } }
public static List <PurchaseOrderDetailsObj> GetByPONumber(int PONumber) { List <PurchaseOrderDetailsObj> purchaseorderdetailslist = new List <PurchaseOrderDetailsObj>(); SqlCommand cmd = new SqlCommand("SELECT * FROM PurchaseOrderDetails WHERE PONumber = " + PONumber.ToString(), cn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { PurchaseOrderDetailsObj purchaseorderdetails = new PurchaseOrderDetailsObj(); purchaseorderdetails.PONumber = int.Parse(dr["PONumber"].ToString()); purchaseorderdetails.ItemNumber = int.Parse(dr["ItemNumber"].ToString()); purchaseorderdetails.Ordered = int.Parse(dr["Ordered"].ToString()); purchaseorderdetails.ExpectedCost = decimal.Parse(dr["ExpectedCost"].ToString()); purchaseorderdetails.OrderNumber = int.Parse(dr["OrderNumber"].ToString()); purchaseorderdetails.Lot = dr["Lot"] == DBNull.Value ? "" : dr["Lot"].ToString(); purchaseorderdetails.LocalSKU = dr["LocalSKU"] == DBNull.Value ? "" : dr["LocalSKU"].ToString(); purchaseorderdetails.SuppliersSKU = dr["SuppliersSKU"] == DBNull.Value ? "" : dr["SuppliersSKU"].ToString(); purchaseorderdetailslist.Add(purchaseorderdetails); } dr.Close(); dr.Dispose(); dr = null; foreach (PurchaseOrderDetailsObj item in purchaseorderdetailslist) { item.QuantityRemaining = item.Ordered - POHistory.GetReceivedQuantity(item.PONumber, item.LocalSKU); item.ItemName = Inventory.GetItemName(item.LocalSKU); } return(purchaseorderdetailslist); }