Exemple #1
0
    protected void btnEditSenhaConfirmar_Click(object sender, EventArgs e)
    {
        if (txbNovaSenha.Text != txbConfirmarSenha.Text)
        {
            lblErro.Text = "* Os campos Nova Senha e Digite Novamente devem ser iguais";
            return;
        }

        Usuario userValid   = new Usuario();
        var     EstabLogado = (Estabelecimento)Session["ObjEst"];

        userValid = UsuarioDB.SelectByEstabelecimento(EstabLogado);

        UsuarioCrypto user            = new UsuarioCrypto();
        UsuarioCrypto userNewPassword = new UsuarioCrypto();

        user.Senha            = txbSenha.Text;
        user.Codigo           = userValid.Codigo;
        userNewPassword.Senha = txbNovaSenha.Text;

        if (!UsuarioDB.SenhaIsValid(user))
        {
            lblErro.Text = "* Campo Senha está incorreto";
            return;
        }

        userValid.Senha = userNewPassword.Senha;

        if (UsuarioDB.UpdateSenha(userValid) != -2)
        {
            Response.Redirect("/estabelecimento/" + EstabLogado.Codigo + "?n=b");
        }
        else
        {
            Response.Redirect("/editar/conta?n=B");
        }
    }