/// <summary> /// Deletes the seelcted item from the list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteItem_Click(object sender, RoutedEventArgs e) { //If the user tries to delete an item that is on an invoice, don't allow the user //to do so. //Give the user a warning message that tells them which invoices that item is used on. try { DataSet ds = new DataSet(); ds = queries.GetInvoicesContainingItem(txtbCode.Text); //if (ds.IsInitialized) //Count Seems to work better if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("Cannot delete this item for it is in an invoice."); } else { queries.DeleteItem(txtbCode.Text); listOfItems = queries.GetAllFromItemDesc(); dgListOfItems.ItemsSource = listOfItems; } } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } }
public wndEdit() { try { InitializeComponent(); queries = new clsDBQueries(); item = new clsItem(); listOfItems = queries.GetAllFromItemDesc(); isUpdateItem = false; dgListOfItems.ItemsSource = listOfItems; } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } }