public void Login(Form _form)
        {
            loginProxy = new LoginProxy();
            var user = loginProxy.Login(UserName, Password);

            if (user != null)
            {
                if (user.AccountLevel == "admin")
                {
                    _form.Hide();
                    Form admin = new AdminDashboard();
                    admin.Show();
                }
                else if (user.AccountLevel == "student")
                {
                    _form.Hide();
                    Form student = new StudentDashboard(user.RegistrationID.ToString());
                    student.Show();
                }
                else if (user.AccountLevel == "teacher")
                {
                    _form.Hide();
                    Form teacher = new TeacherDashboard(user.RegistrationID.ToString());
                    teacher.Show();
                }
            }
            else
            {
                MessageBox.Show("Incorrect Username or Password!");
            }
        }
 private void btnSignin_Click(object sender, EventArgs e)
 {
     if (userNameTextBox.Text == "" || userPasswordTextBox.Text == "")
     {
         MessageBox.Show("Username or password can not be empty");
     }
     else
     {
         UserService    userService    = new UserService();
         StudentService studentService = new StudentService();
         bool           userResult     = userService.LoginValidation(userNameTextBox.Text, userPasswordTextBox.Text);
         bool           studentResult  = studentService.LoginValidation(userNameTextBox.Text, userPasswordTextBox.Text);
         if (userResult)
         {
             Dashboard dashboard = new Dashboard();
             dashboard.Show();
             this.Hide();
         }
         else if (studentResult)
         {
             StudentDashboard student = new StudentDashboard();
             student.Show();
             this.Hide();
         }
         else
         {
             MessageBox.Show("Invalid User Name or Password!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #3
0
        private void Login()
        {
            if (string.IsNullOrWhiteSpace(txtUserName.Text))
            {
                MessageBox.Show("Username is required");
                return;
            }
            if (string.IsNullOrWhiteSpace(txtPassword.Text))
            {
                MessageBox.Show("password is required");
                return;
            }

            var loginrequest = new LoginRequestViewModel()
            {
                UserName = txtUserName.Text,
                Password = txtPassword.Text
            };
            var result = Services.UserService.Login(loginrequest);

            if (result.Status)
            {
                switch (result.Type)
                {
                case Common.UserType.Student:
                    StudentDashboard student = new StudentDashboard(result);
                    student.Show();
                    break;

                case Common.UserType.Teacher:
                    TeacherDashboard teacher = new TeacherDashboard(result);
                    teacher.Show();
                    break;

                case Common.UserType.Parent:
                    break;

                case Common.UserType.Admin:

                    AdminDashboard admin = new AdminDashboard(result);
                    admin.Show();
                    break;

                default:
                    break;
                }
                this.Hide();
            }
            else
            {
                MessageBox.Show(result.Message);
            }
        }