Form1.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace BB_Zdanovich
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void label1_Click(object sender, EventArgs e)
  19. {
  20. }
  21. private void Form1_Load(object sender, EventArgs e)
  22. {
  23. }
  24. private void button2_Click(object sender, EventArgs e)
  25. {
  26. this.Close();
  27. }
  28. private void button1_Click(object sender, EventArgs e)
  29. {
  30. // Реализация авторизации пользователя
  31. if (string.IsNullOrEmpty(TextBoxLogin.Text) || string.IsNullOrEmpty(PasswordBox.Text))
  32. {
  33. MessageBox.Show("Введите логин и пароль");
  34. return;
  35. }
  36. using (var db = new BB_ZdanovichEntities())
  37. {
  38. var user = db.Auth
  39. .AsNoTracking()
  40. .FirstOrDefault(u => u.Login == TextBoxLogin.Text && u.Password == PasswordBox.Text);
  41. if (user == null)
  42. {
  43. MessageBox.Show("Пользователь с такими данными не найден");
  44. return;
  45. }
  46. MessageBox.Show("Пользователь найден");
  47. Form2 f2 = new Form2();
  48. f2.Show();
  49. }
  50. }
  51. }
  52. }