AutorisationWindow.xaml.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 UP43P_Krupina.Pages;
  16. namespace UP43P_Krupina.Windows
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для AutorisationWindow.xaml
  20. /// </summary>
  21. public partial class AutorisationWindow : Window
  22. {
  23. User user;
  24. public AutorisationWindow()
  25. {
  26. InitializeComponent();
  27. Base.MyBase = new UP_KrupinaEntities();
  28. this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
  29. }
  30. private void Autorisation_Click(object sender, RoutedEventArgs e)
  31. {
  32. if (CheckingData())
  33. {
  34. SPMain.Visibility = Visibility.Hidden;
  35. frame.Navigate(new MainUserPage(user));
  36. }
  37. else
  38. {
  39. UsialWindow win = new UsialWindow("Неверные логин или пароль.");
  40. win.ShowDialog();
  41. }
  42. }
  43. private bool CheckingData()
  44. {
  45. user = Base.MyBase.User.FirstOrDefault(x => x.UserLogin == TBLogin.Text && x.UserPassword == TBPassword.Password.ToString());
  46. if (user == null) return false;
  47. return true;
  48. }
  49. private void WithoutAutorisation_Click(object sender, RoutedEventArgs e)
  50. {
  51. SPMain.Visibility = Visibility.Hidden;
  52. frame.Navigate(new MainUserPage());
  53. }
  54. }
  55. }