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); } }