AutorisationWindow.xaml.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using PPPISI52.Pages;
  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.Shapes;
  15. using PPPISI52.Pages;
  16. namespace PPPISI52.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 PP_PISIEntities();
  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. }