private void LoggedHandler(Object sender, LogginEventArgs e) { RequestResults result = CheckUser(e.userName, e.password); switch (result) { case RequestResults.Student: this.Visibility = Visibility.Hidden; setNormalSize(); StudentWindow studentWindow = new StudentWindow(); studentWindow.WindowClosed += ExitApplication; frmMainContent.Content = studentWindow; this.Visibility = Visibility.Visible; break; case RequestResults.Profesor: this.Visibility = Visibility.Hidden; setNormalSize(); TeacherWindow teacherWindow = new TeacherWindow(); teacherWindow.WindowClosed += ExitApplication; frmMainContent.Content = teacherWindow; this.Visibility = Visibility.Visible; break; case RequestResults.Master: this.Visibility = Visibility.Hidden; setNormalSize(); AdministratorWindow administratorWindow = new AdministratorWindow(); administratorWindow.WindowClosed += ExitApplication; frmMainContent.Content = administratorWindow; this.Visibility = Visibility.Visible; break; case RequestResults.None: logginWindow.setWarningVisible(); break; } }
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 = ""; } }