Exemplo n.º 1
0
        private void AuthenticateUser(User user)
        {
            if (user == null)
            {
                MessageBox.Show("Email or password is invalid!", "No such user!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            UserCategory category = UsersDAL.GetUserCategory(user.UserID);
            switch (category)
            {
                case UserCategory.ADMIN: //open admin window
                    AdminMenu a_menu = new AdminMenu(user.UserID);
                    a_menu.FormClosed += (o, s) =>
                    {
                        Application.Exit();
                    };
                    a_menu.Owner = this;
                    a_menu.Show();
                    this.Hide();
                    break;
                case UserCategory.PARENT: //open parent window
                    ParentMenu p_menu = new ParentMenu(user.UserID);
                    p_menu.FormClosed += (o, s) =>
                    {
                        Application.Exit();
                    };
                    p_menu.Owner = this;
                    p_menu.Show();
                    this.Hide();
                    break;
                case UserCategory.STUDENT: //open student window
                    StudentMenu s_menu = new StudentMenu(user.UserID);
                    s_menu.FormClosed += (o, s) =>
                    {
                        Application.Exit();
                    };
                    s_menu.Owner = this;
                    s_menu.Show();
                    this.Hide();
                    break;
                case UserCategory.TEACHER: //open teacher window
                    TeacherMenu t_menu = new TeacherMenu(user.UserID);
                    t_menu.FormClosed += (o, s) =>
                    {
                        Application.Exit();
                    };
                    t_menu.Owner = this;
                    t_menu.Show();
                    this.Hide();
                    break;
                case UserCategory.NONE: //show error
                    goto default;
                default: MessageBox.Show("Internal error occured in resolving user category!");
                    return;
            }
        }
Exemplo n.º 2
0
        private void AuthenticateUser(User user)
        {
            if (user == null)
            {
                MessageBox.Show("Email or password is invalid!", "No such user!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            UserCategory category = UsersDAL.GetUserCategory(user.UserID);

            switch (category)
            {
            case UserCategory.ADMIN:     //open admin window
                AdminMenu a_menu = new AdminMenu(user.UserID);
                a_menu.FormClosed += (o, s) =>
                {
                    Application.Exit();
                };
                a_menu.Owner = this;
                a_menu.Show();
                this.Hide();
                break;

            case UserCategory.PARENT:     //open parent window
                ParentMenu p_menu = new ParentMenu(user.UserID);
                p_menu.FormClosed += (o, s) =>
                {
                    Application.Exit();
                };
                p_menu.Owner = this;
                p_menu.Show();
                this.Hide();
                break;

            case UserCategory.STUDENT:     //open student window
                StudentMenu s_menu = new StudentMenu(user.UserID);
                s_menu.FormClosed += (o, s) =>
                {
                    Application.Exit();
                };
                s_menu.Owner = this;
                s_menu.Show();
                this.Hide();
                break;

            case UserCategory.TEACHER:     //open teacher window
                TeacherMenu t_menu = new TeacherMenu(user.UserID);
                t_menu.FormClosed += (o, s) =>
                {
                    Application.Exit();
                };
                t_menu.Owner = this;
                t_menu.Show();
                this.Hide();
                break;

            case UserCategory.NONE:     //show error
                goto default;

            default: MessageBox.Show("Internal error occured in resolving user category!");
                return;
            }
        }