LoginPage.xaml.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. namespace MyTests.Pages
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для RegistrationPage.xaml
  19. /// </summary>
  20. public partial class LoginPage : Page
  21. {
  22. bool Test = true;
  23. public LoginPage()
  24. {
  25. InitializeComponent();
  26. }
  27. private void RegButton_Click(object sender, RoutedEventArgs e)
  28. {
  29. NavigationService.Navigate(new Pages.RegistrationPage());
  30. }
  31. private void LogButton_Click(object sender, RoutedEventArgs e)
  32. {
  33. if (Test)
  34. {
  35. Session.User = cnt.db.Users.Where(item => item.IdUser == 1).FirstOrDefault();
  36. NavigationService.Navigate(new Pages.MainPage());
  37. }
  38. else
  39. {
  40. try
  41. {
  42. if (!Functions.IsValidLogAndPass(LogBox.Text, PassBox.Password))
  43. new ErrorWindow("Поля не могут быть пустыми").Show();
  44. else if (!Functions.LoginCheck(LogBox.Text, PassBox.Password))
  45. new ErrorWindow("Неверный логин или пароль").Show();
  46. else
  47. {
  48. //Profile.userId = cnt.db.User.Where(item => item.NickName == LogBox.Text).Select(item => item.Id).FirstOrDefault();
  49. NavigationService.Navigate(new Pages.MainPage());
  50. }
  51. }
  52. catch
  53. {
  54. new ErrorWindow("Ошибка входа").ShowDialog();
  55. }
  56. }
  57. }
  58. }
  59. }