Exemplo n.º 1
0
        public ActionResult ISR010_GetNewInstallationSlip(string strSlipNo)
        {
            IReportHandler            reportHandler = ServiceContainer.GetService <IReportHandler>() as IReportHandler;
            List <RPTNewRentalSlipDo> rptList       = reportHandler.GetRptNewRentalSlipReport(strSlipNo);

            IDocumentHandler            dochandler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
            List <tbm_DocumentTemplate> dLst       = dochandler.GetDocumentTemplateByDocumentCode(DocumentCode.C_DOCUMENT_CODE_NEW_INSTALL_SLIP_RENTAL);

            ReportDocument rptH = new ReportDocument();
            //string path = ReportUtil.GetReportTemplatePath("ISR010_NewInstallationSlip.rpt");
            string path = ReportUtil.GetReportPath("Reports/ISR010_NewInstallationSlip.rpt", Server.MapPath("/"));

            rptH.Load(path);

            List <RPTNewRentalSlipDo> lst = new List <RPTNewRentalSlipDo>();

            if (rptList != null && rptList.Count > 0)
            {
                lst.Add(rptList[0]);

                if (dLst.Count > 0)
                {
                    lst[0].DocumentNameEN  = dLst[0].DocumentNameEN;
                    lst[0].DocumentVersion = dLst[0].DocumentVersion;
                }
            }
            else
            {
                rptList.Add(new RPTNewRentalSlipDo());
            }

            rptH.SetDataSource(lst);
            rptH.Subreports["Page1"].SetDataSource(rptList);
            rptH.Subreports["Page2"].SetDataSource(rptList);
            rptH.Subreports["Page3"].SetDataSource(rptList);

            Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            rptH.Close();

            return(File(stream, "application/pdf"));
        }