Example #1
0
        private void homeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string type = Form1.UserType;

            if (type == "Admin")
            {
                BTA_Admin_Panel admin = new BTA_Admin_Panel();
                admin.Show();
                this.Hide();
            }
            else
            {
                BTA_HomePage home = new BTA_HomePage();
                home.Show();
                this.Hide();
            }
        }
        private void button_login_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("Login Button Clicked");
            //First Checking the Login Authentication and Open the respective Section
            //i.e. Admin Panel or User (Tester/Debugger) Panel
            //Getting Login Credentials of the User
            string username = textBox_username.Text.Trim();
            string password = textBox_password.Text.Trim();

            //Decrypt Password Here
            password = EncryptDecrypt.Encrypt(password);
            string usertype = comboBox_usertype.Text.Trim();

            switch (usertype)
            {
            case "Admin":
            {
                //Check user credentials For Admin Login
                LoginDAL l = new LoginDAL();
                l.Login(username, password, usertype);
                bool isLogin = l.Login(username, password, usertype);
                if (isLogin == true)
                {
                    //Login Successfull
                    MessageBox.Show("Login Successfull. Welcome " + username + " to the admin panel.");
                    //Open Admin Panel
                    //SEnding username and usertype to another form
                    Username = username;
                    UserType = usertype;
                    BTA_Admin_Panel admin = new BTA_Admin_Panel();
                    admin.Show();
                    this.Hide();
                }
                else
                {
                    //Login Failed
                    MessageBox.Show("Invalid login credentials. Try Again.");
                }
            }
            break;

            case "Tester":
            {
                //Check user credentials For Admin Login
                LoginDAL l = new LoginDAL();
                l.Login(username, password, usertype);
                bool isLogin = l.Login(username, password, usertype);
                if (isLogin == true)
                {
                    //Login Successfull
                    MessageBox.Show("Login Successfull. Welcome " + username + " to the admin panel.");
                    //Open tester Admin Panel
                    //SEnding username and usertype to another form
                    Username = username;
                    UserType = usertype;
                    BTA_HomePage testerHome = new BTA_HomePage();
                    testerHome.Show();
                    this.Hide();
                }
                else
                {
                    //Login Failed
                    MessageBox.Show("Invalid login credentials. Try Again.");
                }
            }
            break;

            case "Debugger":
            {
                //Check user credentials For Admin Login
                LoginDAL l = new LoginDAL();
                l.Login(username, password, usertype);
                bool isLogin = l.Login(username, password, usertype);
                if (isLogin == true)
                {
                    //Login Successfull
                    MessageBox.Show("Login Successfull. Welcome " + username + " to the admin panel.");
                    //SEnding username and usertype to another form
                    Username = username;
                    UserType = usertype;
                    //Open tester Admin Panel
                    BTA_HomePage testerHome = new BTA_HomePage();
                    testerHome.Show();
                    this.Hide();
                }
                else
                {
                    //Login Failed
                    MessageBox.Show("Invalid login credentials. Try Again.");
                }
            }
            break;

            default:
            {
                MessageBox.Show("Invalid Login Credentials.");
            }
            break;
            }
        }