private void Button_Entrar(object sender, RoutedEventArgs e) { string nome = txtUsuario.Text; string senha = txtSenha.Password; bool logou = false; if (nome == "Admin" && senha == "123") { logou = true; AdministradorWindow w = new AdministradorWindow(); w.Show(); Close(); } NAluno n = new NAluno(); foreach (Aluno a in n.Listar()) { if (nome == a.Nome && senha == Criptografia.Descriptografar(a.Senha)) { logou = true; AlunoWindow w = new AlunoWindow(a); w.Show(); Close(); } } if (!logou) { MessageBox.Show("Senha ou usuário inválido"); } }
public static bool VerificarSenha(ref int p, string n, string s, ref MAluno u, ref MProfessor a) { bool r = false; if (n == "Admin") { r = s == "admin"; p = 0; } if (r == false) { NProfessor f = new NProfessor(); List <MProfessor> lis = f.ListarProfessor(); foreach (MProfessor x in lis) { if (x.Matricula == n && s == x.Senha) { r = true; p = 2; a = x; break; } } } if (r == false) { NAluno e = new NAluno(); List <MAluno> b = e.ListarAluno(); foreach (MAluno x in b) { if (x.Matricula == n && s == x.Senha) { r = true; p = 1; u = x; break; } } } return(r); }