Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                if (!IsPostBack)
                {
                    if (!IsPostBack)
                    {
                        DataTable cat = geren_bd.getdados("select cod,nome_cli from clientes");
                        DropDownListcli.DataSource = cat;
                        DropDownListcli.DataBind();
                        cat = geren_bd.getdados("select cod,nome_pro from produto");
                        DropDownListpro.DataSource = cat;
                        DropDownListpro.DataBind();

                        DataTable pro = geren_bd.getdados("select * from vendasview");
                        GridViewven.DataSource = pro;
                        /*GridViewcat.DataBind();*/
                        Pesquisar(pro, "vendasview");
                        if (!string.IsNullOrEmpty(Request.QueryString["cod"]))
                        {
                            string    comando = "select * from vendas where cod=" + Request.QueryString["cod"];
                            DataTable tabela  = geren_bd.getdados(comando);
                            if (tabela.Rows.Count > 0)
                            {
                                codigo.Text = tabela.Rows[0].ItemArray[0].ToString();
                                DropDownListcli.SelectedValue = tabela.Rows[0].ItemArray[1].ToString();
                                DropDownListpro.SelectedValue = tabela.Rows[0].ItemArray[2].ToString();
                                qtd.Text   = tabela.Rows[0].ItemArray[3].ToString();
                                preco.Text = tabela.Rows[0].ItemArray[4].ToString();
                            }
                        }
                        else
                        {
                            //verificr edição
                            if (!string.IsNullOrEmpty(Request.QueryString["del"]))
                            {
                                geren_bd.excluir("vendas", Request.QueryString["del"]);
                                Response.Redirect("vendas.aspx", false);
                            }
                        }

                        //carregando caixa listagem
                    }
                }
            }
            catch
            {
                Response.Redirect("~/Default.aspx", false);
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                if (!IsPostBack)
                {
                    DataTable vai = new DataTable();
                    vai.Columns.Add(new DataColumn("bd", typeof(char)));
                    vai.Columns.Add(new DataColumn("sexoid", typeof(string)));

                    // Populate the table with sample values.
                    vai.Rows.Add(CreateRow('m', "Masculino", vai));
                    vai.Rows.Add(CreateRow('f', "Feminino", vai));

                    DropDownListcli.DataSource = vai;
                    DropDownListcli.DataBind();
                    DataTable uf = new DataTable();
                    uf.Columns.Add(new DataColumn("id", typeof(int)));
                    uf.Columns.Add(new DataColumn("uf", typeof(string)));

                    // Populate the table with sample values.
                    uf.Rows.Add(CreateRow(1, "AC", uf));
                    uf.Rows.Add(CreateRow(2, "AL", uf));
                    uf.Rows.Add(CreateRow(3, "AP", uf));
                    uf.Rows.Add(CreateRow(4, "AM", uf));
                    uf.Rows.Add(CreateRow(5, "BA", uf));
                    uf.Rows.Add(CreateRow(6, "CE", uf));
                    uf.Rows.Add(CreateRow(7, "DF", uf));
                    uf.Rows.Add(CreateRow(8, "ES", uf));
                    uf.Rows.Add(CreateRow(9, "GO", uf));
                    uf.Rows.Add(CreateRow(10, "MA", uf));
                    uf.Rows.Add(CreateRow(11, "MT", uf));
                    uf.Rows.Add(CreateRow(12, "MS", uf));
                    uf.Rows.Add(CreateRow(13, "MG", uf));
                    uf.Rows.Add(CreateRow(14, "PA", uf));
                    uf.Rows.Add(CreateRow(15, "PB", uf));
                    uf.Rows.Add(CreateRow(16, "PR", uf));
                    uf.Rows.Add(CreateRow(17, "PE", uf));
                    uf.Rows.Add(CreateRow(18, "PI", uf));
                    uf.Rows.Add(CreateRow(19, "RJ", uf));
                    uf.Rows.Add(CreateRow(20, "RN", uf));
                    uf.Rows.Add(CreateRow(21, "RS", uf));
                    uf.Rows.Add(CreateRow(22, "RO", uf));
                    uf.Rows.Add(CreateRow(23, "RR", uf));
                    uf.Rows.Add(CreateRow(24, "SC", uf));
                    uf.Rows.Add(CreateRow(25, "SP", uf));
                    uf.Rows.Add(CreateRow(26, "SE", uf));
                    uf.Rows.Add(CreateRow(27, "TO", uf));

                    DropDownListcliuf.DataSource = uf;
                    DropDownListcliuf.DataBind();

                    DataTable tipo_end = new DataTable();
                    tipo_end.Columns.Add(new DataColumn("id", typeof(int)));
                    tipo_end.Columns.Add(new DataColumn("tipo", typeof(string)));

                    // Populate the table with sample values.
                    tipo_end.Rows.Add(CreateRow(1, "Cobrança", tipo_end));
                    tipo_end.Rows.Add(CreateRow(2, "Entrega", tipo_end));

                    DropDownList_tipo_end.DataSource = tipo_end;
                    DropDownList_tipo_end.DataBind();
                    if (Session["car_cache"] == null)
                    {
                        Session["car_cache"] = new List <Cartao_Credito>();
                    }
                    if (Session["end_cache"] == null)
                    {
                        Session["end_cache"] = new List <Endereco>();
                    }
                    Pesquisar();
                    if (!string.IsNullOrEmpty(Request.QueryString["cod"]))
                    {
                        categoria.Id         = Convert.ToInt32(Request.QueryString["cod"]);
                        res                  = commands["CONSULTAR"].execute(categoria);
                        categoria            = (Cliente)res.Entidades.ElementAt(0);
                        Session["cli"]       = categoria;
                        cache_car            = categoria.Cartoes;
                        Session["car_cache"] = cache_car;
                        PesquisarCartao_Credito();
                        cache_end            = categoria.Enderecos;
                        Session["end_cache"] = cache_end;
                        PesquisarEnderecos();
                        codigo.Text = categoria.Id.ToString();
                        senha.Text  = categoria.usuario.Password;
                        nome.Text   = categoria.Nome;
                        cpf.Text    = categoria.Cpf;
                        rg.Text     = categoria.Rg;
                        data.Text   = categoria.Dt_Nas.ToString("yyyy-MM-dd");
                        email.Text  = categoria.usuario.Login;
                        for (int j = 0; j < DropDownListcli.Items.Count; j++)
                        {
                            if (categoria.Sexo.ToString() == DropDownListcli.Items[j].Value)
                            {
                                DropDownListcli.Items[j].Selected = true;
                            }
                        }
                    }



                    else
                    {
                        //verificr edição
                        if (!string.IsNullOrEmpty(Request.QueryString["del"]))
                        {
                            categoria.Id = Convert.ToInt32(Request.QueryString["del"]);
                            commands["EXCLUIR"].execute(categoria);
                            Response.Redirect("clientes.aspx", false);
                        }
                        else if (!string.IsNullOrEmpty(Request.QueryString["del_end"]))
                        {
                            cache_end = (List <Endereco>)Session["end_cache"];
                            int a = Convert.ToInt32(Request.QueryString["del_end"]);
                            for (int i = 0; i < cache_end.Count; i++)
                            {
                                if (a == cache_end.ElementAt(i).Id)
                                {
                                    cache_end.RemoveAt(i);
                                    Session["end_cache"] = cache_end;
                                    PesquisarEnderecos();
                                    categoria.Enderecos  = cache_end;
                                    Session["cli"]       = categoria;
                                    cache_car            = categoria.Cartoes;
                                    Session["car_cache"] = cache_car;
                                    PesquisarCartao_Credito();
                                    codigo.Text = categoria.Id.ToString();
                                    senha.Text  = categoria.usuario.Password;
                                    nome.Text   = categoria.Nome;
                                    cpf.Text    = categoria.Cpf;
                                    rg.Text     = categoria.Rg;
                                    data.Text   = categoria.Dt_Nas.ToString("yyyy-MM-dd");
                                    email.Text  = categoria.usuario.Login;
                                    for (int j = 0; j < DropDownListcli.Items.Count; j++)
                                    {
                                        if (categoria.Sexo.ToString() == DropDownListcli.Items[j].Value)
                                        {
                                            DropDownListcli.Items[j].Selected = true;
                                        }
                                    }
                                }
                            }
                        }
                        else if (!string.IsNullOrEmpty(Request.QueryString["del_car"]))
                        {
                            cache_car = (List <Cartao_Credito>)Session["car_cache"];
                            int a = Convert.ToInt32(Request.QueryString["del_car"]);
                            for (int i = 0; i < cache_car.Count; i++)
                            {
                                if (a == cache_car.ElementAt(i).Id)
                                {
                                    cache_car.RemoveAt(i);
                                    Session["car_cache"] = cache_car;
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                Response.Redirect("~/Default.aspx", false);
            }
        }