Form1.cs 1.8 KB

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