private void btnAccept_Click_1(object sender, EventArgs e) { if (IsValidData()) { if (addSuppliers) // processing Add { psp = new Suppliers(); PutSuppliers_Data(psp); try { SuppliersDB.AddSuppliers(psp); MessageBox.Show("New Item with Supplier Id of " + psp.SuppliersId + " and SupName " + psp.SupName + " was added"); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } else // processing Modify { Suppliers newSuppliers = new Suppliers(); newSuppliers.SupName = txtSupName.Text; PutSuppliers_Data(newSuppliers); try { if (!SuppliersDB.UpdateSuppliers(modifySuppliers, newSuppliers)) { MessageBox.Show("Another user has updated or " + "deleted that Supplier.", "Database Error"); this.DialogResult = DialogResult.Retry; } else { psp = newSuppliers; this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } }