Esempio n. 1
0
        //Generador de reportes por medio del Stored procedure.
        public ActionResult ReportePlanillaFecha(ReporteViewModel reporteVM)
        {
            try
            {
                var reportViewer = new ReportViewer
                {
                    ProcessingMode             = ProcessingMode.Local,
                    ShowExportControls         = true,
                    ShowParameterPrompts       = true,
                    ShowPageNavigationControls = true,
                    ShowRefreshButton          = true,
                    ShowPrintButton            = true,
                    SizeToReportContent        = true,
                    AsyncRendering             = false,
                };
                string rutaReporte = "~/Reports/DatosPlanilla.rdlc";
                ///construir la ruta física
                string rutaServidor = Server.MapPath(rutaReporte);
                reportViewer.LocalReport.ReportPath = rutaServidor;
                //reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"Reports\ReportCategories.rdlc";
                var infoFuenteDatos = reportViewer.LocalReport.GetDataSourceNames();
                reportViewer.LocalReport.DataSources.Clear();

                List <sp_getDatosPlanillaFecha_Result> datosReporte;
                using (BDContext context = new BDContext())
                {
                    datosReporte = context.sp_getDatosPlanillaFecha(reporteVM.fechaPago).ToList();
                }
                ReportDataSource fuenteDatos = new ReportDataSource();
                fuenteDatos.Name  = infoFuenteDatos[0];
                fuenteDatos.Value = datosReporte;
                reportViewer.LocalReport.DataSources.Add(new ReportDataSource("PlanillaDataSet", datosReporte));

                reportViewer.LocalReport.Refresh();
                ViewBag.ReportViewer = reportViewer;


                return(View("~/Views/Reporte/Report.cshtml"));
            }
            catch (Exception)
            {
                return(View());
            }
        }