MainWindow.xaml.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.Remoting.Contexts;
  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.Navigation;
  15. using System.Windows.Shapes;
  16. using System.Data.Entity;
  17. namespace WindowedMyApp
  18. {
  19. /// <summary>
  20. /// Логика взаимодействия для MainWindow.xaml
  21. /// </summary>
  22. public partial class MainWindow : Window
  23. {
  24. public MainWindow()
  25. {
  26. InitializeComponent();
  27. }
  28. private void Button_Click(object sender, RoutedEventArgs e)
  29. {
  30. //ModelClass model = new ModelClass();
  31. //model.Klients.Where(Klients => Klients.Name == loginText.Text);
  32. using (ModelClass db = new ModelClass())
  33. {
  34. int HashPasswrd = passwrdText.Password.GetHashCode();
  35. Klients klient = db.Klients
  36. .FirstOrDefault(x => x.Login == loginText.Text && x.Password == HashPasswrd);
  37. if (klient != null)
  38. {
  39. ActiveWindow window = new ActiveWindow();
  40. window.Show();
  41. Close();
  42. }
  43. else
  44. {
  45. MessageBox.Show("Такого пользователя не существует");
  46. }
  47. }
  48. }
  49. private void toRegisterButton_Click(object sender, RoutedEventArgs e)
  50. {
  51. RegWind wind = new RegWind();
  52. wind.Show();
  53. Close();
  54. }
  55. }
  56. }