private void Inp_Click(object sender, RoutedEventArgs e) { if (login.Text == "" || password.Text == "") { MessageBox.Show("Вы заполнили не все поля"); if (login.Text == "") { login.BorderBrush = System.Windows.Media.Brushes.Red; } if (password.Text == "") { password.BorderBrush = System.Windows.Media.Brushes.Red; } } else { using (UserContext db = new UserContext()) { try { var select = db.Users.Where(u => u.login == login.Text || u.password == password.Text); IdUser = select.FirstOrDefault().Id; string rol = select.FirstOrDefault().rolles; switch (rol) { case "Директор": Director dir = new Director(IdUser); dir.Show(); this.Close(); break; case "Заказчик": Client cl = new Client(IdUser); cl.Show(); this.Close(); break; case "Менеджер": Manager mngr = new Manager(IdUser); mngr.Show(); this.Close(); break; case "Кладовщик": klad kld = new klad(IdUser); kld.Show(); this.Close(); break; } } catch { var select = db.Users.Where(u => u.login == login.Text); try { string passw = select.FirstOrDefault().password; if (passw != password.Text) { MessageBox.Show("Неверно введен пароль!"); } } catch { MessageBox.Show("Такого пользователя не существует"); } } } } }