예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //// Random image = new Random();
            //Form1.ActiveForm.BackgroundImage = new Bitmap("C:\\Users\\By Rdv\\documents\\visual studio 2015\\Projects\\KuaforAna\\KuaforAna\\images\\b1.jpg");
            SqlConnection MyConnection = new SqlConnection();

            MyConnection.ConnectionString = ConnectionClass.Connection_Path();
            MyConnection.Open();
            SqlCommand    komut = new SqlCommand("SELECT * FROM KULLANICI WHERE USERNAME= '******' AND PASSWORD= '******'");
            SqlDataReader dr;

            komut.Connection = MyConnection;
            dr = komut.ExecuteReader();
            int count = 0;

            while (dr.Read())
            {
                count += 1;
            }
            if (count == 1)
            {
                Form12 du = new Form12();
                Form2.ActiveForm.Visible = false;
                du.Show();
            }
            else if (count == 0 && textBox1.Text != "" && textBox2.Text != "")
            {
                MessageBox.Show("Lütfen kullanıcı adınız veya şifreniz hatalı!", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Clear();
                textBox2.Clear();
            }


            else if (textBox1.Text == "" && textBox2.Text == "")
            {
                MessageBox.Show("Lütfen kullanıcı adınızı ve şifrenizi giriniz.", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.Clear();
                textBox2.Clear();
            }
            else if (textBox1.Text == "")
            {
                MessageBox.Show("Kullanıcı adınızı giriniz.", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (textBox2.Text == "")
            {
                MessageBox.Show("Lütfen şifrenizi giriniz.", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }