Exemplo n.º 1
0
        protected void btnConfirmar_Click(object sender, EventArgs e)
        {
            if (UsuarioLogado == null) //novo usuario
            {
                string senha = NegocioSenha.GerarMD5(edtSenha.Text);

                if (NegocioSenha.ComparaMd5Hash(edtConfirmarSenha.Text, senha))
                {
                    try
                    {
                        Usuario usuario = new Usuario();
                        usuario.NomeUsuario = edtNome.Text;
                        usuario.Email       = edtEmail.Text;
                        usuario.SetSenha(edtSenha.Text);

                        Negocio.AdicionaUsuario(usuario);
                        Session["UsuarioLogado"] = usuario;
                        this.Response.Redirect("Livros.aspx");
                    }
                    catch (Exception ex)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "mensagem", string.Format("Alerta('{0}');", ex.Message), true);
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "mensagem", string.Format("Alerta('{0}');", "A senha e a confirmação de senha precisam ser iguais."), true);
                }
            }
        }
Exemplo n.º 2
0
 public void SetSenha(string senha)
 {
     this.Senha = NegocioSenha.GerarMD5(senha);
 }