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; using System.Data.SqlClient; namespace KazarinDE { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void textBox2_TextChanged(object sender, EventArgs e) { } private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (checkBox1.Checked) { textBox2.PasswordChar = '\0'; } else { textBox2.PasswordChar = '●'; } } private void pictureBox1_Click(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } private void label2_Click(object sender, EventArgs e) { } private void label1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { string username = textBox1.Text; string password = textBox2.Text; SqlConnection conn = new SqlConnection(@"Data Source=Class31000;Initial Catalog=KazarinDE_03;Integrated Security=True"); conn.Open(); SqlCommand cmd = new SqlCommand("SELECT Роли, Статус FROM Сотрудники WHERE Username=@username AND Password=@password", conn); cmd.Parameters.AddWithValue("@username", username); cmd.Parameters.AddWithValue("@password", password); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); int Roles = reader.GetInt32(0); int status = reader.GetInt32(1); if (status == 1) { if (Roles == 1) { Form2 administrator = new Form2(); administrator.Show(); this.Hide(); } else if (Roles == 2) { Form3 waiters = new Form3(); waiters.Show(); this.Hide(); } else if (Roles == 3) { Form4 cooks = new Form4(); cooks.Show(); this.Hide(); } } else { MessageBox.Show("Отказано в доступе"); } } } } }