Page1.xaml.cs 2.3 KB

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