private void Button_Click(object sender, RoutedEventArgs e) { JournalDBEntities db = new JournalDBEntities(); bool check = false; string pass = "******"; if (tbLogin.Text == string.Empty) { if (tbPass.Password == pass) { SaveProperty(1); new MainWindow().Show(); this.Close(); } else { MessageBox.Show("Не верный пароль"); } } else { foreach (var item in db.Employees) { if (item.login == tbLogin.Text) { if (item.password == tbPass.Password) { Properties.Settings.Default.idUser = item.id; if (item.accessRights == true) { SaveProperty(3); } else { SaveProperty(2); } new MainWindow().Show(); check = true; this.Close(); break; } } } if (check == false) { MessageBox.Show("Вы ввели неверный логин или пароль"); } } }