private void Insert_Click(object sender, EventArgs e) { using (AddressIEF frm = new AddressIEF(null, db)) { if (frm.ShowDialog() == DialogResult.OK) { addressBindingSource.DataSource = db.Address.ToList(); } } }
private void Edit_Click(object sender, EventArgs e) { if (addressBindingSource.Current == null) { return; } using (AddressIEF frm = new AddressIEF(addressBindingSource.Current as Address, db)) { if (frm.ShowDialog() == DialogResult.OK) { addressBindingSource.DataSource = db.Address.ToList(); } else { db = new my_db_for_db_2Entities(); addressBindingSource.DataSource = db.Address.ToList(); } } }