Пример #1
0
        public ActionResult ReportePlanillaCedula(ReporteViewModel reporteVM)
        {
            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_getDatosPlanillaCedula_Result> datosReporte;

            using (BDContext context = new BDContext())
            {
                datosReporte = context.sp_getDatosPlanillaCedula(reporteVM.idEmpleado).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"));
        }