Example #1
0
        // GİRİŞ
        private void BtnGiris_Click(object sender, EventArgs e)
        {
            SqlCommand komut = new SqlCommand("Select * From Admin where YoneticiAd=@p1 and YoneticiSifre=@p2", bgl.baglanti());

            komut.Parameters.AddWithValue("@p1", TxtKullaniciAd.Text);
            komut.Parameters.AddWithValue("@p2", TxtSifre.Text);
            SqlDataReader oku = komut.ExecuteReader();

            if (oku.Read())
            {
                FrmAnaForm fr = new FrmAnaForm();
                fr.Show();      // Ana Formu göster.
                this.Hide();    // Admin giriş kısmını gizle.
            }
            else
            {
                MessageBox.Show("Hatalı Giriş! Kullanıcı adı veya şifre hatalı!");
                TxtKullaniciAd.Clear(); // Kullanıcı adı kısmını temizler.
                TxtSifre.Clear();       // Şifre kısmını temizler.
                TxtKullaniciAd.Focus(); // İmleci Kullanıcı adı kısmına getirir.
            }
            bgl.baglanti().Close();
        }
        private void BtnGirisYap_Click(object sender, EventArgs e)
        {
            SqlCommand komut = new SqlCommand("select * from admin where yoneticiad=@p1 and  yoneticisifre=@p2", bgl.baglanti());

            komut.Parameters.AddWithValue("@p1", TxtKullaniciAd.Text);
            komut.Parameters.AddWithValue("@p2", TxtSifre.Text);
            SqlDataReader oku = komut.ExecuteReader();

            if (oku.Read())
            {
                FrmAnaForm fr = new FrmAnaForm();
                fr.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Hatalı kullanıcı adı ya da şifre");
                TxtKullaniciAd.Clear();
                TxtSifre.Clear();
                TxtKullaniciAd.Focus();
            }
            bgl.baglanti().Close();
        }