private void btnLogin_Click(object sender, EventArgs e)
        {
            logBLL.userName = txtUserName.Text.Trim();
            logBLL.passWord = txtPassord.Text.Trim();
            logBLL.userType = cmbUserType.Text.Trim();

            //Checking the Login
            bool success = logDAL.loginCheck(logBLL);

            if (success == true)
            {
                MessageBox.Show("Login SuccessFul");
                //stoer username
                LoggedInUserName = logBLL.userName;
                // We Need to Open Respective Form Based on User Type
                switch (logBLL.userType)
                {
                case "Admin":
                    AdminDashBoard admin = new AdminDashBoard();
                    admin.Show();
                    this.Hide();
                    break;

                case "User":
                    UserDashBoard userDash = new UserDashBoard();
                    userDash.Show();
                    this.Hide();
                    break;

                default:
                {
                    MessageBox.Show("INVALID!!!!! USER");
                }
                break;
                }
            }
            else
            {
                MessageBox.Show("Login Failed!!!!!! try for the second time");
                txtUserName.Text = "";
                txtPassord.Text  = "";
                cmbUserType.Text = "";
            }
        }
Example #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            l.username  = txtUserName.Text.Trim();
            l.password  = txtPassword.Text.Trim();
            l.user_type = cmbUserType.Text.Trim();

            bool sucess = dal.loginCheck(l);

            MessageBox.Show(sucess ? "Login dul i suksesshum" : "Login deshtoi. Provo serish");
            if (sucess)
            {
                loggedIn = l.username;

                switch (l.user_type)
                {
                case "Admin":
                {
                    frmAdminDashboard admin = new frmAdminDashboard();
                    admin.Show();
                    this.Hide();
                }
                break;

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

                default:
                    MessageBox.Show("User Type nuk eshte valid");
                    break;
                }
            }
        }
Example #3
0
        private void loginbutton_Click(object sender, EventArgs e)
        {
            try
            {
                _loginForm.Username = usernametextbox.Text.ToLower().Trim();
                _loginForm.Password = passwordtextbox.Text.Trim();
                _loginForm.UserType = usertypecombobox.SelectedItem.ToString().ToLower();
            }
            catch (Exception exception)
            {
                MessageBox.Show("An error occured please make sure all input field are filled");
            }


            using (var db = new Model1())
            {
                var user = db.Users.FirstOrDefault(x => x.UserName.ToLower() == _loginForm.Username);
                if (user == null)
                {
                    MessageBox.Show("Your login details is incorrect please check them and try again");
                    return;
                }

                var check           = user.UserType.ToLower().Trim();
                var passwordchecker = user.Password.Trim();

                if ((passwordchecker == _loginForm.Password) && (check == _loginForm.UserType))
                {
                    MessageBox.Show("Login successful");
                    switch (check)
                    {
                    case
                        "admin":
                    {
                        FormAdminDashBoard admin = new FormAdminDashBoard();
                        admin.user   = _loginForm.Username.Trim();
                        admin.userId = user.id;
                        admin.Show();
                        Hide();
                        break;
                    }

                    case
                        "normal users":
                    {
                        UserDashBoard users = new UserDashBoard();
                        users.currentUser = _loginForm.Username.Trim();
                        users.Show();
                        Hide();
                        break;
                    }

                    default:
                        MessageBox.Show("Cannot Identify User");
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Your login details is incorrect please check them and try again");
                }
            }
        }