private void button9_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(textBox4.Text + " T.C. Numaralı hastayı silmek istediğinize emin misiniz?", "Silmek İstiyor Musunuz?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         YönetimDb db = new YönetimDb();
         foreach (var hasta in db.Hastalar)
         {
             if (hasta.TCNo == Convert.ToInt64(textBox4.Text))
             {
                 db.Hastalar.Remove(hasta);
             }
         }
         db.SaveChanges();
         MessageBox.Show("Silme işlemi başarıyla tamamlandı", "Silme Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
         textBox11.Text   = "";
         textBox12.Text   = "";
         textBox13.Text   = "";
         textBox14.Text   = "";
         textBox15.Text   = "";
         textBox16.Text   = "";
         textBox17.Text   = "";
         textBox18.Text   = "";
         textBox19.Text   = "";
         textBox20.Text   = "";
         textBox21.Text   = "";
         textBox22.Text   = "";
         button10.Enabled = false;
         button9.Enabled  = false;
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            string kullanıcıadı = Properties.Settings.Default.kullanıcıAdı;
            string eskik        = Properties.Settings.Default.şifre;
            string eski         = textBox1.Text;
            string yeni         = textBox2.Text;
            string yenit        = textBox3.Text;

            if (eski == "" || yeni == "" || yenit == "")
            {
                MessageBox.Show("Alanlardan birisi bile boş bırakılamaz", "Boş Alanlar", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (yeni != yenit)
                {
                    MessageBox.Show("Şifre ve tekrarı uyuşmuyor", "Yanlış Şifre Tekrarı", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (eskik != eski)
                    {
                        MessageBox.Show("Eski şifrenizi yanlış girdiniz", "Yanlış Şifre", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        YönetimDb db = new YönetimDb();
                        foreach (var kullanıcı in db.Kullanıcılar)
                        {
                            if (kullanıcıadı == kullanıcı.KullanıcıAdı)
                            {
                                kullanıcı.Şifre = yeni;
                                break;
                            }
                        }
                        db.SaveChanges();
                        MessageBox.Show("Şifreniz başarıyla değiştirildi", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
            }
        }
 private void button4_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(Properties.Settings.Default.kullanıcıAdı + " kullanıcı adındaki hesabınızı silmek istediğinize emin misiniz?", "Emin Misiniz?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         YönetimDb db = new YönetimDb();
         foreach (var kullanıcı in db.Kullanıcılar)
         {
             if (kullanıcı.KullanıcıAdı == Properties.Settings.Default.kullanıcıAdı)
             {
                 db.Kullanıcılar.Remove(kullanıcı);
                 Properties.Settings.Default.kullanıcıAdı = null;
                 Properties.Settings.Default.şifre        = null;
                 Properties.Settings.Default.beniHatırla  = false;
                 Properties.Settings.Default.Save();
                 break;
             }
         }
         db.SaveChanges();
         this.Close();
     }
 }
 private void button6_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "")
     {
         MessageBox.Show("Ad boş bırakılamaz", "Ad Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         if (textBox2.Text == "")
         {
             MessageBox.Show("Soyad boş bırakılamaz", "Soyad Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             if (comboBox1.Text == "")
             {
                 MessageBox.Show("Cinsiyet boş bırakılamaz", "Cinsiyet Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 if (textBox3.Text == "")
                 {
                     MessageBox.Show("T.C. Numarası boş bırakılamaz", "T.C. Numara Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     if (comboBox8.Text == "" || comboBox9.Text == "")
                     {
                         MessageBox.Show("Randevu Saati boş bırakılamaz", "Randevu Saati Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
                     else
                     {
                         if (comboBox10.Text == "")
                         {
                             MessageBox.Show("Bölüm boş bırakılamaz", "Bölüm Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         }
                         else
                         {
                             if (comboBox11.Text == "")
                             {
                                 MessageBox.Show("Doktor boş bırakılamaz", "Doktor Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             }
                             else
                             {
                                 if (Hasta_Kayıtlımı(Convert.ToInt64(textBox3.Text)) == true)
                                 {
                                     MessageBox.Show("Hasta zaten kayıtlı", "Kayıtlı Hasta", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                 }
                                 else
                                 {
                                     if (Randevu_Kontrol() == true)
                                     {
                                         MessageBox.Show("Seçtiğiniz tarih ve bölüm için randevu alınmış", "Randevu Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                     }
                                     else
                                     {
                                         bool hatalı = false;
                                         if (dateTimePicker2.Value.Date == DateTime.Now.Date)
                                         {
                                             if (Convert.ToInt32(comboBox8.SelectedItem) <= DateTime.Now.Hour)
                                             {
                                                 if (Convert.ToInt32(comboBox9.SelectedItem) <= DateTime.Now.Minute)
                                                 {
                                                     MessageBox.Show("Geçmişten randevu alamazsınız", "Randevu Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                     hatalı = true;
                                                 }
                                             }
                                         }
                                         if (hatalı == false)
                                         {
                                             // KAYIT KISMI
                                             YönetimDb db    = new YönetimDb();
                                             Hastalar  hasta = new Hastalar();
                                             hasta.Ad            = textBox1.Text;
                                             hasta.Soyad         = textBox2.Text;
                                             hasta.Cinsiyet      = comboBox1.Text;
                                             hasta.TCNo          = Convert.ToInt64(textBox3.Text);
                                             hasta.DoğumTarihi   = dateTimePicker1.Value;
                                             hasta.RandevuTarihi = dateTimePicker2.Value;
                                             hasta.RandevuSaati  = comboBox8.Text + ":" + comboBox9.Text;
                                             hasta.Bölüm         = comboBox10.Text;
                                             hasta.Doktor        = comboBox11.Text;
                                             hasta.Ücret         = ücret;
                                             db.Hastalar.Add(hasta);
                                             db.SaveChanges();
                                             // MAİL KISMI
                                             if (checkBox1.Checked == true)
                                             {
                                                 MailMessage mail = new MailMessage();
                                                 mail.From = new MailAddress(Properties.Settings.Default.gönderenMail);
                                                 mail.To.Add(Properties.Settings.Default.gönderilenMail);
                                                 mail.Subject = "Hastane Otomasyonu Mert Balasar";
                                                 mail.Body    = textBox3.Text + " T.C. Numaralı şahıs " + comboBox10.Text + " bölümünden " +
                                                                dateTimePicker2.Value.ToString().Substring(0, 10) + " " + comboBox8.Text + ":" + comboBox9.Text +
                                                                " tarihinde randevu almıştır.";
                                                 SmtpClient istemci = new SmtpClient();
                                                 istemci.Credentials = new System.Net.NetworkCredential(Properties.Settings.Default.gönderenMail, Properties.Settings.Default.gönderenŞifre);
                                                 istemci.Port        = 587;
                                                 istemci.Host        = "smtp.gmail.com";
                                                 istemci.EnableSsl   = true;
                                                 try
                                                 {
                                                     istemci.SendAsync(mail, (object)mail);
                                                 }
                                                 catch
                                                 {
                                                     MessageBox.Show("Mail gönderme başarısız", "Mail Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                 }
                                             }
                                             MessageBox.Show("Randevu Başarıyla Alındı", "Randevu Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Kullanıcı adı boş bırakılamaz", "Kullanıcı Adı Boş", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("Şifre boş bırakılamaz", "Şifre Boş", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (textBox3.Text == "")
                    {
                        MessageBox.Show("Şifre tekrar alanı boş bırakılamaz", "Şifre Tekrarı Boş", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        if (textBox4.Text == "")
                        {
                            MessageBox.Show("Onay kodu boş bırakılamaz", "Onay Kodu Boş", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            if (textBox2.Text != textBox3.Text)
                            {
                                MessageBox.Show("Şifre tekrarı eşleşmedi", "Şifreler Eşleşmiyor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                if (Onay_Kodu_Kontrol(textBox4.Text) == false)
                                {
                                    MessageBox.Show("Onay kodunuz yanlış", "Onay Kodu Hatalı", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                else
                                {
                                    // KULLANICI ADININ VAR OLUP OLMADIĞINI KONTROL ETTİR
                                    YönetimDb db    = new YönetimDb();
                                    bool      varmı = false;
                                    foreach (var eleman in db.Kullanıcılar)
                                    {
                                        if (eleman.KullanıcıAdı == textBox1.Text)
                                        {
                                            MessageBox.Show("Kullanıcı adı kullanımda", "Kullanıcı Adı Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            varmı = true;
                                            break;
                                        }
                                    }
                                    if (varmı == false)
                                    {
                                        Kullanıcılar kullanıcı = new Kullanıcılar();
                                        kullanıcı.KullanıcıAdı = textBox1.Text;
                                        kullanıcı.Şifre        = textBox2.Text;
                                        db.Kullanıcılar.Add(kullanıcı);
                                        db.SaveChanges();
                                        MessageBox.Show("Kayıt başarıyla tamamlandı", "Kayıt Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        this.Close();
                                    }

                                    /*bağlantı = new SqlConnection("Data Source=.\\SQLEXPRESS; Initial Catalog=" + veriTabanıİsmi + "; Integrated Security=True");
                                     * bağlantı.Open();
                                     * adaptör = new SqlDataAdapter("SELECT kullanıcıadı FROM kullanıcılar", bağlantı);
                                     * tablo = new DataTable();
                                     * adaptör.Fill(tablo);
                                     * bool varmı = false;
                                     * for (int i = 0; i < tablo.Rows.Count; i++)
                                     * {
                                     *  if (tablo.Rows[i]["kullanıcıadı"].ToString() == textBox1.Text)
                                     *  {
                                     *      MessageBox.Show("Kullanıcı adı kullanımda", "Kullanıcı Adı Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                     *      varmı = true;
                                     *      break;
                                     *  }
                                     * }
                                     * bağlantı.Close();
                                     * if (varmı == false)
                                     * {
                                     *  bağlantı = new SqlConnection("Data Source=.\\SQLEXPRESS; Initial Catalog=" + veriTabanıİsmi + "; Integrated Security=True");
                                     *  bağlantı.Open();
                                     *  komut = new SqlCommand();
                                     *  komut.Connection = bağlantı;
                                     *  komut.CommandText = "INSERT INTO kullanıcılar (kullanıcıadı, şifre) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "')";
                                     *  komut.ExecuteNonQuery();
                                     *  bağlantı.Close();
                                     *  MessageBox.Show("Kayıt başarıyla tamamlandı", "Kayıt Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                     *  this.Close();*/
                                }
                            }
                        }
                    }
                }
            }
        }