示例#1
0
 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);
     }
 }
示例#2
0
 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);
     }
 }
示例#3
0
 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);
     }
 }