123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- 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 Cafe12
- {
- public partial class AutorizationForm : Form
- {
- ClassCON classCON = new ClassCON();
- public AutorizationForm()
- {
- InitializeComponent();
- StartPosition = FormStartPosition.CenterScreen;
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- var loginUser = textBox2.Text;
- var passUser = textBox1.Text;
- SqlConnection conn = new SqlConnection("Data Source=class31000;Initial Catalog=CHER_KAFE;Integrated Security=True");
- conn.Open();
- SqlDataAdapter adapter = new SqlDataAdapter();
- DataTable table = new DataTable();
- SqlCommand cmd = new SqlCommand("SELECT ID_Роли FROM Пользователи WHERE Логин=@username AND Пароль=@password", conn);
- cmd.Parameters.AddWithValue("@username", loginUser);
- cmd.Parameters.AddWithValue("@password", passUser);
- SqlDataReader reader = cmd.ExecuteReader();
- if (reader.HasRows)
- {
-
- reader.Read();
- int role = reader.GetInt32(0);
- if (role == 1)
- {
- AdministrationForm administrator = new AdministrationForm();
- administrator.ShowDialog();
- }
- else if (role == 2)
- {
- OficiantForm meneger = new OficiantForm();
- meneger.Show();
- }
- else if (role == 3)
- {
- PovarMenu torgash = new PovarMenu();
- torgash.Show();
- }
- }
- else
- {
- MessageBox.Show("не авторизован");
- }
- conn.Close();
- }
-
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- textBox1.PasswordChar = '*';
- textBox1.MaxLength = 50;
- textBox1.MaxLength = 50;
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- }
- }
|