private void btnkaydet_Click(object sender, EventArgs e) { if (gridView1.RowCount != 0) { string adi = Convert.ToString(gridView1.GetFocusedRowCellValue("ADINIZ")); } if (txt_adi.Text == "" || txt_soyadi.Text == "" || txt_evtel.Text == "" || txt_ceptel.Text == "" || txt_adres.Text == "") { DevExpress.XtraEditors.XtraMessageBox.Show("Boş Geçtiğiniz Alanlarınız Mevcuttur." + '\n' + "Lütfen Alanlarınızı Doldurun", "DİKKAT", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { using (TestDevexpresOgrenciOtomasyonEntities3 enti = new TestDevexpresOgrenciOtomasyonEntities3()) { TBL_TELEFONREHBERİ rh = new TBL_TELEFONREHBERİ(); rh.ADINIZ = txt_adi.Text; rh.SOYADINIZ = txt_soyadi.Text; rh.CEPTEL = txt_ceptel.Text; rh.EVTEL = txt_evtel.Text; rh.ADRES = txt_adres.Text; rh.RESİM = txtresim.Text; enti.TBL_TELEFONREHBERİ.Add(rh); enti.SaveChanges(); Listele(); temizlik(); } } }
private void btnguncelle_Click(object sender, EventArgs e) { int ID = (int)gridView1.GetFocusedRowCellValue("ID"); string cikis = DevExpress.XtraEditors.XtraMessageBox.Show("" + ID + " numaralı Kaydınızı Güncellemek istediğinize Emin Misiniz? ", "DİKKAT", MessageBoxButtons.YesNo, MessageBoxIcon.Information).ToString(); if (cikis == DialogResult.Yes.ToString()) { using (TestDevexpresOgrenciOtomasyonEntities3 context = new TestDevexpresOgrenciOtomasyonEntities3()) { try { var query1 = (from contact in context.TBL_TELEFONREHBERİ where contact.ID == ID select contact).First(); query1.ADINIZ = txt_adi.Text; query1.SOYADINIZ = txt_soyadi.Text; query1.EVTEL = txt_evtel.Text; query1.CEPTEL = txt_ceptel.Text; query1.ADRES = txt_adres.Text; query1.RESİM = txtresim.Text; context.SaveChanges(); } catch (Exception hataTuru) { } } } else { } Listele(); temizlik(); }
private void btnsil_Click(object sender, EventArgs e) { int ID = (int)gridView1.GetFocusedRowCellValue("ID"); string cikis = DevExpress.XtraEditors.XtraMessageBox.Show("" + ID + " numaralı Kaydınızı Silmek istediğinize Emin Misiniz? ", "DİKKAT", MessageBoxButtons.YesNo, MessageBoxIcon.Error).ToString(); if (cikis == DialogResult.Yes.ToString()) { using (TestDevexpresOgrenciOtomasyonEntities3 sil = new TestDevexpresOgrenciOtomasyonEntities3()) { TBL_TELEFONREHBERİ a = sil.TBL_TELEFONREHBERİ.SingleOrDefault(g => g.ID == ID); sil.TBL_TELEFONREHBERİ.Remove(a); sil.SaveChanges(); Listele(); } } else { } }