private void button1_Click(object sender, EventArgs e) { int success = 0; if (txtProductName.Text == " ") { MessageBox.Show("A Name must be provided into the Product Name field"); } else { name = txtProductName.Text; } success = jamesProductsDB.AddProducts(txtProductName.Text); if (success == 1) { // ++ Dima Bognen // Added to update Product Form after new product was added FormHandler.upDateProductForm(); // -- Dima Bognen -- End of change MessageBox.Show("Data inserted Correctly"); this.Close(); } else { MessageBox.Show("Data was not inserted"); } this.Close(); }
private void btnUpdate_Click(object sender, EventArgs e) { Products newProducts = new Products(); // passing the id value from the old product list to the new product list. (prod id does not change) newProducts.ProductId = products.ProductId; newProducts.ProdName = txtProdName.Text; try { // update an old customer (UpdateProducts returns a bool value) if (!jamesProductsDB.UpdateProducts(products, newProducts)) { MessageBox.Show("Database Error, Another user may have " + "tried updating that customer, try again."); //this.DialogResult = DialogResult.Retry; } else { products = newProducts; // ++ Dima Bognen // Added to update Product Form after new product was added FormHandler.upDateProductForm(); // -- Dima Bognen -- End of change //this.DialogResult = DialogResult.OK; MessageBox.Show("Update Successful"); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }