okno.xaml.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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.Shapes;
  14. namespace WPF_Entity_Examole
  15. {
  16. /// <summary>
  17. /// Логика взаимодействия для okno.xaml
  18. /// </summary>
  19. public partial class okno : Window
  20. {
  21. gr671_mkyuEntities i;
  22. public okno()
  23. {
  24. InitializeComponent();
  25. i = new gr671_mkyuEntities();
  26. }
  27. private void Button_Click(object sender, RoutedEventArgs e)
  28. {
  29. if (login.Text == "" || password.Password == "" )
  30. {
  31. MessageBox.Show("Пустые поля");
  32. return;
  33. }
  34. if (i.Users.Select(item => item.Login + " " + item.Password).Contains(login.Text + " " + password.Password))
  35. {
  36. MessageBox.Show("Вы авторизованы");
  37. MainWindow mw = new MainWindow();
  38. mw.Show();
  39. this.Close();
  40. }
  41. else
  42. {
  43. MessageBox.Show("Error");
  44. return;
  45. }
  46. }
  47. }
  48. }