AuthorizationWindow.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 WpfApp1.Methods;
  9. using WpfApp1.Windows;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Shapes;
  16. namespace WpfApp1.Windows
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для AuthorizationWindow.xaml
  20. /// </summary>
  21. public partial class AuthorizationWindow : Window
  22. {
  23. CafeEntities db;
  24. public AuthorizationWindow()
  25. {
  26. InitializeComponent();
  27. db = new CafeEntities();
  28. }
  29. //логика после нажатия кнопки "Войти"
  30. private void AuthorizationClick(object sender, RoutedEventArgs e)
  31. {
  32. AuthorizationMethod authorizationMethod = new AuthorizationMethod();
  33. if(authorizationMethod.AuthorizationEnter(LoginText.Text, PasswordText.Password) == true)
  34. {
  35. //логика открытия окна, соответствующая роли авторизированного пользователя
  36. var role = db.Test_User.FirstOrDefault(r => r.Login == LoginText.Text && r.Password == PasswordText.Password);
  37. switch (role.idPost)
  38. {
  39. case 1:
  40. Hide();
  41. new AdminWindow().ShowDialog();
  42. Application.Current.Shutdown();
  43. break;
  44. case 2:
  45. Hide();
  46. new WaiterWindow().ShowDialog();
  47. Application.Current.Shutdown();
  48. break;
  49. case 3:
  50. Hide();
  51. new CookWindow().ShowDialog();
  52. Application.Current.Shutdown();
  53. break;
  54. }
  55. }
  56. }
  57. }
  58. }