Esempio n. 1
0
        protected void enviarButton_Click1(object sender, EventArgs e)
        {
            try
            {
                Usuario usuario = UsuariosDao.ValidarUsuario(
                    usuarioTextBox.Text,
                    senhaTextBox.Text);

                if (usuario == null)

                {
                    throw new Exception("Usuário ou senha inválidos");
                }

                Session["sessao_usuario"] = usuario;
                //Session.Add("sessao_usuario", usuario);

                Response.Redirect("Home.aspx");
            }
            catch (Exception ex)
            {
                mensagemLabel.CssClass = "alert alert-danger";
                mensagemLabel.Text     = ex.Message;
            }
        }
 protected void enviarButton_Click(object sender, EventArgs e)
 {
     try
     {
         Usuario usuario = UsuariosDao.ValidarUsuario(usuarioTextBox.Text, senhaTexrBox.Text);
         if (usuario == null)
         {
             throw new Exception("Usuário ou senha inválidos");
         }
         Session["sessao_usuario"] = usuario ?? throw new Exception("Usuário ou senha inválidos");
         //Session.Add("sessao_usuario", usuario);
         Response.Redirect("Home.aspx");
         //mensagemLabel.CssClass = "alert alert-success";
         //mensagemLabel.Text = "Usuário <strong>" + usuario.Nome + "</strong> incluido com sucesso";
     }
     catch (Exception ex)
     {
         mensagemLabel.CssClass = "alert alert-danger";
         mensagemLabel.Text     = ex.Message;
         //throw;
     }
 }