12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- ---------------------------------------------------------------------------------------------------------------------------------------------------------
- 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
- {
-
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------------------------
|