Example #1
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            if (usuario.primeiroAcesso())
            {
                usuario.setarSenhas("", "");
            }

            if (!txtSenhaNova.Text.Equals(txtSenhaConfirmacao.Text))
            {
                lblMsg.Text = "Senha de confirmação diferente da senha informada";
                BackColor   = Color.Red.Soft;
            }
            else if (txtSenhaNova.Text == "")
            {
                lblMsg.Text = "Senha nova em branco";
                BackColor   = Color.Red.Soft;
            }
            else if (usuario.validar(txtSenhaAntiga.Text, (DAO.TipoUsuario)cmbUsuario.SelectedItem))
            {
                usuario.alterarSenha(txtSenhaAntiga.Text, txtSenhaNova.Text, (DAO.TipoUsuario)cmbUsuario.SelectedItem);
                txtSenhaAntiga.Visible = !usuario.validar("", (DAO.TipoUsuario)cmbUsuario.SelectedItem);
                lblSenhaAntiga.Visible = txtSenhaAntiga.Visible;

                txtSenhaAntiga.Text      = "";
                txtSenhaNova.Text        = "";
                txtSenhaConfirmacao.Text = "";

                BackColor   = Color.Green.Hard;
                lblMsg.Text = "Senha alterada com sucesso";
            }
            else
            {
                lblMsg.Text = "Senha antiga inválida";
                BackColor   = Color.Red.Soft;
            }
        }