} //end search click /// <summary> /// opens edit inventory window. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnInventory_Click(object sender, RoutedEventArgs e) { try { // Creates an EditWindow object edtWindow = new EditWindow(); // Shows the edit window edtWindow.ShowDialog(); // Closes the main window edtWindow.Close(); //inventoryDictionary = new Dictionary<string, string>(); //populateInventory(); } catch (Exception) { MessageBox.Show(MethodInfo.GetCurrentMethod().DeclaringType.Name); } //end catch } //end inventory click
/// <summary> /// Delete an item from the inventory. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeleteItem_Click(object sender, RoutedEventArgs e) { try { // Prevent user from deleting an item that is in the current invoice. // Display a warning message to the user. // Delete item from database using SQL. lblErrorCantDeleteItem.Visibility = Visibility.Hidden; sSQL = mydb.CheckIfItemIsInAnInvoice(itemCode); ds = db.ExecuteSQLStatement(sSQL, ref iRetVal); if(iRetVal == 0) { ///check to see what the message box is showing if (MessageBox.Show("Are you sure you want to delete item: " + txtItemDesc.Text + "?", "Delete item?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { //do no stuff } else { sSQL = mydb.DeleteInventoryItem(itemCode); db.ExecuteNonQuery(sSQL); EditWindow ew = new EditWindow(); ew.Show(); this.Close(); } } else { lblErrorCantDeleteItem.Visibility = Visibility.Visible; } } catch (Exception) { MessageBox.Show(MethodInfo.GetCurrentMethod().DeclaringType.Name); } }