public static int AddInvoice(Invoice invoice) { int invoiceID = -1; // Setup Connection using (DatabaseConnection db = new DatabaseConnection("dbo.AddInvoice")) { // Set Parameters AddParameters(invoice, db.comm); // Open Connection db.conn.Open(); // Execute Command and Read Response invoiceID = Convert.ToInt32(db.comm.ExecuteScalar()); } return invoiceID; }
public InvoiceItem() { clientSession = new ClientSession(); invoice = new Invoice(); }
public static int UpdateInvoice(Invoice invoice, Invoice oldInvoice) { int rowsAffected = 0; // Setup Connection using (DatabaseConnection db = new DatabaseConnection("dbo.UpdateInvoice")) { // Set Parameters AddParameters(invoice, db.comm); AddOldParameters(oldInvoice, db.comm); // Open Connection db.conn.Open(); // Execute Command and Read Response rowsAffected = db.comm.ExecuteNonQuery(); } return rowsAffected; }
private static void AddParameters(Invoice invoice, SqlCommand comm) { comm.Parameters.AddWithValue("CompanyID", invoice.CompanyID); comm.Parameters.AddWithValue("Date", invoice.InvoiceDate); }
public static Invoice ReadInvoice(SqlDataReader reader) { Invoice invoice = new Invoice(); invoice.InvoiceID = (int)reader["InvoiceID"]; invoice.InvoiceDate = (DateTime)reader["InvoiceDate"]; invoice.company = Company.ReadCompany(reader); return invoice; }