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