Esempio n. 1
0
 private void dgvCounty_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         choosenCountyID = Convert.ToInt32(dgvCounty.CurrentRow.Cells[0].Value);
         County c = db.Counties.Where(x => x.CountyID == choosenCountyID).FirstOrDefault();
         txtCountyName.Text        = c.CountyName;
         cmbCityName.SelectedValue = c.CityID;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 2
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         County c = db.Counties.Where(x => x.CountyID == choosenCountyID).Select(x => x).FirstOrDefault();
         c.CountyName = txtCountyName.Text;
         c.CityID     = (int)cmbCityName.SelectedValue;
         db.SaveChanges();
         FillCounty();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 3
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         County c = new County();
         c.CountyName = txtCountyName.Text;
         c.CityID     = (int)cmbCityName.SelectedValue;
         db.Counties.Add(c);
         db.SaveChanges();
         FillCounty();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtCountyName.Text))
     {
         MessageBox.Show("County Name is not null !!");
     }
     else
     {
         County county = new County();
         county.CountyName = txtCountyName.Text;
         county.CityID     = Convert.ToInt32(comboBoxCities.SelectedValue);
         db.Counties.Add(county);
         db.SaveChanges();
         FillCounty();
     }
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridView1.SelectedRows.Count == 1)
         {
             County county = db.Counties.Where(x => x.CountyID == CountyID).FirstOrDefault();
             db.Counties.Remove(county);
             db.SaveChanges();
         }
         else
         {
             MessageBox.Show("Lütfen Tekli Seçim Yapınız.");
         }
         Fill();
     }
     catch
     {
     }
 }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                County county = db.Counties.Where(x => x.CountyID == CountyID).FirstOrDefault();

                county.Description = txtCountyName.Text;

                county.CityID = (int)cmbCityName.SelectedValue;

                db.SaveChanges();

                txtCountyName.Text = "";

                Fill();
            }
            catch
            {
            }
        }
Esempio n. 7
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvCounty.SelectedRows.Count > 1)
         {
             MessageBox.Show("For multiple delete please choose 'Delete Selected Items'");
         }
         else
         {
             County c = db.Counties.Where(x => x.CountyID == choosenCountyID).Select(x => x).FirstOrDefault();
             db.Counties.Remove(c);
             db.SaveChanges();
             FillCounty();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                County county = new County();

                county.Description = txtCountyName.Text;

                county.CityID = (int)cmbCityName.SelectedValue;

                db.Counties.Add(county);

                db.SaveChanges();

                txtCountyName.Text = "";

                Fill();
            }
            catch
            {
            }
        }
 private void btnMultiDelete_Click(object sender, EventArgs e)
 {
     if (dataGridViewCounties.SelectedRows.Count >= 2)
     {
         foreach (DataGridViewRow item in dataGridViewCounties.SelectedRows)
         {
             selectedCounty = db.Counties.Find(item.Cells["CountyID"].Value);
             db.Counties.Remove(selectedCounty);
         }
         db.SaveChanges();
         MessageBox.Show("Multi Delete is Successful");
         FillCounty();
     }
     else if (dataGridViewCounties.SelectedRows.Count == 1)
     {
         MessageBox.Show("Please go to 'Delete'");
     }
     else
     {
         MessageBox.Show("Plase make a selection !");
     }
 }