Page1.xaml.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography;
  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 SSS
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для Page1.xaml
  20. /// </summary>
  21. public partial class Page1 : Page
  22. {
  23. public Page1()
  24. {
  25. InitializeComponent();
  26. }
  27. public void Go(object sender, RoutedEventArgs e)
  28. {
  29. MainFrame.Name1.Navigate(new Reg());
  30. }
  31. public void GoVhod(object sender, RoutedEventArgs e)
  32. {
  33. string CurPass = Pass.Password;
  34. using (SHA256 hash = SHA256.Create())
  35. {
  36. CurPass =
  37. BitConverter.ToString(hash.ComputeHash(Encoding.UTF8.GetBytes(CurPass))).Replace("-", "");
  38. {
  39. using (Entities DB = new Entities())
  40. {
  41. Client client = DB.Client.FirstOrDefault(x => x.Login == Login.Text && x.Password == CurPass);
  42. if (client != null)
  43. {
  44. switch (client.id_Role)
  45. {
  46. case 1:
  47. MainFrame.Name1.Navigate(new PageAdmin());
  48. break;
  49. case 2:
  50. MainFrame.Name1.Navigate(new Page2());
  51. break;
  52. default:
  53. MessageBox.Show("Вы не зарегистрированы");
  54. break;
  55. }
  56. }
  57. else
  58. {
  59. MessageBox.Show("Вы не зарегистрированы");
  60. }
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }