Authorization.xaml.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. using teaTime;
  16. using TeaTime;
  17. namespace teaTime
  18. {
  19. /// <summary>
  20. /// Логика взаимодействия для Authorization.xaml
  21. /// </summary>
  22. public partial class Authorization : Page
  23. {
  24. public Authorization()
  25. {
  26. InitializeComponent();
  27. }
  28. Worker worker = new Worker();
  29. Member member = new Member();
  30. private void bAuth_Click(object sender, RoutedEventArgs e)
  31. {
  32. if(checkWorker(aLogin.Text, aPass.Password))
  33. {
  34. NavigationService.Navigate(new wWorkerMain(worker));
  35. }
  36. else if (checkMember(aLogin.Text, aPass.Password))
  37. {
  38. NavigationService.Navigate(new wMemberMain(member));
  39. }
  40. else
  41. {
  42. MessageBox.Show("Не найдено");
  43. }
  44. }
  45. public bool checkWorker(string login, string password)
  46. {
  47. bool check = false;
  48. using(KotkovaISazonovaEntities_ DB = new KotkovaISazonovaEntities_())
  49. {
  50. List<Worker> w = DB.Worker.ToList();
  51. for(int i = 0; i < w.Count; i++)
  52. {
  53. if(w[i].login == login && w[i].password == password)
  54. {
  55. check = true;
  56. worker = w[i];
  57. }
  58. }
  59. }
  60. return check;
  61. }
  62. public bool checkMember(string login, string password)
  63. {
  64. bool check = false;
  65. using (KotkovaISazonovaEntities_ DB = new KotkovaISazonovaEntities_())
  66. {
  67. List<Member> m = DB.Member.ToList();
  68. for (int i = 0; i < m.Count; i++)
  69. {
  70. if (m[i].login == login && m[i].password == password)
  71. {
  72. check = true;
  73. member = m[i];
  74. }
  75. }
  76. }
  77. return check;
  78. }
  79. private void bReg_Click(object sender, RoutedEventArgs e)
  80. {
  81. NavigationService.Navigate(new Regestration());
  82. }
  83. }
  84. }