示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["cod_usuario"] == null)
            {
                Response.Redirect("login.aspx");
            }

            Label1.Text = "OLÁ " + (string)Session["nome"];

            var dados = new DAO.ClienteDAO().GetClientes();

            GridView1.DataSource = dados;
            GridView1.DataBind();
        }
示例#2
0
        protected void BtnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                var cod = Convert.ToInt32(InputCodigo.Text);

                using (var dao = new DAO.ClienteDAO())
                {
                    dao.Delete(cod);
                }
                BtnVoltar_Click(null, null);
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }
        }
示例#3
0
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                using (var dao = new DAO.ClienteDAO())
                {
                    var cli = CarregarCliente();

                    dao.Insert(cli);
                }
                BtnVoltar_Click(null, null);
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }
        }
示例#4
0
        protected void BtnAlterar_Click(object sender, EventArgs e)
        {
            try
            {
                var cli = CarregarCliente();
                cli.cod_cliente = Convert.ToInt32(InputCodigo.Text);

                using (var dao = new DAO.ClienteDAO())
                {
                    dao.Update(cli);
                }
                BtnVoltar_Click(null, null);
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }
        }
示例#5
0
 protected void BtnPesquisar_Click(object sender, EventArgs e)
 {
     try
     {
         using (var dao = new DAO.ClienteDAO())
         {
             var codigo = Convert.ToInt32(InputCodigo.Text);
             if (dao.GetCliente(codigo) is Models.Cliente cli)
             {
                 InputNome.Text     = cli.nome;
                 InputCpf.Text      = cli.cpf;
                 InputEmail2.Text   = cli.email;
                 InputTel.Text      = cli.telefone;
                 opS.Checked        = cli.ativo;
                 opsN.Checked       = !cli.ativo;
                 InputEndereco.Text = cli.endereco;
             }
         }
     }
     catch (Exception)
     {
     }
 }