AuthorizationWindow.xaml.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace Hotel_Course_Project
  15. {
  16. /// <summary>
  17. /// Логика взаимодействия для AuthorizationWindow.xaml
  18. /// </summary>
  19. public partial class AuthorizationWindow : Window
  20. {
  21. public AuthorizationWindow()
  22. {
  23. InitializeComponent();
  24. }
  25. private void AuthBtn_Click(object sender, RoutedEventArgs e)
  26. {
  27. var user = DataBase.db.Staff.SingleOrDefault(x => x.Login == Login.Text && x.Password == Password.Password);
  28. if (user != null && user.Id_PersStatus == 2)
  29. {
  30. MessageBox.Show("Данный пользователь удалён из базы данных");
  31. }
  32. else if (user != null && user.Id_PersStatus == 1)
  33. {
  34. MainWindow mainWindow = new MainWindow(user);
  35. mainWindow.Show();
  36. this.Close();
  37. }
  38. else
  39. {
  40. MessageBox.Show("Ошибка авторизации");
  41. Password.Password = "";
  42. }
  43. }
  44. private void Window_Loaded(object sender, RoutedEventArgs e)
  45. {
  46. Login.Focus();
  47. }
  48. }
  49. }