Esempio n. 1
0
        public void MakeReport(Object Sender, EventArgs E)
        {
            DatasForReport balPru = new DatasForReport(reportTitle);

            ds = balPru.GetDatas(false, GetParams());

            Press frontEnd = new Press(ds, reportTitle);

            frontEnd.PreHeader(tabPreHeader, report.Width, pr);
            frontEnd.Firmas(tabFirmas, report.Width);
            frontEnd.SourceFieldTitles(balPru.PressFields);

            tbReport = frontEnd.TbReport;

            decimal subtotal = 0, total = 0;
            string  cVal, aVal;

            DataRow[] rows;
            //Operations op = new Operations(ds, balPru.Operations);
            //op.Executer();
            //reportInfo.Text += op.InfoProcess;

            for (i = 0; i < ds.Tables[1].Rows.Count; i++)
            {
                dr = tbReport.NewRow();
                tbReport.Rows.Add(dr);
                cVal  = ds.Tables[1].Rows[i][0].ToString();
                dr[0] = cVal;
                dr[1] = ds.Tables[1].Rows[i][1];

                rows = ds.Tables[0].Select("MCUE_CODIPUC = '" + cVal.Substring(0, 4) + "'");
                if (rows[0][2].ToString() == "D")
                {
                    dr[2] = (Decimal)ds.Tables[1].Rows[i][2];
                }
                else
                {
                    dr[5] = (Decimal)ds.Tables[1].Rows[i][2];
                }

                subtotal += (Decimal)Convert.ToDecimal(ds.Tables[1].Rows[i][2]);

                if (i != ds.Tables[1].Rows.Count - 1)
                {
                    aVal = ds.Tables[1].Rows[i + 1][0].ToString();
                    if (cVal.Substring(0, 4) != aVal.Substring(0, 4))
                    {
                        dr = tbReport.NewRow();
                        tbReport.Rows.Add(dr);
                        dr[0] = "TOTAL";
                        rows  = ds.Tables[0].Select("MCUE_CODIPUC = '" + cVal.Substring(0, 4) + "'");
                        dr[1] = rows[0][1];

                        if (rows[0][2].ToString() == "D")
                        {
                            dr[3] = subtotal;
                        }
                        else
                        {
                            dr[6] = subtotal;
                        }

                        total   += subtotal;
                        subtotal = 0;
                    }
                    if (cVal.Substring(0, 2) != aVal.Substring(0, 2))
                    {
                        dr = tbReport.NewRow();
                        tbReport.Rows.Add(dr);
                        dr[0] = "TOTAL";
                        rows  = ds.Tables[0].Select("MCUE_CODIPUC = '" + cVal.Substring(0, 2) + "'");
                        dr[1] = rows[0][1];

                        if (rows[0][2].ToString() == "D")
                        {
                            dr[4] = total;
                        }
                        else
                        {
                            dr[7] = total;
                        }

                        total = 0;
                    }
                }
                toolsHolder.Visible = true;
            }
            report.DataSource = ds.Tables[2];
            frontEnd.PressFieldTitles(report);
            report.DataBind();

            StringBuilder  SB     = new StringBuilder();
            StringWriter   SW     = new StringWriter(SB);
            HtmlTextWriter htmlTW = new HtmlTextWriter(SW);

            tabPreHeader.RenderControl(htmlTW);
            report.RenderControl(htmlTW);
            tabFirmas.RenderControl(htmlTW);
            string strRep;

            strRep = SB.ToString();
            Session.Clear();
            Session["Rep"]      = strRep;
            toolsHolder.Visible = true;
        }
Esempio n. 2
0
        public void MakeReport(Object Sender, EventArgs E)
        {
            DatasForReport balGen = new DatasForReport(reportTitle);

            ds = balGen.GetDatas(false, GetParams());
            //3 tablas:
            // 1. mcue_codipuc, mcue_nombre, tnat_codigo, timp_codigo FROM mcuenta
            // 2. mcuenta.mcue_codipuc as CODIGO, mcuenta.mcue_nombre as NOMBRE, parcial=msal_valodebi-msal_valocred o msal_valocred-msal_valodebi WHERE mcuenta.mcue_codipuc=msaldocuenta.mcue_codipuc AND msaldocuenta.pano_ano=@ AND msaldocuenta.pmes_mes<=@ AND mcuenta.timp_codigo in ('N','P','@') AND mcuenta.tcla_codigo='R'
            // 3. mauxiliarcuenta.mcue_codipuc as COD, mauxiliarcuenta.mnit_nit as NIT, mnit.mnit_nombres+mnit.mnit_apellidos as NOMBRE, DETALLE = mauxiliarcuenta.maux_valodebi-mauxiliarcuenta.maux_valocred o mauxiliarcuenta.maux_valocred-mauxiliarcuenta.maux_valodebi FROM mcuenta, mauxiliarcuenta, mnit WHERE mauxiliarcuenta.mnit_nit=mnit.mnit_nit AND mcuenta.mcue_codipuc=mauxiliarcuenta.mcue_codipuc AND mauxiliarcuenta.pano_ano=@ AND mauxiliarcuenta.pmes_mes<=@ AND mauxiliarcuenta.mnit_nit != '@'
            //reportInfo.Text=ds.Tables.Count.ToString();

            Press frontEnd = new Press(ds, reportTitle);

            frontEnd.PreHeader(tabPreHeader, report.Width, pr);
            frontEnd.Firmas(tabFirmas, report.Width);
            frontEnd.SourceFieldTitles(balGen.PressFields);
            tbReport = frontEnd.TbReport;
            ArrayList arC = new ArrayList();
            ArrayList arV = new ArrayList();

            DataRow[] rows;
            int       l;

            TCred = new double[10];
            TDeb  = new double[10];
            for (i = 0; i < 10; i++)
            {
                TCred[i] = 0; TDeb[i] = 0;
            }
            ;
            for (i = 0; i < ds.Tables[1].Rows.Count; i++)
            {
                Inserta(arC, ds.Tables[1].Rows[i][0].ToString(), Convert.ToDouble(ds.Tables[1].Rows[i][2]), arV);
                //Calcular Utilidades aca:
                //UBruta,UEjer,UOper

                /*if(Convert.ToInt16(ds.Tables[1].Rows[i][3])==1)UBruta+=Convert.ToDouble(ds.Tables[1].Rows[i][2]);
                 * if(Convert.ToInt16(ds.Tables[1].Rows[i][3])==2)UEjer+=Convert.ToDouble(ds.Tables[1].Rows[i][2]);
                 * if(Convert.ToInt16(ds.Tables[1].Rows[i][3])==3)UOper+=Convert.ToDouble(ds.Tables[1].Rows[i][2]);*/
                if (ds.Tables[1].Rows[i][4].ToString().ToUpper() == "D")
                {
                    TDeb[Convert.ToInt16(ds.Tables[1].Rows[i][0].ToString().Substring(0, 1))] += Convert.ToDouble(ds.Tables[1].Rows[i][2]);
                }
                if (ds.Tables[1].Rows[i][4].ToString().ToUpper() == "C")
                {
                    TCred[Convert.ToInt16(ds.Tables[1].Rows[i][0].ToString().Substring(0, 1))] += Convert.ToDouble(ds.Tables[1].Rows[i][2]);
                }
            }
            //arC.Sort();
            int tot = arC.Count;

            for (i = 0; i < tot; i++)
            {
                //reportInfo.Text+=arC[i].ToString()+"<br>";
                l  = arC[i].ToString().Length;
                dr = tbReport.NewRow();

                dr[0] = arC[i].ToString();
                rows  = ds.Tables[0].Select("MCUE_CODIPUC = '" + arC[i].ToString() + "'");
                if (rows.Length > 0)
                {
                    dr[1] = rows[0][1];
                }
                if (l < 3)
                {
                    dr[5] = ((double)arV[i]).ToString();
                }
                else
                {
                    if (l == 4)
                    {
                        dr[4] = ((double)arV[i]).ToString();
                    }
                    else
                    {
                        if (l == 6)
                        {
                            dr[3] = ((double)arV[i]).ToString();
                        }
                        else
                        {
                            dr[2] = ((double)arV[i]).ToString();
                        }
                    }
                }
                if (((double)arV[i]) != 0)
                {
                    tbReport.Rows.Add(dr);
                }
            }

            frontEnd.PressFieldTitles(report);
            DataView  dv    = frontEnd.SortWithNextField(3, 0);
            DataTable dtTmp = dv.Table;

            if (values[3] == "A")
            {
                report.DataSource = SetAux(dv, 0);
                report.DataBind();
            }
            else if (values[3] == "D")
            {
                report.DataSource = SetAux(dv, 14);
                report.DataBind();
            }
            else if (values[3] == "G")
            {
                report.DataSource = SetAux(dv, 6);
                report.DataBind();
            }
            else if (values[3] == "M")
            {
                report.DataSource = SetAux(dv, 4);
                report.DataBind();
            }
            StringBuilder  SB     = new StringBuilder();
            StringWriter   SW     = new StringWriter(SB);
            HtmlTextWriter htmlTW = new HtmlTextWriter(SW);

            tabPreHeader.RenderControl(htmlTW);
            report.RenderControl(htmlTW);
            tabFirmas.RenderControl(htmlTW);
            string strRep;

            strRep = SB.ToString();
            Session.Clear();
            Session["Rep"]      = strRep;
            toolsHolder.Visible = true;
        }
Esempio n. 3
0
        public void MakeReport(Object Sender, EventArgs E)
        {
            DatasForReport balComp = new DatasForReport(reportTitle);

            ds = balComp.GetDatas(false, GetParams());

            //3 tablas:
            // 1. mcue_codipuc, mcue_nombre, tnat_codigo, timp_codigo FROM mcuenta
            // 2. mcuenta.mcue_codipuc as CODIGO, mcuenta.mcue_nombre as NOMBRE, parcial=msal_valodebi-msal_valocred o msal_valocred-msal_valodebi WHERE mcuenta.mcue_codipuc=msaldocuenta.mcue_codipuc AND msaldocuenta.pano_ano=@ AND msaldocuenta.pmes_mes<=@ AND mcuenta.timp_codigo in ('N','P','@') AND mcuenta.tcla_codigo='R'
            // 3. mauxiliarcuenta.mcue_codipuc as COD, mauxiliarcuenta.mnit_nit as NIT, mnit.mnit_nombres+mnit.mnit_apellidos as NOMBRE, DETALLE = mauxiliarcuenta.maux_valodebi-mauxiliarcuenta.maux_valocred o mauxiliarcuenta.maux_valocred-mauxiliarcuenta.maux_valodebi FROM mcuenta, mauxiliarcuenta, mnit WHERE mauxiliarcuenta.mnit_nit=mnit.mnit_nit AND mcuenta.mcue_codipuc=mauxiliarcuenta.mcue_codipuc AND mauxiliarcuenta.pano_ano=@ AND mauxiliarcuenta.pmes_mes<=@ AND mauxiliarcuenta.mnit_nit != '@'
            //reportInfo.Text=ds.Tables.Count.ToString();
            Press frontEnd = new Press(ds, reportTitle);

            frontEnd.PreHeader(tabPreHeader, report.Width, pr);
            frontEnd.Firmas(tabFirmas, report.Width);
            frontEnd.SourceFieldTitles(balComp.PressFields);
            tbReport = frontEnd.TbReport;
            ArrayList arC0 = new ArrayList();
            ArrayList arC1 = new ArrayList();
            ArrayList arC2 = new ArrayList();
            ArrayList arV0 = new ArrayList();
            ArrayList arV1 = new ArrayList();
            ArrayList arV2 = new ArrayList();
            ArrayList arC  = null;
            ArrayList arV  = null;
            ArrayList arCT = new ArrayList();

            DataRow[] rows;
            int       ano, ai;

            ano = Convert.ToInt16(values[0]);
            for (i = 0; i < ds.Tables[1].Rows.Count; i++)
            {
                ai = ano - Convert.ToInt16(ds.Tables[1].Rows[i][4]);
                if (ai == 0)
                {
                    arC = arC0; arV = arV0;
                }
                if (ai == 1)
                {
                    arC = arC1; arV = arV1;
                }
                if (ai == 2)
                {
                    arC = arC2; arV = arV2;
                }
                Inserta(arC, ds.Tables[1].Rows[i][0].ToString(), Convert.ToDouble(ds.Tables[1].Rows[i][2]), arV, arCT);
                if (ds.Tables[1].Rows[i][3].ToString().ToUpper() == "D")
                {
                    TDeb += Convert.ToDouble(ds.Tables[1].Rows[i][2]);
                }
                if (ds.Tables[1].Rows[i][3].ToString().ToUpper() == "C")
                {
                    TCred += Convert.ToDouble(ds.Tables[1].Rows[i][2]);
                }
            }
            double v0, v1, v2;

            if (arCT.Count > 0)
            {
                for (i = 0; i < arCT.Count; i++)
                {
                    dr    = tbReport.NewRow();
                    dr[0] = arCT[i].ToString();
                    rows  = ds.Tables[0].Select("MCUE_CODIPUC = '" + arCT[i].ToString() + "'");
                    dr[1] = rows[0][1];
                    if (arC0.Contains(arCT[i]))
                    {
                        v0 = (double)arV0[i];
                    }
                    else
                    {
                        v0 = 0;
                    }
                    dr[2] = (v0).ToString();
                    if (arC1.Contains(arCT[i]))
                    {
                        v1 = (double)arV1[i];
                    }
                    else
                    {
                        v1 = 0;
                    }
                    dr[3] = (v1).ToString();
                    if (arC2.Contains(arCT[i]))
                    {
                        v2 = (double)arV2[i];
                    }
                    else
                    {
                        v2 = 0;
                    }
                    dr[4] = (v2).ToString();
                    if (v0 != 0)
                    {
                        dr[5] = (((v1 - v0) * 100) / v0).ToString(); // % Año 0-1
                        dr[6] = (((v2 - v0) * 100) / v0).ToString(); // % Año 0-2
                    }
                    else
                    {
                        dr[5] = "0.00";
                        dr[6] = "0.00";
                    }
                    if (!(v0 == 0 && v1 == 0 && v2 == 0))
                    {
                        tbReport.Rows.Add(dr);
                    }
                }
            }
            frontEnd.PressFieldTitles(report);
            DataView  dv    = frontEnd.SortWithNextField(3, 0);
            DataTable dtTmp = dv.Table;

            if (values[2] == "A")
            {
                report.DataSource = SetAux(dv, 0);
            }
            else if (values[2] == "D")
            {
                report.DataSource = SetAux(dv, 14);
            }
            else if (values[2] == "G")
            {
                report.DataSource = SetAux(dv, 10);
            }
            else if (values[2] == "M")
            {
                report.DataSource = SetAux(dv, 6);
            }
            report.Columns[2].HeaderText = values[0];
            report.Columns[3].HeaderText = (Convert.ToInt16(values[0]) - 1).ToString();
            report.Columns[4].HeaderText = (Convert.ToInt16(values[0]) - 2).ToString();
            report.Columns[5].HeaderText = "% " + values[0] + "-" + (Convert.ToInt16(values[0]) - 1).ToString();
            report.Columns[6].HeaderText = "% " + values[0] + "-" + (Convert.ToInt16(values[0]) - 2).ToString();
            report.DataBind();
            StringBuilder  SB     = new StringBuilder();
            StringWriter   SW     = new StringWriter(SB);
            HtmlTextWriter htmlTW = new HtmlTextWriter(SW);

            tabPreHeader.RenderControl(htmlTW);
            report.RenderControl(htmlTW);
            tabFirmas.RenderControl(htmlTW);
            string strRep;

            strRep = SB.ToString();
            Session.Clear();
            Session["Rep"]      = strRep;
            toolsHolder.Visible = true;
        }
Esempio n. 4
0
        public void MakeReport(Object Sender, EventArgs E)
        {
            DatasForReport balGen = new DatasForReport(reportTitle);

            ds = balGen.GetDatas(false, GetParams());
            //reportInfo.Text += balGen.SQL[0] + "<br>";
            //dgTest.DataSource = ds.Tables[2];
            //dgTest.DataBind();

            Press frontEnd = new Press(ds, reportTitle);

            frontEnd.PreHeader(tabPreHeader, report.Width, pr);
            frontEnd.Firmas(tabFirmas, report.Width);
            frontEnd.SourceFieldTitles(balGen.PressFields);

            tbReport = frontEnd.TbReport;

            double parcialD1 = 0, parcialD2 = 0, parcialD3 = 0, parcialC1 = 0, parcialC2 = 0, parcialC3 = 0;
            double subtotalD1 = 0, subtotalD2 = 0, subtotalD3 = 0, subtotalC1 = 0, subtotalC2 = 0, subtotalC3 = 0;
            double totalD1 = 0, totalD2 = 0, totalD3 = 0, totalC1 = 0, totalC2 = 0, totalC3 = 0;
            string cVal, aVal;
            string mcue = "";
            double saldoAntCuenta = 0, saldoAntSubCuenta = 0, saldoAntSubSubCuenta = 0;
            double saldoCuenta = 0, saldoSubCuenta = 0, saldoSubSubCuenta = 0;
            double saldo = 0;
            double totalSaldoAntDeb = 0, totalSaldoAntCre = 0, totalSaldoActDeb = 0, totalSaldoActCre = 0, totalSaldoDeb = 0, totalSaldoCre = 0;

            try{ mcue = DBFunctions.SingleData("SELECT mcue_codipuc FROM ccontabilidad"); }catch {};
            mcue = mcue.Trim();
            DataRow[] rows;

            for (i = 0; i < ds.Tables[3].Rows.Count; i++)
            {
                dr    = tbReport.NewRow();
                cVal  = ds.Tables[3].Rows[i][0].ToString();
                dr[0] = cVal;
                if (dr[0].ToString() != mcue)
                {
                    tbReport.Rows.Add(dr);
                    dr[1] = ds.Tables[3].Rows[i][1];
                    saldo = CalcularSaldoCuenta(cVal, Convert.ToDouble(ds.Tables[3].Rows[i][2]), Convert.ToDouble(ds.Tables[3].Rows[i][3]));
                    if (NaturalezaCuenta(cVal) == "D")
                    {
                        if (saldo > 0)
                        {
                            dr[6]         = saldo;
                            totalSaldoDeb = totalSaldoDeb + saldo;
                        }
                        else if (saldo < 0)
                        {
                            dr[7]         = saldo * -1;
                            totalSaldoCre = totalSaldoCre + (saldo * -1);
                        }
                    }
                    else if (NaturalezaCuenta(cVal) == "C")
                    {
                        if (saldo > 0)
                        {
                            dr[7]         = saldo;
                            totalSaldoCre = totalSaldoCre + saldo;
                        }
                        else if (saldo < 0)
                        {
                            dr[6]         = saldo * -1;
                            totalSaldoDeb = totalSaldoDeb + (saldo * -1);
                        }
                    }

                    /*if(Convert.ToDouble(ds.Tables[3].Rows[i][2]) != 0)
                    *       dr[6] = Convert.ToDouble(ds.Tables[3].Rows[i][2]);
                    *  if(Convert.ToDouble(ds.Tables[3].Rows[i][3]) != 0)
                    *       dr[7] = Convert.ToDouble(ds.Tables[3].Rows[i][3]);*/

                    rows = ds.Tables[2].Select("CODIGO = '" + cVal + "'");
                    if (rows.Length > 0)
                    {
                        dr[4]            = Convert.ToDouble(rows[0][2]);
                        dr[5]            = Convert.ToDouble(rows[0][3]);
                        parcialD2       += Convert.ToDouble(rows[0][2]);
                        parcialC2       += Convert.ToDouble(rows[0][3]);
                        totalSaldoActDeb = totalSaldoActDeb + Convert.ToDouble(rows[0][2]);
                        totalSaldoActCre = totalSaldoActCre + Convert.ToDouble(rows[0][3]);
                    }

                    rows = ds.Tables[1].Select("CODIGO = '" + cVal + "'");
                    if (rows.Length > 0)
                    {
                        dr[2]            = Convert.ToDouble(rows[0][2]);
                        dr[3]            = Convert.ToDouble(rows[0][3]);
                        parcialD1       += Convert.ToDouble(rows[0][2]);
                        parcialC1       += Convert.ToDouble(rows[0][3]);
                        totalSaldoAntDeb = totalSaldoAntDeb + Convert.ToDouble(rows[0][2]);
                        totalSaldoAntCre = totalSaldoAntCre + Convert.ToDouble(rows[0][3]);
                    }

                    parcialD3 += Convert.ToDouble(ds.Tables[3].Rows[i][2]);
                    parcialC3 += Convert.ToDouble(ds.Tables[3].Rows[i][3]);
                    if (i != ds.Tables[3].Rows.Count - 1)
                    {
                        aVal = ds.Tables[3].Rows[i + 1][0].ToString();
                    }
                    else
                    {
                        aVal = "00000";
                    }
                    if (cVal.Substring(0, 4) != aVal.Substring(0, 4))
                    {
                        dr = tbReport.NewRow();
                        tbReport.Rows.Add(dr);
                        dr[0] = cVal.Substring(0, 4);
                        rows  = ds.Tables[0].Select("MCUE_CODIPUC = '" + cVal.Substring(0, 4) + "'");
                        dr[1] = rows[0][1];
                        saldoAntSubSubCuenta = CalcularSaldoCuenta(cVal.Substring(0, 4), parcialD1, parcialC1);
                        if (NaturalezaCuenta(cVal.Substring(0, 4)) == "D")
                        {
                            if (saldoAntSubSubCuenta > 0)
                            {
                                dr[2] = saldoAntSubSubCuenta;
                            }
                            else if (saldoAntSubCuenta < 0)
                            {
                                dr[3] = saldoAntSubSubCuenta * -1;
                            }
                        }
                        else if (NaturalezaCuenta(cVal.Substring(0, 4)) == "C")
                        {
                            if (saldoAntSubSubCuenta > 0)
                            {
                                dr[3] = saldoAntSubSubCuenta;
                            }
                            else if (saldoAntSubSubCuenta < 0)
                            {
                                dr[2] = saldoAntSubSubCuenta * -1;
                            }
                        }
                        dr[4]             = parcialD2;
                        dr[5]             = parcialC2;
                        saldoSubSubCuenta = CalcularSaldoCuenta(cVal.Substring(0, 4), parcialD3, parcialC3);
                        if (NaturalezaCuenta(cVal.Substring(0, 4)) == "D")
                        {
                            if (saldoSubSubCuenta > 0)
                            {
                                dr[6] = saldoSubSubCuenta;
                            }
                            else if (saldoSubSubCuenta < 0)
                            {
                                dr[7] = saldoSubSubCuenta * -1;
                            }
                        }
                        else if (NaturalezaCuenta(cVal.Substring(0, 4)) == "C")
                        {
                            if (saldoSubSubCuenta > 0)
                            {
                                dr[7] = saldoSubSubCuenta;
                            }
                            else if (saldoSubSubCuenta < 0)
                            {
                                dr[6] = saldoSubSubCuenta * -1;
                            }
                        }
                        subtotalD1 += parcialD1; subtotalD2 += parcialD2; subtotalD3 += parcialD3;
                        subtotalC1 += parcialC1; subtotalC2 += parcialC2; subtotalC3 += parcialC3;
                        parcialD1   = 0; parcialD2 = 0; parcialD3 = 0;
                        parcialC1   = 0; parcialC2 = 0; parcialC3 = 0;
                    }
                    if (cVal.Substring(0, 2) != aVal.Substring(0, 2))
                    {
                        dr = tbReport.NewRow();
                        tbReport.Rows.Add(dr);
                        dr[0] = cVal.Substring(0, 2);
                        //*rows = ds.Tables[0].Select("MCUE_CODIPUC = '" + cVal.Substring(0,2) + "'");
                        try{ dr[1] = DBFunctions.SingleData("SELECT mcue_nombre FROM mcuenta WHERE mcue_codipuc='" + cVal.Substring(0, 2) + "'"); }
                        catch {}
                        saldoAntSubCuenta = CalcularSaldoCuenta(cVal.Substring(0, 2), subtotalD1, subtotalC1);
                        if (NaturalezaCuenta(cVal.Substring(0, 2)) == "D")
                        {
                            if (saldoAntSubCuenta > 0)
                            {
                                dr[2] = saldoAntSubCuenta;
                            }
                            else if (saldoAntSubCuenta < 0)
                            {
                                dr[3] = saldoAntSubCuenta * -1;
                            }
                        }
                        else if (NaturalezaCuenta(cVal.Substring(0, 2)) == "C")
                        {
                            if (saldoAntSubCuenta > 0)
                            {
                                dr[3] = saldoAntSubCuenta;
                            }
                            else if (saldoAntSubCuenta < 0)
                            {
                                dr[2] = saldoAntSubCuenta * -1;
                            }
                        }
                        dr[4]          = subtotalD2;
                        dr[5]          = subtotalC2;
                        saldoSubCuenta = CalcularSaldoCuenta(cVal.Substring(0, 2), subtotalD3, subtotalC3);
                        if (NaturalezaCuenta(cVal.Substring(0, 2)) == "D")
                        {
                            if (saldoSubCuenta > 0)
                            {
                                dr[6] = saldoSubCuenta;
                            }
                            else if (saldoSubCuenta < 0)
                            {
                                dr[7] = saldoSubCuenta * -1;
                            }
                        }
                        else if (NaturalezaCuenta(cVal.Substring(0, 2)) == "C")
                        {
                            if (saldoSubCuenta > 0)
                            {
                                dr[7] = saldoSubCuenta;
                            }
                            else if (saldoSubCuenta < 0)
                            {
                                dr[6] = saldoSubCuenta * -1;
                            }
                        }
                        totalD1   += subtotalD1; totalD2 += subtotalD2; totalD3 += subtotalD3;
                        totalC1   += subtotalC1; totalC2 += subtotalC2; totalC3 += subtotalC3;
                        subtotalD1 = 0; subtotalD2 = 0; subtotalD3 = 0;
                        subtotalC1 = 0; subtotalC2 = 0; subtotalC3 = 0;
                    }

                    if (cVal.Substring(0, 1) != aVal.Substring(0, 1))
                    {
                        dr = tbReport.NewRow();
                        tbReport.Rows.Add(dr);
                        dr[0] = cVal.Substring(0, 1);
                        try
                        {
                            rows  = ds.Tables[0].Select("MCUE_CODIPUC = '" + cVal.Substring(0, 1) + "'");
                            dr[1] = rows[0][1];
                        }
                        catch
                        {
                            dr[1] = "";
                        }
                        saldoAntCuenta = CalcularSaldoCuenta(cVal.Substring(0, 1), totalD1, totalC1);
                        if (NaturalezaCuenta(cVal.Substring(0, 1)) == "D")
                        {
                            if (saldoAntCuenta > 0)
                            {
                                dr[2] = saldoAntCuenta;
                            }
                            else if (saldoAntCuenta < 0)
                            {
                                dr[3] = saldoAntCuenta * -1;
                            }
                        }
                        else if (NaturalezaCuenta(cVal.Substring(0, 1)) == "C")
                        {
                            if (saldoAntCuenta > 0)
                            {
                                dr[3] = saldoAntCuenta;
                            }
                            else if (saldoAntCuenta < 0)
                            {
                                dr[2] = saldoAntCuenta * -1;
                            }
                        }
                        dr[4]       = totalD2;
                        dr[5]       = totalC2;
                        saldoCuenta = CalcularSaldoCuenta(cVal.Substring(0, 1), totalD3, totalC3);
                        if (NaturalezaCuenta(cVal.Substring(0, 1)) == "D")
                        {
                            if (saldoCuenta > 0)
                            {
                                dr[6] = saldoCuenta;
                            }
                            else if (saldoCuenta < 0)
                            {
                                dr[7] = saldoCuenta * -1;
                            }
                        }
                        else if (NaturalezaCuenta(cVal.Substring(0, 1)) == "C")
                        {
                            if (saldoCuenta > 0)
                            {
                                dr[7] = saldoCuenta;
                            }
                            else if (saldoCuenta < 0)
                            {
                                dr[6] = saldoCuenta * -1;
                            }
                        }
                        totalD1 = 0; totalD2 = 0; totalD3 = 0;
                        totalC1 = 0; totalC2 = 0; totalC3 = 0;
                    }
                }
            }

            drTotales = tbReport.NewRow();
            dr[0]     = "T O T ";
            dr[1]     = " A L E S ";
            dr[2]     = totalSaldoAntDeb.ToString("N");
            dr[3]     = totalSaldoAntCre.ToString("N");
            dr[4]     = totalSaldoActDeb.ToString("N");
            dr[5]     = totalSaldoActCre.ToString("N");
            dr[6]     = totalSaldoDeb.ToString("N");
            dr[7]     = totalSaldoCre.ToString("N");
            tbReport.Rows.Add(drTotales);

            frontEnd.PressFieldTitles(report);
            DataView dv = frontEnd.SortWithNextField(4, 0);

            //DataTable dtTmp = dv.Table;


            if (values[2] == "D")
            {
                report.DataSource = dv;
                report.DataBind();
            }
            else if (values[2] == "G")
            {
                report.DataSource = ApplyFilter(dv, 6);
                report.DataBind();
            }
            else if (values[2] == "M")
            {
                report.DataSource = ApplyFilter(dv, 4);
                report.DataBind();
            }
            StringBuilder  SB     = new StringBuilder();
            StringWriter   SW     = new StringWriter(SB);
            HtmlTextWriter htmlTW = new HtmlTextWriter(SW);

            tabPreHeader.RenderControl(htmlTW);
            report.RenderControl(htmlTW);
            tabFirmas.RenderControl(htmlTW);
            string strRep;

            strRep = SB.ToString();
            Session.Clear();
            Session["Rep"]      = strRep;
            toolsHolder.Visible = true;
        }
Esempio n. 5
0
        public void MakeReport(Object Sender, EventArgs E)
        {
            DatasForReport balGen = new DatasForReport(reportTitle);

            ds = balGen.GetDatas(false, GetParams());
            //reportInfo.Text += balGen.InfoMsg;
            //reportInfo.Text += balGen.SQL[0] + "<br>";

            Press frontEnd = new Press(ds, reportTitle);

            frontEnd.PreHeader(tabPreHeader, report.Width, pr);
            frontEnd.SourceFieldTitles(balGen.PressFields);

            tbReport = frontEnd.TbReport;

            double saldo = 0, total = 0;
            string cVal = "", aVal, name = "";

            DataRow[] rows, rows2;
            for (i = 0; i < ds.Tables[1].Rows.Count; i++)
            {
                cVal = ds.Tables[1].Rows[i][1].ToString();
                if (i != ds.Tables[1].Rows.Count - 1)
                {
                    aVal = ds.Tables[1].Rows[i + 1][1].ToString();
                }
                else
                {
                    aVal = "0000";
                }


                if (aVal != cVal)
                {
                    rows  = ds.Tables[1].Select("MCUE_CODIPUC = '" + cVal + "'");
                    rows2 = ds.Tables[0].Select("CUENTA = '" + cVal + "'");
                    name  = rows2[0][1].ToString();

                    for (j = 0; j < rows.Length; j++)
                    {
                        if (j == 0)
                        {
                            dr = tbReport.NewRow();
                            tbReport.Rows.Add(dr);
                            dr[0] = cVal;
                            dr[1] = name;
                        }
                        if (rows2[0][2].ToString() == "D")
                        {
                            saldo = Convert.ToDouble(rows[j][2]) - Convert.ToDouble(rows[j][3]);
                        }
                        if (rows2[0][2].ToString() == "C")
                        {
                            saldo = Convert.ToDouble(rows[j][3]) - Convert.ToDouble(rows[j][2]);
                        }
                        dr[Convert.ToInt32(rows[j][0]) * 2] = saldo;

                        total += saldo;
                    }
                    dr[26] = total;
                    total  = 0;
                }
                if (cVal.Substring(0, 1) != aVal.Substring(0, 1))
                {
                    dr = tbReport.NewRow();
                    tbReport.Rows.Add(dr);
                    dr[0] = "TOTAL";
                    if (cVal.Substring(0, 1) == "4")
                    {
                        dr[1] = "INGRESOS";
                    }
                    if (cVal.Substring(0, 1) == "5")
                    {
                        dr[1] = "GASTOS";
                    }
                    if (cVal.Substring(0, 1) == "6")
                    {
                        dr[1] = "COSTOS";
                    }
                    if (cVal.Substring(0, 1) == "7")
                    {
                        dr[1] = "GASTOS FINANCIEROS";
                    }
                }
            }

            dr = tbReport.NewRow();
            tbReport.Rows.Add(dr);
            dr[0] = "TOTAL";
            dr[1] = "ADMINISTRACION";

            SetSomeValues();

            frontEnd.PressFieldTitles(report);

            /*if(ddlView.SelectedValue != "ND")
             * for(i=0; i<ds.Tables[2].Rows.Count; i++)
             *      for(j=2; j<ds.Tables[2].Columns.Count; j++)
             *              if(ds.Tables[2].Rows[i][j].ToString() != "")
             *                      ds.Tables[2].Rows[i][j] = Convert.ToDouble(ds.Tables[2].Rows[i][j])/Convert.ToInt32(ddlView.SelectedValue);
             */
            report.DataSource = ds.Tables[2];
            report.DataBind();

            toolsHolder.Visible = true;
        }
Esempio n. 6
0
        public void MakeReport(Object Sender, EventArgs E)
        {
            DatasForReport balGen = new DatasForReport(reportTitle);

            ds = balGen.GetDatas(false, GetParams());
            //reportInfo.Text += balGen.SQL[1] + "<br>";
            //dgTest.DataSource = ds.Tables[1];


            Press frontEnd = new Press(ds, reportTitle);

            frontEnd.PreHeader(tabPreHeader, report.Width, pr);
            frontEnd.Firmas(tabFirmas, report.Width);
            frontEnd.SourceFieldTitles(balGen.PressFields);

            tbReport = frontEnd.TbReport;

            double deb1 = 0, cre1 = 0, totalDeb = 0, totalCre = 0;
            string cVal, aVal;

            for (i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                cVal  = ds.Tables[0].Rows[i][2].ToString();
                deb1 += Convert.ToDouble(ds.Tables[0].Rows[i][4]);
                cre1 += Convert.ToDouble(ds.Tables[0].Rows[i][5]);
                if (i != ds.Tables[0].Rows.Count - 1)
                {
                    aVal = ds.Tables[0].Rows[i + 1][2].ToString();
                }
                else
                {
                    aVal = "00000";
                }

                if (cVal != aVal)
                {
                    dr = tbReport.NewRow();
                    tbReport.Rows.Add(dr);
                    dr[0] = ds.Tables[0].Rows[i][0].ToString();
                    dr[1] = ds.Tables[0].Rows[i][1].ToString();
                    dr[2] = cVal;
                    dr[3] = ds.Tables[0].Rows[i][3].ToString();
                    dr[4] = deb1;
                    dr[5] = cre1;
                    deb1  = 0;
                    cre1  = 0;
                }
            }

            dr = tbReport.NewRow();
            tbReport.Rows.Add(dr);

            dr = tbReport.NewRow();
            tbReport.Rows.Add(dr);
            dr[3] = "R E S U M E N";

            deb1 = 0;
            cre1 = 0;

            for (i = 0; i < ds.Tables[1].Rows.Count; i++)
            {
                cVal  = ds.Tables[1].Rows[i][0].ToString();
                deb1 += Convert.ToDouble(ds.Tables[1].Rows[i][2]);
                cre1 += Convert.ToDouble(ds.Tables[1].Rows[i][3]);
                if (i != ds.Tables[1].Rows.Count - 1)
                {
                    aVal = ds.Tables[1].Rows[i + 1][0].ToString();
                }
                else
                {
                    aVal = "00000";
                }

                if (cVal != aVal)
                {
                    dr = tbReport.NewRow();
                    tbReport.Rows.Add(dr);
                    dr[2]    = ds.Tables[1].Rows[i][0].ToString();
                    dr[3]    = ds.Tables[1].Rows[i][1].ToString();
                    dr[4]    = deb1;
                    dr[5]    = cre1;
                    totalDeb = deb1;
                    totalCre = cre1;
                }
            }

            dr = tbReport.NewRow();
            tbReport.Rows.Add(dr);

            dr = tbReport.NewRow();
            tbReport.Rows.Add(dr);
            dr[3] = "TOTAL MOVIMIENTO";
            dr[4] = totalDeb;
            dr[5] = totalCre;
            //reportInfo.Text += ds.Tables.Count.ToString() + "<br>";
            frontEnd.PressFieldTitles(report);
            //DataView dv = frontEnd.SortWithNextField(2,0);
            report.DataSource = ds.Tables[2];
            report.DataBind();

            StringBuilder  SB     = new StringBuilder();
            StringWriter   SW     = new StringWriter(SB);
            HtmlTextWriter htmlTW = new HtmlTextWriter(SW);

            tabPreHeader.RenderControl(htmlTW);
            report.RenderControl(htmlTW);
            tabFirmas.RenderControl(htmlTW);
            string strRep;

            strRep = SB.ToString();
            Session.Clear();
            Session["Rep"]      = strRep;
            toolsHolder.Visible = true;
        }