private async void btnEditCustomers_Click(object sender, EventArgs e) { CustomersTable obj = customersTableBindingSource.Current as CustomersTable; if (obj != null) { using (frmAddEditCustomer frm = new frmAddEditCustomer(obj)) { if (frm.ShowDialog() == DialogResult.OK) { try { customersTableBindingSource.EndEdit(); await db.SaveChangesAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
public frmAddEditCustomer(CustomersTable obj) { InitializeComponent(); bindingSourceCustomer.DataSource = obj; }