LoginPage.xaml.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. NavigationService.Navigate(new Pages.MainPage());
  35. else
  36. {
  37. try
  38. {
  39. if (!Functions.IsValidLogAndPass(LogBox.Text, PassBox.Password))
  40. new ErrorWindow("Поля не могут быть пустыми").Show();
  41. else if (!Functions.LoginCheck(LogBox.Text, PassBox.Password))
  42. new ErrorWindow("Неверный логин или пароль").Show();
  43. else
  44. {
  45. //Profile.userId = cnt.db.User.Where(item => item.NickName == LogBox.Text).Select(item => item.Id).FirstOrDefault();
  46. NavigationService.Navigate(new Pages.MainPage());
  47. }
  48. }
  49. catch
  50. {
  51. new ErrorWindow("Ошибка входа").ShowDialog();
  52. }
  53. }
  54. }
  55. }
  56. }