LoginPage.xaml.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 PsychoTest.Pages
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для LoginPage.xaml
  19. /// </summary>
  20. public partial class LoginPage : Page
  21. {
  22. PsychoBase DB = new PsychoBase();
  23. public LoginPage()
  24. {
  25. InitializeComponent();
  26. }
  27. private void LogIn(object sender, RoutedEventArgs e)
  28. {
  29. Users user = DB.Users.Where(x=>x.Login == Login.Text && x.Password == Password.Password).FirstOrDefault();
  30. if(user != null)
  31. {
  32. if(user.Id_role == 2)
  33. {
  34. MainFrame.frame.Navigate(new UserTests(user.User_id));
  35. }
  36. else
  37. {
  38. MainFrame.frame.Navigate(new PsychoPage(user.User_id));
  39. }
  40. }
  41. else
  42. {
  43. MessageBox.Show("Ваших данных нет в базе");
  44. }
  45. }
  46. }
  47. }