Avtorization.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Servise.Classes;
  2. using Servise.Forms;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace Servise
  14. {
  15. public partial class Form1 : Form
  16. {
  17. DataBase conect = new DataBase();
  18. public Form1()
  19. {
  20. InitializeComponent();
  21. }
  22. private void Avtorization_Click(object sender, EventArgs e)
  23. {
  24. string query = "Select *from employees where login = '" + Login.Text.Trim() + "' and password = '" + Password.Text.Trim() + "'";
  25. SqlDataAdapter sda = new SqlDataAdapter(query, conect.getConect());
  26. DataTable dtbl = new DataTable();
  27. sda.Fill(dtbl);
  28. if (dtbl.Rows.Count == 1)
  29. {
  30. UserInform.Login = Login.Text.Trim();
  31. UserInform.Password = Password.Text.Trim();
  32. if (Login.Text.Trim() == "admin")
  33. {
  34. UserInform.AdminLi = true;
  35. }
  36. this.Hide();
  37. Main goMain = new Main();
  38. goMain.Show();
  39. }
  40. else
  41. {
  42. MessageBox.Show("Неверный логин и/или пароль");
  43. }
  44. }
  45. private void FomClose(object sender, FormClosedEventArgs e)
  46. {
  47. Application.Exit();
  48. }
  49. }
  50. }