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