private void Retrieve()
    {
        trReal.Visible = true;
        t11_financeiro t11 = new t11_financeiro();
        {
            t11.t11_cd_financeiro = Int32.Parse(cod.Value);
            t11.Retrieve();
            if (t11.Found)
            {
                //FormBind(" and t05_cd_parceiro not in (select t05_cd_parceiro from t11_financeiro where t08_cd_acao=" + pb.cd_acao() + " and t05_cd_parceiro<>" + t11.t05_cd_parceiro + ")");
                FormBind("");
                ListItem li = ddlt05_cd_parceiro.Items.FindByValue(t11.t05_cd_parceiro.ToString());
                if (li != null) li.Selected = true;
                li = rblfl_economico.Items.FindByValue(t11.fl_economico.ToString());
                if (li != null) li.Selected = true;

                t08_acao t08 = new t08_acao();
                {
                    t08.t08_cd_acao = pb.cd_acao();
                    t08.Retrieve();
                    if (t08.Found)
                    {
                        t28_vlfinanceiro t28 = new t28_vlfinanceiro();
                        {
                            for (int i = t08.dt_inicio.Year; i <= t08.dt_fim.Year; i++)
                            {
                                t28.t11_cd_financeiro = t11.t11_cd_financeiro;
                                t28.nu_ano = i;
                                t28.Retrieve();

                                TextBox txtvl_p1 = (TextBox)ucPrevisto.FindControl("txtvl_p1" + i.ToString());
                                TextBox txtvl_p4 = (TextBox)ucPrevisto.FindControl("txtvl_p2" + i.ToString());
                                TextBox txtvl_p8 = (TextBox)ucPrevisto.FindControl("txtvl_p3" + i.ToString());
                                TextBox txtvl_p12 = (TextBox)ucPrevisto.FindControl("txtvl_p4" + i.ToString());

                                TextBox txtvl_r1 = (TextBox)ucRealizado.FindControl("txtvl_r1" + i.ToString());
                                TextBox txtvl_r4 = (TextBox)ucRealizado.FindControl("txtvl_r2" + i.ToString());
                                TextBox txtvl_r8 = (TextBox)ucRealizado.FindControl("txtvl_r3" + i.ToString());
                                TextBox txtvl_r12 = (TextBox)ucRealizado.FindControl("txtvl_r4" + i.ToString());

                                if (t28.Found)
                                {
                                    if (txtvl_p1 != null)
                                    {
                                        txtvl_p1.Text = t28.vl_p1.ToString("N2");
                                        txtvl_p4.Text = t28.vl_p4.ToString("N2");
                                        txtvl_p8.Text = t28.vl_p8.ToString("N2");
                                        txtvl_p12.Text = t28.vl_p12.ToString("N2");
                                    }
                                    if (txtvl_r1 != null)
                                    {
                                        txtvl_r1.Text = t28.vl_r1.ToString("N2");
                                        txtvl_r4.Text = t28.vl_r4.ToString("N2");
                                        txtvl_r8.Text = t28.vl_r8.ToString("N2");
                                        txtvl_r12.Text = t28.vl_r12.ToString("N2");
                                    }
                                }
                                else
                                {
                                    if (txtvl_p1 != null)
                                    {
                                        txtvl_p1.Text = "0";
                                        txtvl_p4.Text = "0";
                                        txtvl_p8.Text = "0";
                                        txtvl_p12.Text = "0";
                                    }
                                    if (txtvl_r1 != null)
                                    {
                                        txtvl_r1.Text = "0";
                                        txtvl_r4.Text = "0";
                                        txtvl_r8.Text = "0";
                                        txtvl_r12.Text = "0";
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        bool redirect = false;
        int cd=0;
        try
        {
            GridView gv = (GridView)sender;
            if (e.CommandName != "Sort")
            {
                cd = Int32.Parse(gv.DataKeys[Int32.Parse(e.CommandArgument.ToString())].Value.ToString());
                switch (e.CommandName.Trim())
                {
                    case "Selecionar":
                        redirect = true;
                        break;
                    case "Editar":
                        Exibir();
                        this.lblHeader.Text = "Alteração";
                        this.btnAcao.Text = "Alterar";
                        cod.Value = cd.ToString();
                        Retrieve();

                        break;
                    case "Deletar":
                        t11_financeiro t11 = new t11_financeiro();
                        {
                            t11.t11_cd_financeiro = cd;
                            t11.Delete();
                            pb.saveLog(pb.cd_usuario(), pb.cd_projeto(), "", "t11_financeiro", "delete", t11.t11_cd_financeiro.ToString());
                        }
                        t28_vlfinanceiro t28 = new t28_vlfinanceiro();
                        {
                            t28.t11_cd_financeiro = cd;
                            t28.Delete();
                        }
                        GridBind();
                        lblMsg.Text = pb.Message("Exclusão realizada com sucesso!", "ok");
                        lblMsg.Visible = true;
                        break;
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        if (redirect)
        {
            Context.Items["t11_cd_financeiro"] = cd.ToString();
            Server.Transfer("Financeiro.aspx", false);
        }
    }
    protected void btnAcao_Click(object sender, System.EventArgs e)
    {
        t11_financeiro t11 = new t11_financeiro();
        {
            bool result = false;
            bool erro = false;
            string msg = "";
            t11.t08_cd_acao = pb.cd_acao();
            t11.t05_cd_parceiro = Int32.Parse(ddlt05_cd_parceiro.SelectedValue);
            t11.dt_cadastro = DateTime.Now;
            t11.dt_alterado = DateTime.Now;
          // LEVI  t11.fl_economico = bool.Parse(rblfl_economico.SelectedValue);
            if (!(erro))
            {
                if (cod.Value != "0")
                {
                    t11.t11_cd_financeiro = Int32.Parse(cod.Value);
                    result = t11.Update();
                    msg = pb.Message("Alteração realizada com sucesso!", "ok");
                    pb.saveLog(pb.cd_usuario(), pb.cd_projeto(), "", "t11_financeiro", "update", cod.Value);
                }
                else
                {
                    result = t11.Save();
                    msg = pb.Message("Cadastro realizado com sucesso!", "ok");
                    pb.saveLog(pb.cd_usuario(), pb.cd_projeto(), "", "t11_financeiro", "insert", t11.nu_ano.ToString());
                }

                if (result)
                {
                    t28_vlfinanceiro t28 = new t28_vlfinanceiro();
                    {
                        t08_acao t08 = new t08_acao();
                        {
                            t08.t08_cd_acao = pb.cd_acao();
                            t08.Retrieve();
                            if (t08.Found)
                            {
                                if (trReal.Visible)
                                {
                                    t28.t11_cd_financeiro = Int32.Parse(cod.Value.ToString());
                                }
                                else
                                {
                                    t11.RetrieveCod();
                                    if (t11.Found) t28.t11_cd_financeiro = t11.t11_cd_financeiro;
                                }
                                t28.Delete();
                                for (int i = t08.dt_inicio.Year; i <= t08.dt_fim.Year; i++)
                                {
                                    TextBox txtvl_p1 = (TextBox)ucPrevisto.FindControl("txtvl_p1" + i.ToString());
                                    TextBox txtvl_p4 = (TextBox)ucPrevisto.FindControl("txtvl_p2" + i.ToString());
                                    TextBox txtvl_p8 = (TextBox)ucPrevisto.FindControl("txtvl_p3" + i.ToString());
                                    TextBox txtvl_p12 = (TextBox)ucPrevisto.FindControl("txtvl_p4" + i.ToString());

                                    TextBox txtvl_r1 = (TextBox)ucRealizado.FindControl("txtvl_r1" + i.ToString());
                                    TextBox txtvl_r4 = (TextBox)ucRealizado.FindControl("txtvl_r2" + i.ToString());
                                    TextBox txtvl_r8 = (TextBox)ucRealizado.FindControl("txtvl_r3" + i.ToString());
                                    TextBox txtvl_r12 = (TextBox)ucRealizado.FindControl("txtvl_r4" + i.ToString());

                                    if (txtvl_p1 != null)
                                    {
                                        if (txtvl_p1.Text == "") txtvl_p1.Text = "0";
                                        if (txtvl_p4.Text == "") txtvl_p4.Text = "0";
                                        if (txtvl_p8.Text == "") txtvl_p8.Text = "0";
                                        if (txtvl_p12.Text == "") txtvl_p12.Text = "0";

                                        t28.nu_ano = i;
                                        t28.vl_p1 = Decimal.Parse(txtvl_p1.Text);
                                        t28.vl_p4 = Decimal.Parse(txtvl_p4.Text);
                                        t28.vl_p8 = Decimal.Parse(txtvl_p8.Text);
                                        t28.vl_p12 = Decimal.Parse(txtvl_p12.Text);
                                        if (trReal.Visible)
                                        {
                                            if (txtvl_r1.Text == "") txtvl_r1.Text = "0";
                                            if (txtvl_r4.Text == "") txtvl_r4.Text = "0";
                                            if (txtvl_r8.Text == "") txtvl_r8.Text = "0";
                                            if (txtvl_r12.Text == "") txtvl_r12.Text = "0";
                                            t28.vl_r1 = Decimal.Parse(txtvl_r1.Text);
                                            t28.vl_r4 = Decimal.Parse(txtvl_r4.Text);
                                            t28.vl_r8 = Decimal.Parse(txtvl_r8.Text);
                                            t28.vl_r12 = Decimal.Parse(txtvl_r12.Text);
                                        }
                                        t28.Save();
                                        if (txtvl_p1 != null)
                                        {
                                            txtvl_p1.Text = "0";
                                            txtvl_p4.Text = "0";
                                            txtvl_p8.Text = "0";
                                            txtvl_p12.Text = "0";
                                        }
                                        if (txtvl_r1 != null)
                                        {
                                            txtvl_r1.Text = "0";
                                            txtvl_r4.Text = "0";
                                            txtvl_r8.Text = "0";
                                            txtvl_r12.Text = "0";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    Ocultar();
                    GridBind();
                    cod.Value = "0";
                }
            }
            lblMsg.Text = msg;
            lblMsg.Visible = true;
        }
    }
示例#4
0
    private void Retrieve(int cod)
    {
        t11_financeiro t11 = new t11_financeiro();
        {
            t11.t11_cd_financeiro = cod;
            t11.Retrieve();
            if (t11.Found)
            {
                if (t11.fl_economico)
                {
                    lbltipo.Text = "Econômico";
                }
                else
                {
                    lbltipo.Text = "Financeiro";
                }
                t05_parceiro t05 = new t05_parceiro();
                {
                    t05.t05_cd_parceiro = t11.t05_cd_parceiro;
                    t05.Retrieve();
                    if (t05.Found)
                    { lblnm_parceiro.Text = t05.nm_parceiro; }
                }
                t08_acao t08 = new t08_acao();
                {
                    t08.t08_cd_acao = pb.cd_acao();
                    t08.Retrieve();
                    if (t08.Found)
                    {
                        lblnm_acao.Text = t08.nm_acao;
                        t28_vlfinanceiro t28 = new t28_vlfinanceiro();
                        {
                            for (int i = t08.dt_inicio.Year; i <= t08.dt_fim.Year; i++)
                            {
                                t28.t11_cd_financeiro = t11.t11_cd_financeiro;
                                t28.nu_ano = i;
                                t28.Retrieve();

                                TextBox txtvl_p1 = (TextBox)ucPrevisto.FindControl("txtvl_p1" + i.ToString());
                                TextBox txtvl_p4 = (TextBox)ucPrevisto.FindControl("txtvl_p2" + i.ToString());
                                TextBox txtvl_p8 = (TextBox)ucPrevisto.FindControl("txtvl_p3" + i.ToString());
                                TextBox txtvl_p12 = (TextBox)ucPrevisto.FindControl("txtvl_p4" + i.ToString());
                                TextBox txtvl_ptotal = (TextBox)ucPrevisto.FindControl("txtvl_ptotal5" + i.ToString());

                                TextBox txtvl_r1 = (TextBox)ucRealizado.FindControl("txtvl_r1" + i.ToString());
                                TextBox txtvl_r4 = (TextBox)ucRealizado.FindControl("txtvl_r2" + i.ToString());
                                TextBox txtvl_r8 = (TextBox)ucRealizado.FindControl("txtvl_r3" + i.ToString());
                                TextBox txtvl_r12 = (TextBox)ucRealizado.FindControl("txtvl_r4" + i.ToString());
                                TextBox txtvl_rtotal = (TextBox)ucRealizado.FindControl("txtvl_rtotal5" + i.ToString());

                                if (t28.Found)
                                {
                                    if (txtvl_p1 != null)
                                    {
                                        txtvl_p1.Text = t28.vl_p1.ToString("N2");
                                        txtvl_p4.Text = t28.vl_p4.ToString("N2");
                                        txtvl_p8.Text = t28.vl_p8.ToString("N2");
                                        txtvl_p12.Text = t28.vl_p12.ToString("N2");
                                        txtvl_ptotal.Text = (t28.vl_p1 + t28.vl_p4 + t28.vl_p8 + t28.vl_p12).ToString("N2");
                                    }
                                    if (txtvl_r1 != null)
                                    {
                                        txtvl_r1.Text = t28.vl_r1.ToString("N2");
                                        txtvl_r4.Text = t28.vl_r4.ToString("N2");
                                        txtvl_r8.Text = t28.vl_r8.ToString("N2");
                                        txtvl_r12.Text = t28.vl_r12.ToString("N2");
                                        txtvl_rtotal.Text = (t28.vl_r1 + t28.vl_r4 + t28.vl_r8 + t28.vl_r12).ToString("N2");
                                    }
                                }
                                else
                                {
                                    if (txtvl_p1 != null)
                                    {
                                        txtvl_p1.Text = "0,00";
                                        txtvl_p4.Text = "0,00";
                                        txtvl_p8.Text = "0,00";
                                        txtvl_p12.Text = "0,00";
                                    }
                                    if (txtvl_r1 != null)
                                    {
                                        txtvl_r1.Text = "0,00";
                                        txtvl_r4.Text = "0,00";
                                        txtvl_r8.Text = "0,00";
                                        txtvl_r12.Text = "0,00";
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }