Authorization.xaml.cs 2.7 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. namespace ROGOZ.Pages
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для Authorization.xaml
  19. /// </summary>
  20. public partial class Authorization : Window
  21. {
  22. public Authorization()
  23. {
  24. InitializeComponent();
  25. }
  26. private void BtnLogin_Click(object sender, RoutedEventArgs e)
  27. {
  28. //var curentUser = user1Entities.GetContext().User.FirstOrDefault(p => p.Login == TBoxLogin.Text && p.Password == PBoxPassword.Password);
  29. var curentUser = App.Context.User.FirstOrDefault(p => p.Login == TBoxLogin.Text && p.Password == PBoxPassword.Password);
  30. if (curentUser != null)
  31. {
  32. App.CurentUser = curentUser;
  33. MainWindow mainWindow = new MainWindow();
  34. mainWindow.Show();
  35. this.Close();
  36. }
  37. else
  38. {
  39. MessageBox.Show("Пользователь с такими данными не найден.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
  40. }
  41. //if (TBoxLogin.Text != "" && PBoxPassword.Password != "")
  42. //{
  43. // //MessageBox.Show("Заходи", "хихихи", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  44. // MainWindow mainWindow = new MainWindow();
  45. // mainWindow.Show();
  46. // this.Close();
  47. //}
  48. //else
  49. //{
  50. // MessageBox.Show("ДА.", "Капец", MessageBoxButton.OK, MessageBoxImage.Error);
  51. //}
  52. }
  53. private void PBoxPassword_PasswordChanged(object sender, RoutedEventArgs e)
  54. {
  55. if (PBoxPassword.Password.Length > 0)
  56. {
  57. WaterMarkerLabel.Visibility = Visibility.Collapsed;
  58. }
  59. else
  60. {
  61. WaterMarkerLabel.Visibility = Visibility.Visible;
  62. }
  63. }
  64. private void Page_MouseDown(object sender, MouseButtonEventArgs e)
  65. {
  66. if (e.LeftButton == MouseButtonState.Pressed) { DragMove(); }
  67. }
  68. private void btnClose_Click(object sender, RoutedEventArgs e)
  69. {
  70. this.Close();
  71. }
  72. private void btnMinimize_Click(object sender, RoutedEventArgs e)
  73. {
  74. WindowState = WindowState.Minimized;
  75. }
  76. }
  77. }