private bool login()
        {
            string query = "Select * from userinfo where AccountNumber=@AccountNumber and Pin=@Pin";

            if (this.dbConnect.OpenConnection() == true)
            {
                //create command and assign the query and connection from the constructor
                MySqlCommand cmd = new MySqlCommand(query, dbConnect.connection);

                cmd.Parameters.AddWithValue("@AccountNumber", txtAccountNumber.Text);
                Class1.AccountNumber = txtAccountNumber.Text;
                cmd.Parameters.AddWithValue("@Pin", txtPin.Text);

                cmd.ExecuteNonQuery();

                MySqlDataReader login = cmd.ExecuteReader();

                if (login.Read())
                {
                    dbConnect.CloseConnection();
                    return(true);
                }
                else
                {
                    dbConnect.CloseConnection();
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 2
0
        private bool login()
        {
            string query = "Select * from employee where Username=@Username and Password=@Password";

            if (this.dbConnect.OpenConnection() == true)
            {
                //create command and assign the query and connection from the constructor
                MySqlCommand cmd = new MySqlCommand(query, dbConnect.connection);

                cmd.Parameters.AddWithValue("@Username", txtUsername.Text);
                cmd.Parameters.AddWithValue("@Password", txtPassword.Text);

                cmd.ExecuteNonQuery();

                MySqlDataReader login = cmd.ExecuteReader();

                if (login.Read())
                {
                    dbConnect.CloseConnection();
                    return(true);
                }
                else
                {
                    dbConnect.CloseConnection();
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }