Form1.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 yrok2
  11. {
  12. public partial class Form1 : Form
  13. {
  14. Class1 database = new Class1();
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Form1_Load(object sender, EventArgs e)
  20. {
  21. }
  22. private void button1_Click(object sender, EventArgs e)
  23. {
  24. string usern = textBox1.Text;
  25. string pass = textBox2.Text;
  26. SqlDataAdapter adapter = new SqlDataAdapter();
  27. DataTable table = new DataTable();
  28. string querystring = $"SELECT Login, Password FROM LoginPassword WHERE Login = '{usern}' and Password = '{pass}'";
  29. SqlCommand command = new SqlCommand(querystring, database.GetConnection());
  30. adapter.SelectCommand = command;
  31. adapter.Fill(table);
  32. if (table.Rows.Count == 1)
  33. {
  34. MessageBox.Show("Успешно!");
  35. Form2 frm = new Form2();
  36. this.Hide();
  37. frm.Show();
  38. }
  39. else
  40. MessageBox.Show("Неверные данные");
  41. }
  42. }
  43. }