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