Exemplo n.º 1
0
        /// <summary>
        /// creates a new invoice
        /// </summary>
        /// <param name="date"></param>
        /// <param name="Line"></param>
        public int CreateInvoice(string date, string cost, List <clsLineItems> lstItems)
        {
            try
            {
                db.ExecuteNonQuery(Query.CreateInvoice(date, cost));


                Int32.TryParse(db.ExecuteScalarSQL(Query.GetInsertedInvoiceId(date, cost)), out int id);
                InsertLineItems(id, lstItems);
                return(id);
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType + "." +
                                    MethodInfo.GetCurrentMethod().Name + "->" + ex.Message);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// delete selected item if it is not on an invoice
 /// </summary>
 /// <param name="code"></param>
 /// <returns>coonfirmation of deletion</returns>
 public void DeleteItems(int code)
 {
     try
     {
         SQL = "SELECT count(*) FROM LineItems as LI " +
               "WHERE LI.ItemCode = " + code + "";
         string Qrows = db.ExecuteScalarSQL(SQL);
         if (Qrows == "0")
         {
             SQL = "DELETE FROM ItemDesc " +
                   "WHERE ItemCode = " + code + "";
             int test = db.ExecuteNonQuery(SQL);
         }
         else
         {
             MessageBox.Show("Item is in an invoice. Can not be deleted");
         }
     }
     catch (Exception ex)
     {
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
     }
 }