/// <summary> /// Calls function to insert contents of text boxes into database as Item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, RoutedEventArgs e) { /*Take contents of txtCode, txtDescription, and txtCost and insert it into the * ItemDesc table. * * Error checking to make sure all boxes have input, all inputs are valid, and that * contents of txtCode does not already exist as a key in ItemDesc */ try { if (txtCode.Text == "" || txtDescription.Text == "" || txtCost.Text == "") { MessageBox.Show("Please enter text in all boxes."); } else { bool valid = clsIL.addItem(txtCode.Text, txtDescription.Text, txtCost.Text); if (!valid) { MessageBox.Show("Please enter unique item code and valid cost"); } else { dgItems.ItemsSource = null; dgItems.ItemsSource = clsIL.getItems(); txtCode.Text = ""; txtDescription.Text = ""; txtCost.Text = ""; } } } catch (Exception ex) { HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// Instantiates Item window /// </summary> /// <param name="main">Main window object</param> public wndItem(wndMain main) { try { InitializeComponent(); mainWindow = main; clsIL = new clsItemsLogic(); dgItems.ItemsSource = clsIL.getItems(); } catch (Exception ex) { HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }