private void Button_Enter_Click(object sender, RoutedEventArgs e) { List <User> users = eLibraryDBEntities.Users.ToList(); User user = users.FirstOrDefault(u => u.Login == LoginTextBox.Text && u.Password == UserPassPasswordBox.Password); if (user == null) { MessageBox.Show("Неправильный логин или пароль"); } else if (user.IsBlocked == true) { MessageBox.Show("Вы заблокированны"); } else { switch (user.RoleId) { case 1: ReaderWindow readerWindow = new ReaderWindow(); readerWindow.SetData(eLibraryDBEntities.Readers.FirstOrDefault(r => r.UserId == user.UserId).ReaderId); readerWindow.Show(); this.Close(); break; case 2: LibrarianWindow librarianWindow = new LibrarianWindow(); librarianWindow.SetData(user.UserId); librarianWindow.Show(); this.Close(); break; case 3: AdminWindow adminWindow = new AdminWindow(); adminWindow.SetData(user.UserId); adminWindow.Show(); this.Close(); break; } } }
private void buttonEntrance_Click(object sender, RoutedEventArgs e) { if (ModelCheck()) { try { Users users = LibraryDBEntities.Users.FirstOrDefault(p => p.Login == textBoxLogin.Text && p.Password == passwordBox.Password); if (users.IsBlocked == true) { MessageBox.Show("Дешевка заблокирована"); return; } switch (users.Role.ToLower()) { case "читатель": ReaderWindow reader = new ReaderWindow(users.Id); reader.Show(); this.Close(); break; case "библиотекарь": LibrarianWindow librarian = new LibrarianWindow(users.Id); librarian.Show(); this.Close(); break; case "администратор": AdministratorWindow administrator = new AdministratorWindow(); administrator.Show(); this.Close(); break; } } catch { MessageBox.Show("Пойманы за руку как дешевка"); } } }