/// <summary>
 /// Updates an invoice in the database to have all the given products attached to it.
 /// </summary>
 /// <param name="invoice">The invoice ID number</param>
 /// <param name="invoiceProducts">The products to attach to the invoice</param>
 public static void updateInvoice(Invoice invoice, List <Product> invoiceProducts)
 {
     try
     {
         double invoiceTotal = 0;
         foreach (Product product in invoiceProducts)
         {
             if (product.needDeleted)
             {
                 dataAccess.ExecuteNonQuery(SQLStrings.removeLineItem(invoice.ID, product.ProductCode));
                 continue;
             }
             invoiceTotal += product.ProductCost;
             if (!product.inDB)
             {
                 dataAccess.ExecuteNonQuery(SQLStrings.insertLineItem(invoice.ID, product.ProductCode));
             }
         }
         dataAccess.ExecuteNonQuery(SQLStrings.updateInvoice(invoice.ID, invoice.Date.ToShortDateString(), invoiceTotal));
     }
     catch (Exception ex)
     {
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + ":" +
                             MethodInfo.GetCurrentMethod().Name + "->" + ex.Message);
     }
 }
        /// <summary>
        /// Adds an ivoice to the database with the given products attached to it.
        /// </summary>
        /// <param name="date">The invoice date</param>
        /// <param name="prodList">The products attached to the invoice</param>
        /// <returns></returns>
        public static int addInvoice(DateTime date, List <Product> prodList)
        {
            double invoiceTotal = 0;

            foreach (Product p in prodList)
            {
                if (!p.needDeleted)
                {
                    invoiceTotal += p.ProductCost;
                }
            }
            dataAccess.ExecuteNonQuery(SQLStrings.insertInvoice(date.ToShortDateString(), invoiceTotal));
            int newId = int.Parse(dataAccess.ExecuteScalarSQL(SQLStrings.getNewInvoice()));

            foreach (Product p in prodList)
            {
                if (!p.needDeleted)
                {
                    dataAccess.ExecuteNonQuery(SQLStrings.insertLineItem(newId, p.ProductCode));
                }
            }
            return(newId);
        }