private void GirisYapButon_Click(object sender, EventArgs e)
 {
     try
     {
         if (KullaniciAdBox.Text == "" && SifreBox.Text == "")
         {
             MessageBox.Show("Lütfen boş kısım bırakmayınız.");
         }
         else
         {
             islem            = new MeshEkran.Classlar.AdminGiris();
             adminkullanicisi = islem.AdminKontrol(KullaniciAdBox.Text, SifreBox.Text);
             if (adminkullanicisi != null)
             {
                 Admin_AnaMenu a = new Admin_AnaMenu();
                 MessageBox.Show("Başarıyla giriş yaptınız.");
                 a.StartPosition = FormStartPosition.CenterScreen;
                 a.Show();
                 this.Hide();
                 Dispose();
             }
             else
             {
                 MessageBox.Show("Kullanıcı adı veya şifre yanlıştır. Lütfen tekrar deneyiniz.");
             }
         }
     }
     catch (Exception hata)
     {
         MessageBox.Show("Bir hata oluştu. \n");
         MessageBox.Show(hata.Message);
     }
 }
Exemple #2
0
 public KullaniciDLL.Admin AdminKontrol(string KullaniciAdi, string Sifre)
 {
     KullaniciDLL.Admin adminuser = null;
     using (var connection = MeshEkran.Veritabani.Database.GetConnection())
     {
         var command = new SqlCommand("SELECT *FROM Admin WHERE KullaniciAdi='" + KullaniciAdi + "'and Sifre='" + Sifre + "'")
         {
             Connection = connection
         };
         connection.Open();
         using (var reader = command.ExecuteReader())
         {
             while (reader.Read())
             {
                 adminuser = new KullaniciDLL.Admin
                 {
                     KullaniciID  = reader.GetInt32(0),
                     KullaniciAdi = reader.GetString(1),
                     Sifre        = reader.GetString(2),
                     Isim         = reader.GetString(3),
                     Soyisim      = reader.GetString(4)
                 };
             }
         }
         connection.Close();
     }
     return(adminuser);
 }
Exemple #3
0
        public bool AdminInsert(KullaniciDLL.Admin adminuser)
        {
            bool result = false;

            if (!AdminVarsa(adminuser))
            {
                using (var connection = MeshEkran.Veritabani.Database.GetConnection())
                {
                    var command = new SqlCommand("INSERT INTO Admin(KullaniciAdi,Sifre,Ad,Soyad) VALUES('" + adminuser.KullaniciAdi + "','" + adminuser.Sifre + "','" + adminuser.Isim + "','" + adminuser.Soyisim + "')")
                    {
                        Connection = connection
                    };
                    connection.Open();
                    if (command.ExecuteNonQuery() != -1)
                    {
                        result = true;
                    }
                    connection.Close();
                }
            }
            return(result);
        }
Exemple #4
0
        private bool AdminVarsa(KullaniciDLL.Admin adminuser)
        {
            bool result = false;

            using (var connection = MeshEkran.Veritabani.Database.GetConnection())
            {
                var command = new SqlCommand("SELECT *FROM Admin WHERE KullaniciAdi='" + adminuser.KullaniciAdi + "'")
                {
                    Connection = connection
                };
                connection.Open();
                using (var reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        result = true;
                    }
                }
                connection.Close();
            }
            return(result);
        }