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