Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            String          constring   = "SERVER=db4free.net;UID=internals;PWD=peaceinheaven;PORT=3306;DATABASE=internals;old guids=true";
            MySqlConnection conDataBase = new MySqlConnection(constring);
            MySqlCommand    cmdDataBase = new MySqlCommand("select CollegeCode,UserName,cast(aes_decrypt(Password,'SecretKey') as char(50)) as Password  from internals.login where UserName='******' and Password=aes_encrypt('" + textBox2.Text + "','SecretKey') and CollegeCode='" + textBox3.Text + "';", conDataBase);
            MySqlDataReader myReader;

            try
            {
                conDataBase.Open();
                myReader = cmdDataBase.ExecuteReader();
                int count = 0;
                while (myReader.Read())
                {
                    count = count + 1;
                }
                if (count == 1)
                {
                    MessageBox.Show("YOU ARE AN AUTHORIZED USER...ACCESS GRANTED.");
                    this.Hide();
                    mainform f2 = new mainform(textBox1.Text, textBox3.Text);
                    f2.ShowDialog();
                }
                else if (count > 1)
                {
                    MessageBox.Show("DUPLICATE USERNAME AND PASSWORD...ACCESS DENIED.");
                }
                else
                {
                    MessageBox.Show("YOU SEEM TO BE AN UNAUTHORIZED USER...ACCESS DENIED.");
                }

                conDataBase.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            String          constring   = "datasource=localhost;port=3306;username=root;password=root";
            MySqlConnection conDataBase = new MySqlConnection(constring);
            MySqlCommand    cmdDataBase = new MySqlCommand("select * from internals.login where UserName='******' and Password='******';", conDataBase);
            MySqlDataReader myReader;

            try
            {
                conDataBase.Open();
                myReader = cmdDataBase.ExecuteReader();
                int count = 0;
                while (myReader.Read())
                {
                    count = count + 1;
                }
                if (count == 1)
                {
                    MessageBox.Show("YOU ARE AN AUTHORIZED USER...ACCESS GRANTED.");
                    this.Hide();
                    mainform f2 = new mainform();
                    f2.ShowDialog();
                }
                else if (count > 1)
                {
                    MessageBox.Show("DUPLICATE USERNAME AND PASSWORD...ACCESS DENIED.");
                }
                else
                {
                    MessageBox.Show("YOU SEEM TO BE AN UNAUTHORIZED USER...ACCESS DENIED.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }