|
@@ -0,0 +1,76 @@
|
|
|
+---------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
+//Резерв C# команд (Win Forms)
|
|
|
+
|
|
|
+//Авторизация через базу данных:
|
|
|
+
|
|
|
+ using (var db = new LeTest5Entities())
|
|
|
+ {
|
|
|
+ var Users1 = db.Users1.AsNoTracking().FirstOrDefault(u => u.login == textBox1.Text && u.pass == textBox2.Text);
|
|
|
+
|
|
|
+ if (Users1 == null)
|
|
|
+ {
|
|
|
+ label4.Text = "Неверный логин/пароль";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (Users1.status)
|
|
|
+ {
|
|
|
+ case "admin":
|
|
|
+ {
|
|
|
+ admin123 sf = new admin123();
|
|
|
+ sf.Owner = this;
|
|
|
+ sf.Show();
|
|
|
+ this.Hide();
|
|
|
+
|
|
|
+ MessageBox.Show("Добро пожаловать админ!");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ case "operator":
|
|
|
+ {
|
|
|
+ Products sf = new Products();
|
|
|
+ sf.Owner = this;
|
|
|
+ sf.Show();
|
|
|
+ this.Hide();
|
|
|
+ MessageBox.Show("Добро пожаловать оператор!");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+---------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
+
|
|
|
+//Регистрация в базе данных:
|
|
|
+
|
|
|
+ using (var db = new LeTest5Entities())
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(textBox1.Text) | string.IsNullOrEmpty(textBox2.Text) | string.IsNullOrEmpty(textBox3.Text))
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ bool registr = db.Users1.Any(u => u.login == textBox1.Text|u.pass == textBox2.Text);
|
|
|
+ if (!registr)
|
|
|
+ {
|
|
|
+
|
|
|
+ db.Database.ExecuteSqlCommand($"INSERT INTO Users1 (login, pass, status)\nVALUES('{textBox1.Text}','{textBox2.Text}','{textBox3.Text}');");
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+---------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|