private void btnAdmin_Click(object sender, EventArgs e)
        {
            AdminPanel adminPanel = new AdminPanel();

            adminPanel.Show();
            this.Hide();
        }
Пример #2
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            Hashing hash = new Hashing();

            hash.GenSalt(PswdTextBox.Text, hash.CreateSalt(10));

            userSearchCriteria = new Users
            {
                Hash  = PswdTextBox.Text,
                Login = LoginTextBox.Text
            };

            semID = sems[SemCombobox.SelectedIndex].ID;
            String salt = UserFacade.GetSalt(userSearchCriteria);

            userSearchCriteria.Hash = hash.GenSalt(PswdTextBox.Text, salt);
            log = UserFacade.LogIn(userSearchCriteria);
            if (log != null)
            {
                if (log.TypeOfUser == "adm")
                {
                    this.Hide();
                    AdminPanel fm = new AdminPanel();
                    fm.Show();
                }
                else if (log.TypeOfUser == "tch")
                {
                    this.Hide();
                    TeacherID = UserFacade.GetTeacherFromUser(log).ID;
                    TeacherPanel lct = new TeacherPanel();
                    lct.Show();
                }
                else if (log.TypeOfUser == "std")
                {
                    if (UserFacade.GetStudentSem(log, semID))
                    {
                        albumNumber = UserFacade.GetAlbumNumber(log.ID);
                        this.Hide();
                        StudentWindow std = new StudentWindow();
                        std.Show();
                    }
                    else
                    {
                        MessageBox.Show("Error!", "Error");
                        LoginTextBox.Text = "";
                        PswdTextBox.Text  = "";
                    }
                }
            }
            else
            {
                MessageBox.Show("Wrong login or password!", "Error");
                LoginTextBox.Text = "";
                PswdTextBox.Text  = "";
            }
        }