メインレポート用とサブレポート用の2つのストアドプロシージャを使用しています。以下はコードです。
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を直接表示すると、Crystal Reportフォームも表示され、コードでobj.Showを使用しているため、理由がわかります。コメントしようとしましたが、エラーがスローされます。クリスタルレポートフォームではなくPDFを直接表示するようにコードを変更することをお勧めします。