public ActionResult CTR080_QuotationForCancelContractMemorandum(int iDocID) { IContractDocumentHandler contractDocHandler = ServiceContainer.GetService <IContractDocumentHandler>() as IContractDocumentHandler; List <RPTCancelContractMemoDo> rptList = contractDocHandler.GetRptCancelContractMemoData(iDocID); List <RPTCancelContractMemoDetailDo> rptListDetail = contractDocHandler.GetRptCancelContractMemoDetail(iDocID); bool isShowDefaultData = false; if (rptListDetail == null || rptListDetail.Count == 0) { rptListDetail = GetDefaultCancelContractMemoDetailData(); isShowDefaultData = true; } ReportDocument rptH = new ReportDocument(); string path = ReportUtil.GetReportPath("Reports/CTR080_QuotationForCancelContractMemorandum.rpt", Server.MapPath("/")); //string path = ReportUtil.GetReportTemplatePath("CTR080_QuotationForCancelContractMemorandum.rpt"); rptH.Load(path); rptH.SetDataSource(rptList); rptH.Subreports["CTR080_1"].SetDataSource(rptListDetail); rptH.SetParameterValue("ShowDefaultData", isShowDefaultData, "CTR080_1"); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); rptH.Close(); return(File(stream, "application/pdf")); }
public ActionResult CTR060_CancelContractMemorandum(int iDocID) { try { IContractDocumentHandler contractDocHandler = ServiceContainer.GetService <IContractDocumentHandler>() as IContractDocumentHandler; List <RPTCancelContractMemoDo> rptList = contractDocHandler.GetRptCancelContractMemoData(iDocID); List <RPTCancelContractMemoDetailDo> rptListDetail = contractDocHandler.GetRptCancelContractMemoDetail(iDocID); ReportDocument rptH = new ReportDocument(); string path = ReportUtil.GetReportPath("Reports/CTR060_CancelContractMemorandum.rpt", Server.MapPath("/")); //string path = ReportUtil.GetReportTemplatePath("CTR060_CancelContractMemorandum.rpt"); rptH.Load(path); rptH.SetDataSource(rptList); rptH.Subreports["CTR060_1"].SetDataSource(rptListDetail); rptH.SetParameterValue("AutoBillingTypeNone", AutoTransferBillingType.C_AUTO_TRANSFER_BILLING_TYPE_NONE, "CTR060_1"); rptH.SetParameterValue("AutoBillingTypeAll", AutoTransferBillingType.C_AUTO_TRANSFER_BILLING_TYPE_ALL, "CTR060_1"); rptH.SetParameterValue("AutoBillingTypePartial", AutoTransferBillingType.C_AUTO_TRANSFER_BILLING_TYPE_PARTIAL, "CTR060_1"); rptH.SetParameterValue("BankBillingTypeNone", BankTransferBillingType.C_BANK_TRANSFER_BILLING_TYPE_NONE, "CTR060_1"); rptH.SetParameterValue("BankBillingTypeAll", BankTransferBillingType.C_BANK_TRANSFER_BILLING_TYPE_ALL, "CTR060_1"); rptH.SetParameterValue("BankBillingTypePartial", BankTransferBillingType.C_BANK_TRANSFER_BILLING_TYPE_PARTIAL, "CTR060_1"); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); rptH.Close(); //IDocumentHandler documentHandler = ServiceContainer.GetService<IDocumentHandler>() as IDocumentHandler; //doDocumentDataGenerate doDoc = new doDocumentDataGenerate(); //if (rptList.Count > 0) //{ // doDoc.DocumentNo = rptList[0].DocNo; // doDoc.DocumentCode = rptList[0].DocumentCode; // doDoc.DocumentData = rptList; //} //List<ReportParameterObject> listSubReportDataSource = new List<ReportParameterObject>(); //listSubReportDataSource.Add(new ReportParameterObject() { SubReportName = "CTR060_1", Value = rptListDetail }); //doDoc.SubReportDataSource = listSubReportDataSource; //doDoc.MainReportParam = null; //List<ReportParameterObject> listSubReportParam = new List<ReportParameterObject>(); //listSubReportParam.Add(new ReportParameterObject() { ParameterName = "AutoBillingTypeNone", Value = AutoTransferBillingType.C_AUTO_TRANSFER_BILLING_TYPE_NONE, SubReportName = "CTR060_1" }); //listSubReportParam.Add(new ReportParameterObject() { ParameterName = "AutoBillingTypeAll", Value = AutoTransferBillingType.C_AUTO_TRANSFER_BILLING_TYPE_ALL, SubReportName = "CTR060_1" }); //listSubReportParam.Add(new ReportParameterObject() { ParameterName = "AutoBillingTypePartial", Value = AutoTransferBillingType.C_AUTO_TRANSFER_BILLING_TYPE_PARTIAL, SubReportName = "CTR060_1" }); //listSubReportParam.Add(new ReportParameterObject() { ParameterName = "BankBillingTypeNone", Value = BankTransferBillingType.C_BANK_TRANSFER_BILLING_TYPE_NONE, SubReportName = "CTR060_1" }); //listSubReportParam.Add(new ReportParameterObject() { ParameterName = "BankBillingTypeAll", Value = BankTransferBillingType.C_BANK_TRANSFER_BILLING_TYPE_ALL, SubReportName = "CTR060_1" }); //listSubReportParam.Add(new ReportParameterObject() { ParameterName = "BankBillingTypePartial", Value = BankTransferBillingType.C_BANK_TRANSFER_BILLING_TYPE_PARTIAL, SubReportName = "CTR060_1" }); //doDoc.SubReportParam = listSubReportParam; //// doDoc2 //List<RPTCoverLetterDo> rptListCover = contractDocHandler.GetRptCoverLetterData(100); // iDocID = 100 , fixed to 100 for test //List<RPTInstrumentDetailDo> rptListInst = contractDocHandler.GetRptInstrumentDetailData(100); // iDocID = 100 , fixed to 100 for test //doDocumentDataGenerate doDoc2 = new doDocumentDataGenerate(); //if (rptListCover.Count > 0) //{ // rptListCover[0].DocumentCode = "CTR090"; // doDoc2.DocumentNo = rptListCover[0].DocNo; // doDoc2.DocumentCode = rptListCover[0].DocumentCode; // doDoc2.DocumentData = rptListCover; //} //List<ReportParameterObject> listSubReportDataSource2 = new List<ReportParameterObject>(); //listSubReportDataSource2.Add(new ReportParameterObject() { SubReportName = "CTR090_1", Value = rptListInst }); //listSubReportDataSource2.Add(new ReportParameterObject() { SubReportName = "CTR090_2", Value = rptListInst }); //listSubReportDataSource2.Add(new ReportParameterObject() { SubReportName = "CTR090_3", Value = rptListInst }); //doDoc2.SubReportDataSource = listSubReportDataSource2; //List<ReportParameterObject> listMainReportParam2 = new List<ReportParameterObject>(); //listMainReportParam2.Add(new ReportParameterObject() { ParameterName = "FlagOn", Value = FlagType.C_FLAG_ON }); //doDoc2.MainReportParam = listMainReportParam2; //doDoc2.SubReportParam = null; //Stream stream = documentHandler.GenerateDocument(doDoc, doDoc2); return(File(stream, "application/pdf")); } catch (Exception ex) { throw ex; } }