protected PurchaseInvoices GetByID(int _ID) { Gate.Command.CommandText = "select * from PurchaseInvoices"; Gate.Command.CommandText += " Where ID = @ID "; Gate.Command.Parameters.Clear(); Gate.Command.Parameters.AddWithValue("@ID", _ID); System.Data.SqlClient.SqlDataReader Reader = Gate.Execute(); PurchaseInvoices NewObj = new PurchaseInvoices(); if (Reader != null && Reader.Read()) { if (Reader["ID"] != null) { NewObj.ID = int.Parse(Reader["ID"].ToString()); } if (Reader["CustomerID"] != null) { NewObj.CustomerID = int.Parse(Reader["CustomerID"].ToString()); } if (Reader["Date"] != null) { NewObj.Date = (DateTime)Reader["Date"]; } if (Reader["AmountValue"] != null) { NewObj.AmountValue = float.Parse(Reader["AmountValue"].ToString()); } if (Reader["Discount"] != null) { NewObj.Discount = float.Parse(Reader["Discount"].ToString()); } if (Reader["Tax"] != null) { NewObj.Tax = float.Parse(Reader["Tax"].ToString()); } if (Reader["Total"] != null) { NewObj.Total = float.Parse(Reader["Total"].ToString()); } if (Reader["PaidType"] != null) { NewObj.PaidType = Reader["PaidType"].ToString(); } if (Reader["Notes"] != null) { NewObj.Notes = Reader["Notes"].ToString(); } } ; Gate.Close(); return(NewObj); }
protected List <PurchaseInvoices> GetAll() { Gate.Command.CommandText = "select * from PurchaseInvoices"; Gate.Command.Parameters.Clear(); System.Data.SqlClient.SqlDataReader Reader = Gate.Execute(); List <PurchaseInvoices> List = new List <PurchaseInvoices>(); while (Reader != null && Reader.Read()) { PurchaseInvoices NewObj = new PurchaseInvoices(); if (Reader["ID"] != null) { NewObj.ID = int.Parse(Reader["ID"].ToString()); } if (Reader["CustomerID"] != null) { NewObj.CustomerID = int.Parse(Reader["CustomerID"].ToString()); } if (Reader["Date"] != null) { NewObj.Date = (DateTime)Reader["Date"]; } if (Reader["AmountValue"] != null) { NewObj.AmountValue = float.Parse(Reader["AmountValue"].ToString()); } if (Reader["Discount"] != null) { NewObj.Discount = float.Parse(Reader["Discount"].ToString()); } if (Reader["Tax"] != null) { NewObj.Tax = float.Parse(Reader["Tax"].ToString()); } if (Reader["Total"] != null) { NewObj.Total = float.Parse(Reader["Total"].ToString()); } if (Reader["PaidType"] != null) { NewObj.PaidType = Reader["PaidType"].ToString(); } if (Reader["Notes"] != null) { NewObj.Notes = Reader["Notes"].ToString(); } List.Add(NewObj); } ; Gate.Close(); return(List); }