Form1.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace WindowsFormsAppGrishina
  10. {
  11. public partial class Form1 : Form
  12. {
  13. public Form1()
  14. {
  15. InitializeComponent();
  16. }
  17. private void button1_Click(object sender, EventArgs e)
  18. {
  19. Form2 Form2 = new Form2();
  20. Form2.Show();
  21. }
  22. private void button2_Click(object sender, EventArgs e)
  23. {
  24. if (string.IsNullOrEmpty(TextBoxLogin.Text) || string.IsNullOrEmpty(PasswordBox.Text))
  25. {
  26. MessageBox.Show("Введите логин и пароль");
  27. return;
  28. }
  29. using (var db = new UserEntities())
  30. {
  31. var user = db.User
  32. .AsNoTracking()
  33. .FirstOrDefault(u => u.Login == TextBoxLogin.Text && u.Pass == PasswordBox.Text);
  34. if (user == null)
  35. {
  36. MessageBox.Show("Пользователь с такими данными не найден");
  37. return;
  38. }
  39. MessageBox.Show("Пользователь найден");
  40. }
  41. }
  42. }
  43. }