using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { String loginUS = textBox1.Text; String passUS = textBox2.Text; BD bd = new BD(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("SELECT id_role FROM `ISPr24-37_AnpilogovPV_ekzam`.login WHERE `name` = @userlog AND `pass` = @userpass", bd.getConnect()); command.Parameters.Add("@userlog", MySqlDbType.VarChar).Value = loginUS; command.Parameters.Add("@userpass", MySqlDbType.VarChar).Value = passUS; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count > 0) { var id_role = table.Rows[0]["id_role"].ToString(); if (id_role == "1") { Hide(); Form2 form2 = new Form2(); form2.Show(); } else if (id_role == "2") { Hide(); Form3 form3 = new Form3(); form3.Show(); } } else { MessageBox.Show("Неверный логин или пароль!"); } } } }