コード例 #1
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            l.username  = txt_UserName.Text.Trim();
            l.password  = txt_Password.Text.Trim();
            l.user_type = cmb_UserType.Text.Trim();

            //checking the login credentials
            bool success = dal.loginCheck(l);

            if (success == true)
            {
                MessageBox.Show("Login Sucessful.");
                loggedIn = l.username;
                switch (l.user_type)
                {
                case "Admin":
                {
                    frm_AdminDashBoard admin = new frm_AdminDashBoard();
                    admin.Show();
                    this.Hide();
                }
                break;

                case "User":
                {
                    frm_DashBoard_Users user = new frm_DashBoard_Users();
                    user.Show();
                    this.Hide();
                }
                break;

                default:
                {
                    MessageBox.Show("Invalid User Type.");
                }
                break;
                }
            }
            else
            {
                MessageBox.Show("Login Failed. Try Again.");
            }
        }