Пример #1
0
        private void btnGiris_Click(object sender, EventArgs e)
        {
            Kullanici k = db.Kullanici.FirstOrDefault(x => x.kullaniciAdi == txtKullaniciAdi.Text && x.sifre == txtParola.Text);

            if (k != null)
            {
                AnaEkran ae = new AnaEkran();
                ae.Show();
            }
        }
Пример #2
0
 public int GirisYap(string kullaniciAdi, string sifre)
 {
     try
     {
         if (kullaniciAdi != "" && sifre != "") //kullanıcı adı ve parolanın dolu olup olmadığının kontrolü
         {
             if (IsNumeric(kullaniciAdi))       //kullanıcı adı sayısal olamaz.
             {
                 MessageBox.Show("Kullanıcı adı sayısal olamaz.");
             }
             else
             {
                 Kullanici k = db.Kullanici.FirstOrDefault(x => x.kullaniciAdi == kullaniciAdi && x.sifre == sifre);//kullanıcıAdı ve paraloya göre kullanıcı bulunur.
                 if (k != null)
                 {
                     k.aktifMi = true;//kullanıcının sisteme girdiğini belirtmek için aktif mi özelliği true yapılır.
                     db.SaveChanges();
                     AnaEkran ae = new AnaEkran();
                     ae.Show();
                     txtKullaniciAdi.Text = "";
                     txtParola.Text       = "";
                     return(1);
                 }
                 else
                 {
                     MessageBox.Show("Kullanıcı adı veya şifre hatalı.", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return(0);
                 }
             }
         }
         else
         {
             MessageBox.Show("Lütfen kullanıcı adınızı ve şifrenizi giriniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         return(2);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Bilinmeyen Bir Hata Oluştu!", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(3);
     }
 }