private void btnDelete_Click(object sender, EventArgs e) { try { County county = ctx.Counties.Find(clickedID); ctx.Counties.Remove(county); ctx.SaveChanges(); txtCounty.Text = string.Empty; List(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { County county = ctx.Counties.Find(clickedID); county.CountyName = txtCounty.Text; county.CityID = (int)cmbCity.SelectedValue; ctx.SaveChanges(); List(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }