MainPage.xaml.cs 1.6 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.Navigation;
  14. using System.Windows.Shapes;
  15. namespace Cafe
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для MainPage.xaml
  19. /// </summary>
  20. public partial class MainPage : Page
  21. {
  22. public MainPage()
  23. {
  24. InitializeComponent();
  25. }
  26. private void LoginBtn_Click(object sender, RoutedEventArgs e)
  27. {
  28. if(LoginTBox.Text != "" && PsswrdBox.Password != "")
  29. {
  30. var AuthorizedUser = DbConnect.gr672_SdaEntities1.User.SingleOrDefault(u => u.Login == LoginTBox.Text && u.Password == PsswrdBox.Password);
  31. if (AuthorizedUser != null)
  32. {
  33. switch (AuthorizedUser.Role.NameOfRole)
  34. {
  35. case "Administrator":
  36. FramePages.MainFrame.Navigate(new AdminPage(AuthorizedUser));
  37. break;
  38. case "Waiter":
  39. FramePages.MainFrame.Navigate(new WaiterPage(AuthorizedUser));
  40. break;
  41. case "Cook":
  42. FramePages.MainFrame.Navigate(new CookPage(AuthorizedUser));
  43. break;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }