Add records in a reportviewer

1

I have a report in visual basic, what I need is that at the end of the page show me the total number of records that exist.

I also need you to show me the total of each column (example: The Column reason has X amount)

    
asked by Mario 19.06.2017 в 06:14
source

1 answer

1

hi look at this is the SQL query, where I calculate the totalizer

    IF @Tipo='ReporteLiquidacion'
    BEGIN
        --Cabecera
        SELECT      TOP 1            R.facID 'facID'
                                ,Folio_Recompra 'folio_recompra'
                                ,R.Tipo_Operacion 'tipo_oper'
                                ,R.Condicion_Pago 'cond_pago'
                                ,R.Tasa_Captacion 'tasa_capta'
                                ,R.Fecha_de_Pago 'Fecha_de_Pago'

        FROM Facturas F 
        INNER JOIN FIP_VENTA V ON F.facid = V.facid
        INNER JOIN FIP_Recompra R ON v.facID = r.facID
        AND R.facID IN (SELECT facID FROM @tablaFacID)

-- Totalizador cabecera
        SELECT                  SUM(R.Valor_Recompra)  'total_rescate'
        FROM Facturas F 
        INNER JOIN FIP_VENTA V ON F.facid = V.facid
        INNER JOIN FIP_Recompra R ON v.facID = r.facID
        AND R.facID IN (SELECT facID FROM @tablaFacID)


    --Detalle
        SELECT                    R.facID 
                                ,F.cliente 'cliente'
                                ,Folio_Recompra
                                ,CONVERT(INT,F.numero_documento) 'numero_documento'
                                ,CONVERT(INT,F.valor_documento) 'valor_documento'
                                ,R.Valor_Rescate 'Valor_Rescate'
                                ,CONVERT(VARCHAR,F.fecha_vencimiento,103) 'fecha_vencimiento'
                                ,R.Interes_por_Recuperar 'Interes_por_Recuperar'--ver si es otro campo
                                ,R.Valor_Recompra 'Valor_Recompra'
                                ,R.Fecha_de_Pago 'Fecha_de_Pago'
                                ,R.Interes_por_Recuperar 'Interes_por_Recuperar'
                                ,R.Monto_Pago 'Monto_Pago'
                                ,R.Tipo_Operacion
                                ,R.Condicion_Pago
                                ,R.Tasa_Captacion
                                ,R.Dias_Reliquidados 'Dias_Reliquidados'
        From Facturas F 
        INNER JOIN FIP_VENTA V ON F.facid = V.facid
        INNER JOIN FIP_Recompra R ON v.facID = r.facID
        AND R.facID IN (SELECT facID FROM @tablaFacID)

    END

here is where I do the event

 protected void Imprimir_Liquidacion_Click(object sender, EventArgs e)
        {
            BolsaDeProductos.SX.BD.Conexion objconexion = new BolsaDeProductos.SX.BD.Conexion();
            DataSet ds = new DataSet();
            Parametros Param = new Parametros();

            Param.Limpiar();
            Param.Agregar("Tipo", "ReporteLiquidacion");
            Param.Agregar("listaFact", objFunciones.Desencriptar(Request.QueryString["listaFact"].ToString()));


            ds = objconexion.EjecutarSQL("spInsertRecompraFIP", Param.Generar("parametros", true));

            ReportViewer liqRecompra = new ReportViewer();

            liqRecompra.LocalReport.ReportPath = ConfigurationManager.AppSettings["RutaDocumento"].ToString() + "Liquidacion_Recompra.rdlc";
            liqRecompra.LocalReport.DataSources.Clear();
            liqRecompra.LocalReport.DataSources.Add(new ReportDataSource("cabecera", ds.Tables[0]));
            liqRecompra.LocalReport.DataSources.Add(new ReportDataSource("total", ds.Tables[1]));
            liqRecompra.LocalReport.DataSources.Add(new ReportDataSource("detalle", ds.Tables[2]));

            byte[] bytes = liqRecompra.LocalReport.Render("Word", null, out mimeType, out encoding, out extension, out streamIds, out warnings);

            Response.Clear();
            Response.ContentType = mimeType;
            Response.AddHeader("content-disposition", "attachment; filename= Comprobante_Liquidacion_Recompra." + extension);
            Response.BinaryWrite(bytes);
            Response.Flush();



        }

I hope it serves you, regards

    
answered by 19.06.2017 в 17:17