public static XtraForm Preview(XtraForm mainForm, PLDynRepType ReportType, DataSet Source, string[] FieldNames, string[] Captions, int[] ExpectedWidths, string Title, string SubTitle) { ParameterFields Params = null; try { #region Mở rộng nếu có thêm Report mới PLBlankReport frm = new PLBlankReport(); PLCrystalReportViewer view = new PLCrystalReportViewer(); if (ReportType == PLDynRepType.HSheet) { HSheetReport Report = new HSheetReport(); DynamicSheetReport.ToSheetReport(Report, out Params, Source, FieldNames, Captions, ExpectedWidths, Title, SubTitle); //view._I.ReportSource = Report;//phiên bản 12 view.ReportSource = Report;//phiên bản 10 } else if (ReportType == PLDynRepType.VSheet) { VSheetReport Report = new VSheetReport(); DynamicSheetReport.ToSheetReport(Report, out Params, Source, FieldNames, Captions, ExpectedWidths, Title, SubTitle); //view._I.ReportSource = Report;//phien bản 12 view.ReportSource = Report;//phien bản 10 } #endregion //view._I.ParameterFieldInfo = Params;//phien bản 12 //view.ParameterFieldInfo = Params;//phien bản 10 frm.WindowState = FormWindowState.Maximized; view.Dock = DockStyle.Fill; frm.Controls.Add(view); return frm; } catch (Exception ex){ PLException.AddException(ex); return null; } }
/// <summary>Xem trước khi in /// </summary> /// <returns></returns> public XtraForm preview() { try { PLBlankReport frm = new PLBlankReport(); PLCrystalReportViewer view = new PLCrystalReportViewer(); ReportDocument report = GetRepObj(); report.SetDataSource(mMainDataSet); view._DSList = FillDataForSubReport(report); view._DSList.Insert(0, mMainDataSet); FillParams(view); //view._I.ReportSource = report;//phien bản 12 view.ReportSource = report;//phien bản 10 frm.WindowState = FormWindowState.Maximized; view.Dock = DockStyle.Fill; frm.Controls.Add(view); return frm; } catch (Exception ex) { PLMessageBox.ShowErrorMessage("Không kết nối được với máy in.\nVui lòng kiểm tra lại kết nối với máy in."); PLException.AddException(ex); return null; } }