private void btnConfirmar_Click(object sender, EventArgs e) { try { string criterioSenha = mtxtSenhaAntiga.Text; criterioUsuario = modelf.Login; DataTable dtFuncionario = daof.consultar(criterioUsuario, criterioSenha).Tables["funcionario"]; // Valida o Login if (dtFuncionario.Rows.Count >= 1) { lblErroLogin.Visible = false; if (mtxtSenhaAntiga.Text == string.Empty || mtxtNovaSenha.Text == string.Empty) { MessageBox.Show("Nenhum campo pode ficar em branco", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error); if (mtxtSenhaAntiga.Text == string.Empty) { mtxtSenhaAntiga.BackColor = Color.Red; mtxtSenhaAntiga.Focus(); } else if (mtxtNovaSenha.Text == string.Empty) { mtxtNovaSenha.BackColor = Color.Red; mtxtNovaSenha.Focus(); } } else if (!mtxtNovaSenha.Text.Equals(mtxtCNovaSenha.Text)) { MessageBox.Show("Senhas Diferentes", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error); //mtxtNovaSenha.Clear(); mtxtCNovaSenha.Clear(); mtxtCNovaSenha.Focus(); } else { modelf.Senha = mtxtNovaSenha.Text; daof.alteracaoSenha(modelf); if (MessageBox.Show("Senha Alterada com Sucesso", "Senha Alterada", MessageBoxButtons.OK, MessageBoxIcon.Question) == DialogResult.OK) { this.Visible = false; } } } else { MessageBox.Show("Senha Antiga Invalida", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error); mtxtSenhaAntiga.Clear(); mtxtSenhaAntiga.Focus(); lblErroLogin.Visible = true; } } catch (Exception ex) { MessageBox.Show("Erro é\n" + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnEntrar_Click(object sender, EventArgs e) { try { string criterioSenha = txtSenha.Text; string criterioUsuario = txtUsuario.Text; DataTable dtFuncionario = daof.consultar(criterioUsuario, criterioSenha).Tables["funcionario"]; // Valida o Login if (dtFuncionario.Rows.Count >= 1) { for (int i = 0; i < dtFuncionario.Rows.Count; i++) { DataRow linha = dtFuncionario.Rows[0]; codFun = Convert.ToInt32(linha["codigoFuncionario"].ToString()); nome = linha["nome"].ToString(); adm = Convert.ToBoolean(linha["nivel"].ToString()); } NotMedPark.ShowBalloonTip(5, "Bem Vindo!", "Seja Bem Vindo ao MedPark " + nome + ", Software para gestão de Estacionamento.", NotMedPark.BalloonTipIcon); // Autentica this.Hide(); this.Visible = false; Home telaHome = new Home(adm, codFun); telaHome.ShowDialog(); } // Usuario Padrão - Para primeiro acesso (Caso não tenha funcionario cadastrado) else if (criterioUsuario == "admin" && criterioSenha == "admin") { this.Hide(); this.Visible = false; Home telaHome = new Home(true, 0); telaHome.ShowDialog(); } else { // Erro Login lblErroLogin.Visible = true; txtUsuario.Clear(); txtSenha.Clear(); // txtUsuario.BackColor = Color.FromArgb(255, 121, 121); txtUsuario.BackColor = Color.Red; // txtSenha.BackColor = Color.FromArgb(255, 121, 121); txtSenha.BackColor = Color.Red; txtUsuario.Focus(); } } catch (Exception ex) { MessageBox.Show("Erro é\n" + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }