Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 public InvoiceItem()
 {
     clientSession = new ClientSession();
     invoice = new Invoice();
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 private static void AddParameters(Invoice invoice, SqlCommand comm)
 {
     comm.Parameters.AddWithValue("CompanyID", invoice.CompanyID);
     comm.Parameters.AddWithValue("Date", invoice.InvoiceDate);
 }
Exemplo n.º 5
0
 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;
 }