/// <summary> /// Call to the Printing class using the configuration of the selected report /// </summary> private void btnOk_Click(object sender, EventArgs e) { // If no report selected, exit if (cmbBoxSelectTemplate.SelectedIndex < 0) { return; } // Get report configuration ReportConfiguration lReport = mReports[cmbBoxSelectTemplate.SelectedIndex]; // Loop for all the instances in the received list foreach (Oid oid in mSelectedOids) { switch (lReport.ReportType) { case ReportTypes.Word: { PrintingDriver.PrintToWord.Print(oid, lReport, rdoBtnPreview.Checked, (int)numUpDownCopies.Value, lblNameOfPrint.Text, ""); break; } case ReportTypes.Excel: { PrintingDriver.PrintToExcel.Print(oid, lReport); break; } case ReportTypes.CrystalReports: { DataSet lDataSet = PrintingDriver.PrintToDataSets.GetData(oid, lReport.DatasetFile); ScenarioManager.LaunchCrystalReportPreviewScenario(lDataSet, lReport.ReportFilePath, null, !rdoBtnPreview.Checked); break; } case ReportTypes.RDLC: { DataSet lDataSet = PrintingDriver.PrintToDataSets.GetData(oid, lReport.DatasetFile); ScenarioManager.LaunchRDLReportPreviewScenario(lDataSet, lReport.ReportFilePath, null, !rdoBtnPreview.Checked); break; } } } // Close this form Close(); }
/// <summary> /// Process the report and show it. /// </summary> /// <returns>A boolean value indicating the success or failure in the process.</returns> public override bool Execute() { if (!CheckNullAndFormatFilterVariablesValues()) { return(false); } // Load filter variable values in the parameters collection foreach (ArgumentController lFilterVariable in InputFields) { object lFilterVariableValue = lFilterVariable.Value; ArgumentOVControllerAbstract lOVController = lFilterVariable as ArgumentOVControllerAbstract; if (lOVController != null) { if (lOVController.Value != null) { lFilterVariableValue = lOVController.GetSupplementaryInfoText(); } } if (ReportParams.ContainsKey(lFilterVariable.Name)) { ReportParams[lFilterVariable.Name] = lFilterVariableValue; } else { ReportParams.Add(lFilterVariable.Name, lFilterVariableValue); } } // Execute Filter Event initialization. ExecuteFilterEventArgs lExecuteFilterEventArgs = new ExecuteFilterEventArgs(this); try { // Get the data according the report definition. DataTable lDataTable = GetData(); // Create the DataSet from the base DataTable, taking into account the DataSet structure. DataSet lDataSet = PrintingDriver.PrintToDataSets.GetData(lDataTable, mDataSetFile); if (GetReportType() == ReportTypes.CrystalReports) { // Show 'Crystal' preview scenario. ScenarioManager.LaunchCrystalReportPreviewScenario(lDataSet, ReportFile, ReportParams, PrintDirectly); } if (GetReportType() == ReportTypes.RDLC) { // Show 'RDLC' preview scenario. ScenarioManager.LaunchRDLReportPreviewScenario(lDataSet, ReportFile, ReportParams, PrintDirectly); } } catch (Exception exc) { Exception gettingDataException = new Exception(CultureManager.TranslateString(LanguageConstantKeys.L_ERROR_REPORT_GETTINGDATA, LanguageConstantValues.L_ERROR_REPORT_GETTINGDATA), exc); Presentation.ScenarioManager.LaunchErrorScenario(gettingDataException); // Indicate that an error has occurred during the report configuration. lExecuteFilterEventArgs.Success = false; } OnExecuteFilter(lExecuteFilterEventArgs); return(lExecuteFilterEventArgs.Success); }