private void button1_Click_1(object sender, EventArgs e)
        {
            Admin_Dashboard obj = new Admin_Dashboard();

            obj.Show();
            this.Hide();
        }
示例#2
0
        private void btnGoBack_Click(object sender, EventArgs e)
        {
            Admin_Dashboard obj = new Admin_Dashboard();

            obj.Show();
            this.Hide();
        }
示例#3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                bool valid = true;
                if (string.IsNullOrEmpty(txtUsername.Text) || string.IsNullOrEmpty(txtPassword.Text))
                {
                    MessageBox.Show("Need to fill all the values ", "Register", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    valid = false;
                }
                if (valid)
                {
                    String     UserType = null;
                    SqlCommand cmd      = new SqlCommand
                                              ("Select UserType from  StaffInfo where Username ='******' and Password ='******' ", sqlCon);
                    SqlDataReader dr      = cmd.ExecuteReader();
                    Boolean       records = dr.HasRows;
                    if (records)
                    {
                        while (dr.Read())
                        {
                            UserType = dr[0].ToString();
                        }
                        if (UserType.Equals("Admin"))
                        {
                            Admin_Dashboard obj = new Admin_Dashboard();
                            obj.Show();
                            this.Hide();
                        }
                        else if (UserType.Equals("Cashier"))
                        {
                            Cashier_Dashboard obj = new Cashier_Dashboard();
                            obj.Show();
                            this.Hide();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid login Credentials/Staff Account Does Not Exist", "Login Form", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    dr.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error inserting data" + ex, "Login Form", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }