Auth.xaml.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using MyWpfApp.models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace MyWpfApp.Pages
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для Auth.xaml
  20. /// </summary>
  21. public partial class Auth : Page
  22. {
  23. List<User> users;
  24. public Auth()
  25. {
  26. InitializeComponent();
  27. // users = new List<User>() { new User { Name = "Ivan", Login = "123", Password = "123", Id = 1 }, new User() { Name = "Petr", Login = "456", Password = "456", Id = 2 } };
  28. }
  29. private void btnEnter_Click(object sender, RoutedEventArgs e)
  30. {
  31. int pass = TxtPassword.Password.GetHashCode();
  32. LoginedTable currentUser = Globals.MyGlobalConnection.LoginedTable.FirstOrDefault(x=>x.Login == TxtLogin.Text && x.Password == pass);
  33. if (currentUser != null)
  34. {
  35. MessageBox.Show("Здравствуйте, "+ currentUser.Roles.Role);
  36. if (currentUser.IDRole==1)
  37. {
  38. Globals.MyGlobalFrame.Navigate(new PageUserList());
  39. }
  40. else
  41. {
  42. Globals.MyGlobalFrame.Navigate(new PageUserInfo(currentUser));
  43. }
  44. }
  45. else
  46. {
  47. MessageBox.Show("Вы не зарегистрированы");
  48. }
  49. }
  50. private void Button_Click(object sender, RoutedEventArgs e)
  51. {
  52. MessageBox.Show("Сработало");
  53. }
  54. }
  55. }