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