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