Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //MsAccess bağlantısı
            OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\kutuphane.accdb");

            con.Open();
            OleDbCommand kmt = new OleDbCommand();

            kmt.Connection = con;     //command connectiona bağlanıyor

            //query kodu
            kmt.CommandText = "SELECT *FROM kullanicilar where kullanici_adi='" + kullanici_adi.Text + "' AND kullanici_sifresi='" + kullanici_sifresi.Text + "'";
            OleDbDataReader oku = kmt.ExecuteReader();

            if (oku.Read())                //okuma gerçekleşiyorsa
            {
                this.Hide();               //mevcut formu gizle
                anamenu k = new anamenu(); // k adında yeni bir anamenu formu türet
                k.ShowDialog();            // yeni formu aç
            }
            else
            {
                MessageBox.Show("Kullanıcı adı ya da şifre yanlış");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Kullanıcı adını lütfen boş bırakmayınız..!");
            }
            else if (textBox2.Text == "")
            {
                MessageBox.Show("Şifrenizi giriniz..!");
            }
            else
            {
                try
                {
                    baglanti.Open();
                    SqlDataAdapter adapter = new SqlDataAdapter("select * from kullanici_tablo where kullanici_adi='" + textBox1.Text + "' and kullanici_sifre='" + textBox2.Text + "'", baglanti);
                    DataSet        dataset = new DataSet();
                    adapter.Fill(dataset);
                    baglanti.Close();
                    yetki = "";
                    yetki = dataset.Tables[0].Rows[0][5].ToString();



                    if (dataset.Tables[0].Rows.Count == 1)
                    {
                        anamenu anamenu = new anamenu();
                        anamenu.Show();
                        this.Visible = false;
                    }
                    else
                    {
                        MessageBox.Show("Lütfen kullanıcı adı ve şifrenizi doğru giriniz.!");
                    }
                }
                catch
                {
                    MessageBox.Show("Lütfen kullanıcı adı ve şifrenizi doğru giriniz.!");
                    baglanti.Close();
                }
            }
        }