Ejemplo n.º 1
0
        private void login_Click(object sender, EventArgs e)
        {
            string user  = username.Text;
            string pass  = password.Text;
            string query = "SELECT * FROM users WHERE username = '******' AND password ='******';";

            conn.Open();
            MySqlCommand     comm = new MySqlCommand(query, conn);
            MySqlDataAdapter adap = new MySqlDataAdapter(comm);

            conn.Close();
            DataTable tbl = new DataTable();

            adap.Fill(tbl);

            if (tbl.Rows.Count == 1)
            {
                Main_menu main = new Main_menu();
                main.getUsername = tbl.Rows[0]["username"].ToString();
                main.getUsertype = tbl.Rows[0]["user_type"].ToString();
                main.getUid      = tbl.Rows[0]["user_id"].ToString();
                main.getFname    = tbl.Rows[0]["firstname"].ToString();
                main.getLname    = tbl.Rows[0]["lastname"].ToString();
                main.prev        = this;
                this.Hide();
                setNull();
                main.Show();
            }
            else if (username.ForeColor == Color.Gray || password.ForeColor == Color.Gray)
            {
                MessageBox.Show("You did not enter a username or password!");
            }
            else
            {
                MessageBox.Show("The username or password is incorrect.");
            }
        }