private void buttonAuthorization_Click(object sender, EventArgs e) { if (textBoxLogin.Text != "") { var users = model.UserSet.Where(u => u.Name.Contains(textBoxLogin.Text)).ToList(); if (users.Count > 0) { if (textBoxPassword.Text == users[0].Password) { if (users[0].Privelege.Available) { FormAdminMainMenu newForm = new FormAdminMainMenu(); newForm.ParentAuthorization = this; newForm.Show(); Hide(); } else { FormUserMainMenu newForm = new FormUserMainMenu(); newForm.ParentAuthorization = this; newForm.Show(); Hide(); } } else { MessageBox.Show("Пароль неверен"); } } else { MessageBox.Show("Пользователь не найден"); } } else { MessageBox.Show("Пользователь не найден"); } textBoxPassword.Text = ""; }