Vhod.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 partial class Vhod : Form
  14. {
  15. public Vhod()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Vhod_FormClosed(object sender, FormClosedEventArgs e)
  20. {
  21. Application.Exit();
  22. }
  23. private void button1_Click(object sender, EventArgs e)
  24. {
  25. if (polelogin.Text.Replace(" ", "") == "") MessageBox.Show("Поле логин не может быть пустым");
  26. else if (polepassword.Text.Replace(" ", "") == "") MessageBox.Show("Поле пароль не может быть пустым");
  27. else
  28. {
  29. SqlConnection sqlconn = new SqlConnection(@"Data Source=ngknn.ru;Initial Catalog=31P-Gromov-PP;Persist Security Info=True;User ID=31П;Password=12357");
  30. string query = "Select *from Autorizate where login = '" + polelogin.Text.Trim() + "' and password = '" + polepassword.Text.Trim() + "'";
  31. SqlDataAdapter sda = new SqlDataAdapter(query, sqlconn);
  32. DataTable dtbl = new DataTable();
  33. sda.Fill(dtbl);
  34. if (dtbl.Rows.Count == 1)
  35. {
  36. this.Hide();
  37. Main Main = new Main();
  38. Main.ShowDialog();
  39. }
  40. else
  41. {
  42. MessageBox.Show("Неверный логин и/или пароль");
  43. }
  44. }
  45. }
  46. }
  47. }