Ejemplo n.º 1
0
        /// <summary>
        /// Updates an existing invoice's stuff on the Invoice table
        /// </summary>
        /// <param name="i"></param>
        public void SaveExisting(InvoiceCls i)
        {
            //data.ExecuteNonQuery("DELETE * FROM Invoices WHERE InvoiceNumber =" + invNum);
            data.ExecuteNonQuery("UPDATE Invoices SET InvoiceDate = '" + i.date + "', TotalAmount = " +
                                 i.totalCost + " WHERE InvoiceNumber = " + i.invNum);

            data.ExecuteNonQuery("DELETE * FROM LineItems WHERE InvoiceNumber = " + i.invNum);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new invoice in Invoices table.
        /// </summary>
        /// <param name="i"></param>
        public void CreateNew(ref int invNum, InvoiceCls i)
        {
            //else, insert the Invoice info and then find the highest number
            data.ExecuteNonQuery("INSERT INTO Invoices(InvoiceDate, TotalAmount) VALUES('" +
                                 i.date + "', " + i.totalCost + ")");

            string highest = data.ExecuteScalarSQL("SELECT TOP 1 InvoiceNumber FROM" +
                                                   " Invoices ORDER BY InvoiceNumber DESC");

            //And set invNum to it
            highest = Int32.Parse(highest).ToString();
            //Console.WriteLine(highest + " is highest");

            i.invNum = Int32.Parse(highest);
        }