private void btnAccept_Click(object sender, EventArgs e) { if (IsValidData()) { if (vendor == null) { try { newVendor.VendorID = VendorDB.AddVendor(newVendor); vendor = newVendor; this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } else { try { if (!VendorDB.UpdateVendor(vendor, newVendor)) { MessageBox.Show("Another user has updated or " + "deleted that vendor.", "Database Error"); this.DialogResult = DialogResult.Retry; } else { vendor = newVendor; this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } }