Ejemplo n.º 1
0
 /// <summary>
 /// Deletes an item from the database.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDeleteItem_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         LineItem = itemsLogic.GetLineItems(itemsSQL.GetLineItems());
         //Verify none of the item codes are currently being used by an invoice
         foreach (var element in LineItem)
         {
             if (element.ItemCode == txtItemCode.Text)
             {
                 MessageBox.Show("You cannot delete this item, it is invoice #" + element.InvoiceNum.ToString(), "Cannot delete item", MessageBoxButton.OK, MessageBoxImage.Warning);
                 return;
             }
         }
         //Execute the delete statement if none of the elements are in an invoice
         DA.ExecuteNonQuery(itemsSQL.DeleteItem(txtItemCode.Text));
         //Empty the current items out of the text boxes
         txtItemCode.Text = "";
         txtItemDesc.Text = "";
         txtItemCost.Text = "";
         //Updates the Data grid
         FillBox();
     }
     catch (System.Exception ex)
     {
         HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                     MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Ejemplo n.º 2
0
        public wndItems()
        {
            InitializeComponent();
            try
            {
                //Initialize objects to access respective classes
                itemsLogic = new clsItemsLogic();
                itemsSQL   = new clsItemsSQL();
                DA         = new clsDataAccess();
                LineItem   = itemsLogic.GetLineItems(itemsSQL.GetLineItems());

                FillBox();
            }
            catch (Exception ex)
            {
                //Just throw the exception
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                                    MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }