Beispiel #1
0
 /// <summary>
 /// Deletes the provided Item
 /// </summary>
 /// <param name="SelectedItem">Item To Delete</param>
 public void DeleteItem(object SelectedItem)
 {
     try
     {
         SQL.DeleteItem(((Item)SelectedItem)._Code.ToString());
         _Items.Remove((Item)SelectedItem);
     }
     catch (Exception ex)
     {
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                             MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
     }
 }
        /// <summary>
        /// Method to delete Item from database
        /// </summary>
        /// <param name="sCode">Item Code of Item to be deleted</param>
        /// <param name="invoices">List of invoices to be set if item is on invoice</param>
        /// <returns>Bool; True if on an invoice, false otherwise</returns>
        public bool deleteItem(string sCode, ref List <string> invoices)
        {
            try
            {
                int iRet = 1;

                string sSQL = clsSQL.FindItemsOnInvoices(sCode);

                ds = clsDA.ExecuteSQLStatement(sSQL, ref iRet);

                //If not on invoice
                if (iRet == 0)
                {
                    sSQL = clsSQL.DeleteItem(sCode);
                    clsDA.ExecuteNonQuery(sSQL);

                    return(false);
                }
                else
                {
                    //Pass List of invoices back go window
                    List <string> invoiceList = new List <string>();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        invoiceList.Add(dr[0].ToString());
                    }

                    invoices = invoiceList;

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                                    MethodInfo.GetCurrentMethod().Name + " ->" + ex.Message);
            }
        }