コード例 #1
0
 private void btnKaydet_Click(object sender, EventArgs e)
 {
     model.kullaniciad    = textAd.Text.Trim();
     model.kullanicisoyad = textSoyad.Text.Trim();
     model.kullanicimail  = textMail.Text.Trim();
     model.kullanicisifre = textParola.Text.Trim();
     using (dbAraf db = new dbAraf())
     {
         if (textAd.Text == "" || textAd.Text == null || textAd.Text == " ")
         {
             MessageBox.Show("Lütfen bilgileri eksiksiz tamamlayınız.", "Bilgilendirme Penceresi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (textSoyad.Text == "" || textSoyad.Text == null || textSoyad.Text == " ")
         {
             MessageBox.Show("Lütfen bilgileri eksiksiz tamamlayınız.", "Bilgilendirme Penceresi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (textMail.Text == "" || textMail.Text == null || textMail.Text == " ")
         {
             MessageBox.Show("Lütfen bilgileri eksiksiz tamamlayınız.", "Bilgilendirme Penceresi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (textParola.Text == "" || textParola.Text == null || textParola.Text == " ")
         {
             MessageBox.Show("Lütfen bilgileri eksiksiz tamamlayınız.", "Bilgilendirme Penceresi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (model.kullaniciID == 0) //ekleme
         {
             db.Kullanicis.Add(model);
         }
         else // güncelleme
         {
             db.Entry(model).State = System.Data.Entity.EntityState.Modified;
         }
         db.SaveChanges();
         MessageBox.Show("Kayıt işlemi gerçekleşti.", "Bilgilendirme Penceresi", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Form1 frm = new Form1();
         frm.Show();
         this.Hide();
         return;
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: izzetoz/DesktopApplication
 private void btnSil_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bu kaydı silmek istediğinize emin misiniz?", "Bilgilendirme Penceresi", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
     {
         using (dbAraf db = new dbAraf())
         {
             var entry = db.Entry(model);
             if (entry.State == System.Data.Entity.EntityState.Detached)
             {
                 db.Kullanicis.Attach(model);
             }
             db.Kullanicis.Remove(model);
             db.SaveChanges();
             PopulateDataGridView();
             Clear();
             MessageBox.Show("İşlemi gerçekleşti.", "Bilgilendirme Penceresi", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }