Auth.cs 1.4 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. using System.Data.SqlClient;
  10. namespace Perevozki
  11. {
  12. public partial class Auth : Form
  13. {
  14. public Auth()
  15. {
  16. InitializeComponent();
  17. StartPosition = FormStartPosition.CenterScreen;
  18. }
  19. private void button1_Click(object sender, EventArgs e)
  20. {
  21. DB dataBase = new DB();
  22. var log = textBox1.Text;
  23. var pass = textBox2.Text;
  24. SqlDataAdapter adapter = new SqlDataAdapter();
  25. DataTable table = new DataTable();
  26. string querystring = $"select Login, Password from Polzovateli where Login='{log}' and Password='{pass}'";
  27. SqlCommand command = new SqlCommand(querystring, dataBase.GetConnection());
  28. adapter.SelectCommand = command;
  29. adapter.Fill(table);
  30. if (table.Rows.Count > 0)
  31. {
  32. MessageBox.Show("Вы успешно вошли!");
  33. Menu f2 = new Menu();
  34. f2.ShowDialog();
  35. }
  36. else
  37. {
  38. MessageBox.Show("Неверный логин или пароль, повторите попытку");
  39. }
  40. }
  41. }
  42. }