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