Exemplo n.º 1
0
        private void mem_Login_Click(object sender, EventArgs e)
        {
            // Open database to look for correct ID and password.
            // The branch and ID is Saved for all other forms.
            if ((member_Id.TextLength > 0) && (member_pw.TextLength > 0))
            {
                string email, pw;

                SqlConnection sq = new SqlConnection();
                sq.ConnectionString = "Data Source=DESKTOP-863JJKV;Initial Catalog=Project;Integrated Security=True";
                SqlCommand cmd = new SqlCommand("select * from [Members] where email=@username and Password=@password ", sq);
                cmd.Parameters.AddWithValue("@username", member_Id.Text);
                cmd.Parameters.AddWithValue("@password", member_pw.Text);
                sq.Open();
                SqlDataReader sq_reader = cmd.ExecuteReader();

                bool match = false;


                while ((sq_reader.Read()))
                {
                    email = sq_reader["email"].ToString();
                    pw    = sq_reader["Password"].ToString();

                    if ((member_Id.Text.Trim() == email.Trim()) && (member_pw.Text.Trim() == pw.Trim()))
                    {
                        match     = true;
                        member_ID = Convert.ToInt32(sq_reader["ID"]);
                        branch_ID = Convert.ToInt32(sq_reader["Branch_ID"]);
                        MessageBox.Show("Successful log-in!");
                        // Passing both these objects for Branch and ID
                        Member_login member = new Member_login(home, this);
                        member.Show();
                        this.Close();
                    }
                }
                // If none found.
                if (!match)
                {
                    MessageBox.Show("Incorrect credentials, Try again!");
                    home.Show();
                    this.Close();
                    sq_reader.Close();
                    sq.Close();
                }
            }
        }
Exemplo n.º 2
0
 private void Back_Click(object sender, EventArgs e)
 {
     this.Close();
     member.Show();
 }
Exemplo n.º 3
0
 private void rated_Click(object sender, EventArgs e)
 {
     MessageBox.Show("You've successfully rated!");
     this.Close();
     member.Show();
 }