public void Execute(object parameter) { var loginSet = parameter as LoginSet; LoginValidation loginValidation = new LoginValidation(loginSet.Username, loginSet.Password, new LoginValidation.ActionOnError(PrintErrorMessage)); User validUser = null; if (loginValidation.ValidateUserInput(ref validUser)) { if (validUser.role == 1) { //Message for admin MessageBox.Show("Welcome administrator!", "Notice!", MessageBoxButton.OK); MainWindow mainWindow = new MainWindow(validUser); mainWindow.Show(); return; } else { MainWindow mainWindow = new MainWindow(validUser); mainWindow.Show(); return; } } MessageBox.Show("Wrong username or password!", "Notice!", MessageBoxButton.OK); loginSet.Username = loginSet.Password = ""; }
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); } }
private void Button_Click(object sender, RoutedEventArgs e) { LoginValidation validator = new LoginValidation(username.Text, password.Password, showError); User temp = new User(); if (validator.ValidateUserInput(ref temp) == true) { MainForm another = new MainForm(temp); another.Show(); this.Close(); } }
private void loginBtn_Click(object sender, RoutedEventArgs e) { // Sanitize the box clearAllTextBoxes(); string username = usernameBox.Text; string password = passwordBox.Text; // Login in the Program.cs of UserLogin LoginValidation validation = new LoginValidation(username, password, UserLogin.Program.ValidationErrorHandler); user = new User(); user.Username = username; user.Password = password; if (validation.ValidateUserInput(ref user)) { // Student role if (user.RoleId == 4) { ChangeAccessToAllBoxes(true); GetStudentInfoByFacNumber(user.FacNumber); loginBtn.IsEnabled = false; logoutBtn.IsEnabled = true; this.student = GetStudentInfoByFacNumber(user.FacNumber); this.DataContext = this.student; } // Professor role else if (user.RoleId == 1) { ChangeAccessToAllBoxes(true); clearAllTextBoxes(); addMarkBtn.Visibility = Visibility.Visible; btnGetStudentInfo.Visibility = Visibility.Visible; loginBtn.IsEnabled = false; logoutBtn.IsEnabled = true; NavigationWindow profWindow = new NavigationWindow(); profWindow.Content = new ProfessorPage(); profWindow.Show(); NavigationWindow specializationWindow = new NavigationWindow(); specializationWindow.Content = new SpecializationsPage(); specializationWindow.Show(); } } else { MessageBox.Show("Invalid username and/or password"); } }
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 vali = new LoginValidation(txtUsername.Text, txtPassword.Text, ConsoleShowErr); if (vali.ValidateUserInput(ref MainWindow.user)) { MainWindow Win1 = new MainWindow(); Win1.Show(); if (MainWindow.user.role == UserRole.STUDENT) { Student st = StudentData.IsThereStudent(MainWindow.user.facultyNumber); if (st != null) { Win1.DisplayInfo(st); } Win1.btnPermisions.IsEnabled = false; Win1.btnSearch.IsEnabled = false; } if (MainWindow.user.role == UserRole.PROFESSOR) { TeacherControlWindow Teach = new TeacherControlWindow(); Teach.Show(); Win1.Close(); this.Close(); //Win1.btnPermisions.IsEnabled = false; } if (MainWindow.user.role == UserRole.ADMIN) { AdminControlWindow Adm = new AdminControlWindow(); Adm.Show(); Win1.Close(); this.Close(); //Win1.btnPermisions.IsEnabled = false; } this.Close(); } else { txtPassword.Text = ""; Login.ConsoleShowErr("wrong info"); vali = null; } }
private void BtnLogin_Click(object sender, RoutedEventArgs e) { string username = txtInputUserName.Text; string password = txtInputPassword.Text; var validation = new LoginValidation(username, password, message => { MessageBox.Show(message); }); User user = null; if (validation.ValidateUserInput(ref user)) { Student student = _validation.GetStudentDataByUser(user); if (student != null) { new MainWindow(student).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 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 LoginButton(object sender, RoutedEventArgs e) { User user = new User(); LoginWindow lv = new LoginWindow(); LoginValidation loginValidation = new LoginValidation(nameBox.Text, passwordBox.Text, printError); temp = nameBox.Text; if (loginValidation.ValidateUserInput(ref user)) { this.Close(); MainWindow mainWindow = new MainWindow(); mainWindow.Show(); } else { MessageBox.Show("Грешни данни."); nameBox.Text = String.Empty; passwordBox.Text = String.Empty; } }
private void Button_Click(object sender, RoutedEventArgs e) { LoginValidation loginValidation = new LoginValidation(txt1.Text, txt2.Text, Program.error); User user = null; if (loginValidation.ValidateUserInput(ref user) && user.role == 4) { MainWindow mainWindow = new MainWindow(); mainWindow.GetStudent(user.number); mainWindow.Show(); this.Close(); } else { MessageBox.Show("Error"); } /*foreach (User user in UserData.TestUsers) * { * if (txt1.Text.Equals(user.name) && (txt2.Text.Equals(user.pass)) && (user.role == 4)) * { * //MainWindow mainWindow = new MainWindow(); * StudentData studentData = new StudentData(); * foreach (Student student in studentData.TestStudents) * { * if (student.number == user.number) * { * MainWindow mainWindow = new MainWindow(); * mainWindow.GetStudent(); * mainWindow.Show(); * this.Close(); * } * } * * } * else { continue; } * }*/ }
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 LoginUser() { LoginValidation validator = new LoginValidation(usernameTextBox.Text, passwordBox.Password, DisplayMessage); User user = null; if (validator.ValidateUserInput(ref user)) { DisableLoginForm(); if (user.role == (int)UserRoles.STUDENT) { Student stud = StudentData.IsThereStudent(user.facNumber); EnableForm(); FillStudentInfo(stud); } if (user.role == (int)UserRoles.PROFESSOR) { //FacNumSearchGrid.Visibility = Visibility.Visible; ProfessorWindow main = new ProfessorWindow(); App.Current.MainWindow = main; this.Close(); main.Show(); } } }
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 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(); } } }