TestClass.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Data.SqlClient;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace project
  12. {
  13. public class Testovik
  14. {
  15. DataBase dataBase = new DataBase();
  16. public string autoRization(string login, string password)
  17. {
  18. if (login == null)
  19. return "Введите логин";
  20. if (password == null)
  21. return "Введите пароль";
  22. SqlConnection sqlconn = new SqlConnection(@"Data Source=ngknn.ru;Initial Catalog=Project_GorodskoiSpravochnik;Persist Security Info=True;User ID=31П;Password=12357");
  23. string query = $"Select *from Employee where login = '{login}' and password = '{password}'";
  24. SqlDataAdapter sda = new SqlDataAdapter(query, sqlconn);
  25. DataTable dtbl = new DataTable();
  26. sda.Fill(dtbl);
  27. if (dtbl.Rows.Count == 1)
  28. {
  29. Login.login = login;
  30. return "Вы успешно вошли";
  31. }
  32. else
  33. {
  34. return "Неверный логин и/или пароль";
  35. }
  36. }
  37. }
  38. }