public void Login() { var validation = new LoginValidation(LoginParameters.Username, LoginParameters.Password, errorAction); User user = null; if (validation.ValidateUserInput(ref user)) { Page page = new StudentPage(); if (user.Role == UserRoles.STUDENT) { var studentPage = page as StudentPage; var studentValidation = new StudentValidation(); try { studentPage.Student = studentValidation.GetStudentDataByUser(user); } catch (ArgumentException ex) { studentPage.Student = null; } } else if (user.Role == UserRoles.ADMIN) { page = new AdminPage(); } else { page = new StudentPage(); MessageBox.Show("Login was unsuccessful"); return; } loginWindow.NavigateTo(page); } }
public MainWindow(User user) { InitializeComponent(); //currStudent = findLoginStudent(user.fakNum); currStudent = StudentValidation.GetStudentDataByUser(user); }
private void FillsData() { User user = UserData.TestUsers[0]; student = StudentValidation.GetStudentDataByUser(user); ShowStudentData = student; }
public MainWindowVM(User tempuser) { st = StudentValidation.IsThereStudent(tempuser); if (tempuser.userRole == 4) { PopulateCommand = new RelayCommand(Populate); } }
public Login() { InitializeComponent(); _validation = new StudentValidation(message => MessageBox.Show(message)); Logger.Logger.plant(); UserData.ResetTestUserData(); StudentData.AddStudents(); }
private void btnEnter_Click(object sender, RoutedEventArgs e) { UserLogin.LoginValidation new1 = new UserLogin.LoginValidation(txtLogName.Text, txtLogPass.Text, MyErrorMessage); UserLogin.User us1 = new UserLogin.User(); if (new1.ValidateUserInput(ref us1) == true) { Student newStudent = StudentValidation.GetStudentDataByUser(us1); MainWindow mw = new MainWindow(); mw.showStudentInfo(newStudent); mw.Show(); } }
private void btn_click(object sender, RoutedEventArgs e) { string username = txtUser.Text.Trim(); string password = txtPass.Text.Trim(); User user = null; LoginValidation login = new LoginValidation(username, password, ErrHandler); if (login.ValidateUserInput(ref user)) { Student student = StudentValidation.GetStudentDataByUser(user); MainWindow anotherWindow = new MainWindow(); anotherWindow.Vm.ShowStudentData = student; anotherWindow.Show(); this.Close(); } }
private void btnLogin_Click(object sender, RoutedEventArgs e) { LoginValidation lv = new LoginValidation(txtUsername.Text, txtPassword.Password, printError); User user = new User(); if (lv.ValidateUserInput(ref user)) { Student student = StudentValidation.GetStudentDataByUser(user); MainWindow mainWindow = new MainWindow(); MainWindowVM vm = new MainWindowVM(student, mainWindow); mainWindow.DataContext = vm; mainWindow.Show(); this.Close(); } else { resetInputFields(); } }
private void btnFork_Click(object sender, RoutedEventArgs e) { checkStudent = StudentData.testStudent[0]; User user = StudentValidation.GetUserDataByStudent(checkStudent); if (user != null && user.role == 1) { ForkWindow forkWindow = new ForkWindow(); forkWindow.Height = this.Height; forkWindow.Width = this.Width; forkWindow.Show(); } else { MessageBoxResult result = MessageBox.Show("Нямате адмиски права!", "Внимание", MessageBoxButton.OK, MessageBoxImage.Question); if (result == MessageBoxResult.OK) { e.Handled = true; } } }
private void LoginBtn_Click(object sender, RoutedEventArgs e) { string username = txtUsername.Text; string password = passwordBox.Password; LoginValidation validation = new LoginValidation(username, password, ShowActionErrorMessage); User user = new User(); if (validation.ValidateUserInput(ref user)) { try { Student student = StudentValidation.GetStudentDataByUser(user); MainWindow mainWindow = new MainWindow(student); mainWindow.Show(); Close(); } catch { invalidCredentials(); } } }
private void loginBtn_Click(object sender, RoutedEventArgs e) { string username = usernameTxtBox.Text; string password = passwordTxtBox.Password; LoginValidation validation = new LoginValidation(username, password, ShowActionErrorMessage); User user = new User(); if (validation.ValidateUserInput(ref user)) { //StudentValidation.InsertIntoStudentData(); Student student = StudentValidation.GetStudentDataByFacultyNumber(user); MainWindow mainWindow = new MainWindow(); MainWindowViewModel vm = new MainWindowViewModel(student, mainWindow); mainWindow.DataContext = vm; mainWindow.Show(); Close(); } else { resetInputFields(); } }
private void btnLogin_Click(object sender, RoutedEventArgs e) { //StudentData.resetStudents(); UserLogin.UserData.ResetTestUserData(); LoginValidation loginValidation = new LoginValidation(txtUsername.Text, txtPassword.Password, printError); User user = new User(); if (loginValidation.ValidateUserInput(ref user)) { /*MainWindow anotherWindow = new MainWindow(); * anotherWindow.Show(); * Hide();*/ Student student = StudentValidation.GetStudentDataByUser(user); MainWindow mainWindow = new MainWindow(); MainWindowVM mwVM = new MainWindowVM(student, mainWindow); mainWindow.DataContext = mwVM; mainWindow.Show(); this.Close(); } else { Logger.LogActivity("Unsuccessful Login"); MessageBox.Show("Neshto nevalidno vavede ti!"); TextBox usernameBox = txtUsername; usernameBox.Clear(); PasswordBox passwordBox = txtPassword; passwordBox.Clear(); /*MessageBox.Show("Invalid data"); * txtUsername.Clear(); * txtPassword.Clear();*/ } }
private void buttonLogin(object sender, RoutedEventArgs e) { if (currentUserRole == UserRoles.ANONYMOUS) { User u = UserData.IsUserPassCorrect(((TextBox)tb_user).Text, ((TextBox)tb_pass).Text); if (u != null) { //isLoggedIn = true; enableAllControls(); user.IsEnabled = false; tb_user.IsEnabled = false; tb_pass.Text = String.Empty; pass.IsEnabled = false; tb_pass.IsEnabled = false; btnLogin.Content = "Изход"; currentUserRole = (UserRoles)u.role; switch (u.role) { case (int)UserRoles.STUDENT: Student s = StudentValidation.GetStudentDataByUser(u); fillStudentControls(s); break; case (int)UserRoles.ADMIN: btnGrades.Visibility = Visibility.Visible; fNumberProfessor.Visibility = Visibility.Visible; tb_fNumberProfessor.Visibility = Visibility.Visible; buttonSearchStudent.Visibility = Visibility.Visible; /* u.role = (int)UserRoles.ANONYMOUS; */ break; case (int)UserRoles.INSPECTOR: InspectorWindow iw = new InspectorWindow(); iw.Show(); //this.Close(); break; default: break; } GradeWindow gradeWindow = new GradeWindow(); gradeWindow.Show(); } } else { currentUserRole = UserRoles.ANONYMOUS; user.IsEnabled = true; tb_user.IsEnabled = true; pass.IsEnabled = true; tb_pass.IsEnabled = true; btnLogin.Content = "Вход"; //isLoggedIn = false; clearAllControls(); disableAllControls(); btnGrades.Visibility = Visibility.Hidden; fNumberProfessor.Visibility = Visibility.Hidden; tb_fNumberProfessor.Visibility = Visibility.Hidden; buttonSearchStudent.Visibility = Visibility.Hidden; } }
private void Button_Click(object sender, RoutedEventArgs e) { Boolean emptyUserName; emptyUserName = username.Text.Equals(String.Empty); Boolean emptyPassword; emptyPassword = password.Equals(String.Empty); bool isStFound = false; if (emptyUserName == true) { MessageBox.Show("Не е посочено потребителско име"); Delete(); } else if (emptyPassword == true) { MessageBox.Show("Не е посоченa парола"); Delete(); } else if (username.Text.Length < 5) { MessageBox.Show("Потребителското име е по - малкo от 5 символа"); Delete(); } else if (password.Text.Length < 5) { MessageBox.Show("Паролата е по - малка от 5 символа"); Delete(); } else { LoginValidation login = new LoginValidation(username.Text, password.Text, OnLoginError); User user = null; if (!login.ValidateUserInput(ref user)) { Delete(); return; } if (user.role == 4) { Student student = StudentValidation.GetStudentDataByUser(user); MainWindow mainWindow = new MainWindow(); mainWindow.DataContext = new MainFormVM() { Student = student }; isStFound = true; mainWindow.Show(); Delete(); } if (isStFound == false) { MessageBox.Show("Няма такъв студент"); Delete(); } } }