0

我正在使用两个存储过程,一个用于主报表,另一个用于子报表。下面是代码。

 private void LoadSalesOrderReport()
 {
     string Type = gvQuotationDetails.Rows[QuoteIndex].Cells["Type"].EditedFormattedValue.ToString();
     FilePath = ConfigurationManager.AppSettings["EMP_IMG_PATH"].ToString() + "\\" + ValQuoteID.ToString() + ".pdf";
     DeleteExistingFile(FilePath);
     try
     {
         AccountsPayableMaster objAPM = new AccountsPayableMaster();
         QuotationReport obj = new QuotationReport();
         objReportDocument.Load(Application.StartupPath + @"\rptQuotationReport.rpt");
         obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_SalesOrderReport;1");
         obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_GetBatchReportDetails;1");
         obj.crysQuotationReport.ReportSource = objReportDocument;
         objReportDocument.SetParameterValue("@QuoteID", ValQuoteID);
         objReportDocument.SetParameterValue("Type", "-" + Type.ToUpper() + "-");
         objReportDocument.SetParameterValue("@QuoteID", ValQuoteID, objReportDocument.Subreports[0].Name.ToString());
         string[] Print = objAPM.GetPrintDetails();
         SetPrintParameters(objReportDocument, Print);
         obj.Show();
         objReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, FilePath);

     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     OpenPdfFile();
 }

 private void OpenPdfFile()
 {
     try
     {
         Process.Start(FilePath);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please install MicrosoftOffice/Pdf Reader to view files", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }

代码工作正常。但问题是。当我单击前端的按钮直接显示 pdf 时。水晶报表表格也显示出来了,我知道原因,因为我在代码中使用了 obj.Show。我试图评论它,但它抛出了一个错误。可以一个建议更改我的代码以直接显示 pdf 而不是 Crystalreport 表单。

在此处输入图像描述

4

0 回答 0