private void BtnEnterClick(object sender, RoutedEventArgs e) { List <User> users = TatarCulturDbEntities.GetContext().Users.ToList(); User user = users.FirstOrDefault(p => p.Login == TbLogin.Text && p.Password == PbPassword.Password); StringBuilder error = new StringBuilder(); if (string.IsNullOrWhiteSpace(TbLogin.Text)) { error.AppendLine("Введите логин"); } if (string.IsNullOrWhiteSpace(PbPassword.Password)) { error.AppendLine("Введите пароль"); } if (error.Length > 0) { MessageBox.Show(error.ToString(), "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (user != null) { int rols = (int)user.IdRols; Manager.idUser = user.IdUser; MainWindow mainWindow = new MainWindow(rols, user); mainWindow.Owner = this; this.Hide(); mainWindow.Show(); } else if (user == null) { MessageBox.Show("Неверный пароль или логин", "Неверный пароль или логин", MessageBoxButton.OK, MessageBoxImage.Error); PbPassword.Clear(); } }
private void CheckFields() { if (CoBAlgorithm.SelectedIndex == 4) { SpDpApiSettings.Visibility = Visibility.Visible; GrFileEncryptionPassword.Visibility = Visibility.Collapsed; PbPassword.Clear(); if (_selectedFile != null && _selectedFileInfo != null && CoBAlgorithm.SelectedItem != null && !string.IsNullOrWhiteSpace(TbFileDestination.Text) ) { BtStart.IsEnabled = true; } else { BtStart.IsEnabled = false; } return; } SpDpApiSettings.Visibility = Visibility.Collapsed; GrFileEncryptionPassword.Visibility = Visibility.Visible; if (_selectedFile != null && _selectedFileInfo != null && !string.IsNullOrWhiteSpace(PbPassword.Password) && CoBAlgorithm.SelectedItem != null && !string.IsNullOrWhiteSpace(TbFileDestination.Text) ) { BtStart.IsEnabled = true; } else { BtStart.IsEnabled = false; } }
private void SignIn(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(TbLogin.Text)) { MB.MessageBoxInfo("Введите логин"); TbLogin.Focus(); } else if (string.IsNullOrWhiteSpace(PbPassword.Password)) { MB.MessageBoxInfo("Введите пароль"); PbPassword.Focus(); } else { var employee = DataService.GetContext().Employee.FirstOrDefault(u => u.User.Login == TbLogin.Text); if (employee == null) { MB.MessageBoxInfo("Введен неверно логин/пароль"); TbLogin.Focus(); count++; } else { if (employee.User.Password != PbPassword.Password) { MB.MessageBoxInfo("Введен неверно логин/пароль"); TbLogin.Clear(); PbPassword.Clear(); count++; } else { Entity.CurrentEmployee = employee; switch (employee.User.IdRole) { case 1: new WinManager().Show(); this.Close(); break; case 2: new WinEmployee().Show(); this.Close(); break; case 3: new WinAdmin().Show(); this.Close(); break; } count = 0; } } if (count >= 3) { TbLogin.Text = string.Empty; PbPassword.Password = string.Empty; GridSignIn.Visibility = Visibility.Hidden; GridCaptcha.Visibility = Visibility.Visible; TbCaptcha.Text = Captcha.GenerateString(5); return; } } }