Ejemplo n.º 1
0
        public ActionResult Reporte(int id)
        {
            //declarar el objeto de la clase LocalReport
              LocalReport localReport = new LocalReport();
              //localReport.ReportPath = Server.MapPath("~/Content/Reports/Report1.rdlc");
              localReport.ReportPath = Server.MapPath("~/Content/Reports/Reporte.rdlc");

              List<Alertas> listReport = new AlertasRepository().GetAllAlertasReporte(id).ToList();

              List<Alertas_detalle> ListDetalle = new Alertas_detalleRepository().GetAllAlertas_detalle(id).ToList();
              string test = ListDetalle[0].EtiquetaUnidades;

              List<EAN> ListDetalleEAN = new EANRepository().GetListEANByAlerta(id).ToList();

              ReportDataSource reportDataSource = new ReportDataSource("ReporteAlertas", listReport);
              ReportDataSource reportDataSource2 = new ReportDataSource("Detalle", ListDetalle);
              ReportDataSource reportDataSource3 = new ReportDataSource("DetalleEAN", ListDetalleEAN);
              localReport.DataSources.Add(reportDataSource);
              localReport.DataSources.Add(reportDataSource2);
              localReport.DataSources.Add(reportDataSource3);

              string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority +
               Request.ApplicationPath.TrimEnd('/');

              //string uriImage = Request.Url.Authority.Replace(Request.Url.Authority, "") +
              //    baseUrl + @dirLogos + listReport.FirstOrDefault().NombreLogo;

              //ReportParameter[] param = new ReportParameter[1];
              //param[0] = new ReportParameter("Path", uriImage);

              //localReport.EnableExternalImages = true;
              //localReport.SetParameters(param);

              //Ahora pasamos los datos al reporte

              //declaramos las variables de configuración para el reporte
              string reportType = "PDF";
              string mimeType;
              string encoding;
              string fileNameExtension;
              //En la configuración del reporte debe especificarse para el tipo de reporte
              //consulte el sitio para más información
              //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
              Warning[] warnings;
              string[] streams;
              byte[] renderedBytes;
              //Transformar el reporte a bytes para transferirlo como flujo
              renderedBytes = localReport.Render(reportType, null, out mimeType,
              out encoding,
              out fileNameExtension,
              out streams,
              out warnings);
              //enviar el archivo al cliente (navegador)
              return File(renderedBytes, mimeType);
        }
Ejemplo n.º 2
0
        public ActionResult Edit_detalle(int id, bool readOnly)
        {
            Alertas_detalle _Alertas_detalle = new Alertas_detalleRepository().GetAlertaById(id);
              ViewBag.ReadOnly = readOnly;
              List<EAN> listEANByDetail = null;

              if (_Alertas_detalle.Alertas_detalle_EAN.Count == 0)
              {
            listEANByDetail = new EANRepository().GetListEANByAlerta(_Alertas_detalle.Id_alerta.Value).ToList();

            foreach (var item in listEANByDetail)
            {
              Alertas_detalle_EAN _Alertas_detalle_EAN = new Alertas_detalle_EAN();
              _Alertas_detalle_EAN.Id_alerta_detalle = id;
              _Alertas_detalle_EAN.Id_ean = item.Id_ean;
              _Alertas_detalle_EAN.unidades = 0;

              new Alertas_detalle_EANRepository().Create(_Alertas_detalle_EAN);
            }

              }

              return PartialView(new Alertas_detalleRepository().GetAlertaById(id));
        }