示例#1
0
        private void btnExit_Click(object sender, EventArgs e)
        {
            StaffHome home = new StaffHome();

            home.Show();
            this.Close();
        }
示例#2
0
        public void checkStaff()
        {
            //Create SqlConnection
            SqlConnection con = new SqlConnection(@"Data Source=KAVEER-PC\MSSQL;Initial Catalog=petcare;Integrated Security=True");
            SqlCommand    cmd = new SqlCommand("select * from userTable where userStatus = 'active' and userType = 'staff' and username = @username and userPassword = @password ", con);

            cmd.Parameters.AddWithValue("@username", txtUsername.Text);
            cmd.Parameters.AddWithValue("@password", MD5Hash(txtPwd.Text));
            con.Open();
            SqlDataAdapter adapt = new SqlDataAdapter(cmd);
            DataSet        ds    = new DataSet();

            adapt.Fill(ds);
            con.Close();
            int count = ds.Tables[0].Rows.Count;

            //If count is equal to 1, than show frmMain form
            if (count == 1)
            {
                MessageBox.Show("Login Successful!");
                StaffHome staff = new StaffHome();
                this.Hide();
                staff.Show();
            }
            else
            {
                MessageBox.Show("Login Failed");
            }
        }