1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace yrok2
- {
- public partial class Form1 : Form
- {
- Class1 database = new Class1();
- public Form1()
- {
- InitializeComponent();
-
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string usern = textBox1.Text;
- string pass = textBox2.Text;
- SqlDataAdapter adapter = new SqlDataAdapter();
- DataTable table = new DataTable();
- string querystring = $"SELECT Login, Password FROM LoginPassword WHERE Login = '{usern}' and Password = '{pass}'";
- SqlCommand command = new SqlCommand(querystring, database.GetConnection());
- adapter.SelectCommand = command;
- adapter.Fill(table);
- if (table.Rows.Count == 1)
- {
- MessageBox.Show("Успешно!");
- Form2 frm = new Form2();
- this.Hide();
- frm.Show();
- }
- else
- MessageBox.Show("Неверные данные");
- }
- }
- }
|