Avtorization.xaml.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using PP_Ven_MosS.Classes;
  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. using PP_Ven_MosS.ModelBase;
  17. using PP_Ven_MosS.Pages;
  18. namespace PP_Ven_MosS
  19. {
  20. /// <summary>
  21. /// Логика взаимодействия для Avtorization.xaml
  22. /// </summary>
  23. public partial class Avtorization : Page
  24. {
  25. public Avtorization()
  26. {
  27. InitializeComponent();
  28. }
  29. public void Registration_Click(object sender, RoutedEventArgs e)
  30. {
  31. FrameClass.MainFrame.Navigate(new Registration());
  32. }
  33. public void Sign_Click(object sender, RoutedEventArgs e)
  34. {
  35. try
  36. {
  37. string GHCPass = PBPass.Password.GetHashCode().ToString();
  38. User user = Database.entities.User.FirstOrDefault(x => x.Login == TBLog.Text && x.Password == GHCPass);
  39. if (user != null)
  40. {
  41. if (user.Id_role == 1)
  42. {
  43. UserRole.userrole = user.Id_role;
  44. UserID.userid = user.Id_user;
  45. FrameClass.MainFrame.Navigate(new MenuAdmin());
  46. }
  47. else if (user.Id_role == 2)
  48. {
  49. UserRole.userrole = user.Id_role;
  50. UserID.userid = user.Id_user;
  51. FrameClass.MainFrame.Navigate(new ApplicationsListAdmin());
  52. }
  53. else if (user.Id_role == 3)
  54. {
  55. UserRole.userrole = user.Id_role;
  56. UserID.userid = user.Id_user;
  57. FrameClass.MainFrame.Navigate(new ApplicationsListUser());
  58. }
  59. }
  60. else
  61. {
  62. MessageBox.Show("Неверный логин или пароль,\n попробуйте еще раз\n, или зарегистрируйтесь");
  63. }
  64. }
  65. catch
  66. {
  67. MessageBox.Show("Ошибка");
  68. }
  69. }
  70. }
  71. }