コード例 #1
0
        //创建打印预览和直接打印的报表对象。
        private DIYReport.ReportModel.RptReport createRptReport(string moduleID, PrintTempleteContentInfo templeteContent)
        {
            try {
                //PrintTempleteContentInfo templeteContent = _ReportData.GetPrintTempleteContent(templeteID);
                DIYReport.ReportModel.RptReport reportContent = DIYReport.ReportReader.Instance().ReadFromXmlString(templeteContent.TempleteXmlContent);
                reportContent.UserParamList = convertToRptParam(_ReportData.ReportParamList);

                //以后再追加报表子表的处理问题
                DIYReport.Interface.ISubReportCommand subCommand = new SubReportCommand(templeteContent, _ReportData.DataSource);
                //subCommand.SetDataSourceParams = pars;
                reportContent.SubReportCommand = subCommand;

                //  if (_ReportData.DataSource is DataSet) {
                DataSet dsData = _ReportData.DataSource;
                reportContent.DataSource = dsData.Tables[templeteContent.DataSource];
                //}
                //else {
                //    throw new MB.Util.APPException("目前报表的数据类型只支持 DataSet 请先转换", MB.Util.APPMessageType.SysErrInfo);
                //}

                return(reportContent);
            }
            catch (Exception ex) {
                throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, string.Format("根据功能模块ID:{0},打印模板ID: {1} 创建报表对象出错。", moduleID, templeteContent.GID));
            }
        }
コード例 #2
0
        /// <summary>
        /// 得到子表的数据源
        /// </summary>
        /// <param name="parentRow"></param>
        /// <param name="relationMember"></param>
        /// <param name="reportName"></param>
        /// <returns></returns>
        public object GetReportDataSource(DataRow parentRow, string relationMember, string reportName)
        {
            PrintTempleteContentInfo childInfo = _PrintTemplete.Childs.FirstOrDefault(o => string.Compare(o.Name, reportName, true) == 0);

            if (childInfo == null)
            {
                return(null);
            }
            if (_DataSource.Tables.Contains(childInfo.DataSource))
            {
                if (string.IsNullOrEmpty(relationMember))
                {
                    return(_DataSource.Tables[childInfo.DataSource]);
                }
                else
                {
                    DataRow[] drs      = parentRow.GetChildRows(relationMember, System.Data.DataRowVersion.Default);
                    DataTable newTable = null;
                    if (drs.Length > 0)
                    {
                        newTable = drs[0].Table.Clone();
                        foreach (DataRow dr in drs)
                        {
                            newTable.Rows.Add(dr.ItemArray);
                        }
                    }
                    return(newTable);
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 子报表相关处理。
        /// </summary>
        /// <param name="printTemplete"></param>
        /// <param name="dsData"></param>
        public SubReportCommand(MB.WinPrintReport.Model.PrintTempleteContentInfo printTemplete, DataSet dsData)
        {
            _PrintTemplete  = printTemplete;
            _DataSource     = dsData;
            _SubReportNames = new List <string>();

            if (_PrintTemplete.Childs != null)
            {
                foreach (MB.WinPrintReport.Model.PrintTempleteContentInfo child in _PrintTemplete.Childs)
                {
                    _SubReportNames.Add(child.Name);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// 显示打印模板设计。
        /// </summary>
        /// <param name="moduleID"></param>
        /// <param name="templeteID"></param>
        public void ShowDesign(string moduleID, PrintTempleteContentInfo templeteContent)
        {
            _CurrentTempleteContent = templeteContent;
            if (string.IsNullOrEmpty(templeteContent.TempleteXmlContent))
            {
                var newReport = DIYReport.ReportModel.RptReport.NewReport(templeteContent.Name, templeteContent.GID);
                templeteContent.TempleteXmlContent = DIYReport.ReportWriter.Instance().BuildXMLString(newReport);
            }

            DIYReport.ReportModel.RptReport reportContent = createRptReport(moduleID, templeteContent);

            DIYReport.Extend.EndUserDesigner.MainDesignForm frmDesign = new DIYReport.Extend.EndUserDesigner.MainDesignForm(reportContent);
            frmDesign.BeginXReportIOProcess += new DIYReport.ReportModel.XReportIOEventHandler(frmDesign_BeginXReportIOProcess);
            frmDesign.ShowDialog();
        }
コード例 #5
0
 /// <summary>
 /// 打印浏览。
 /// </summary>
 /// <param name="moduleID"></param>
 /// <param name="templeteID"></param>
 /// <param name="parmValues"></param>
 public void ShowPreview(string moduleID, PrintTempleteContentInfo templeteContent)
 {
     MB.Util.TraceEx.Write("开始执行 ShowPreview ");
     _CurrentTempleteContent = templeteContent;
     DIYReport.ReportModel.RptReport report = createRptReport(moduleID, templeteContent);
     MB.Util.TraceEx.Write("createRptReport 成功 ");
     if (report != null)
     {
         DIYReport.UserDIY.DesignEnviroment.CurrentReport = report;
         DIYReport.Extend.Print.XPrintingSystem printSystem = new DIYReport.Extend.Print.XPrintingSystem();
         printSystem.PrintPreview(report);
     }
     else
     {
         throw new MB.Util.APPException(string.Format("该报表模板 {0} 还没有开始绘制,请在报表打印设计器中先设计。", templeteContent.Name), MB.Util.APPMessageType.DisplayToUser);
     }
 }
コード例 #6
0
 /// <summary>
 /// 报表直接打印。可以指定是否弹出打印对话框
 /// </summary>
 /// <param name="moduleID"></param>
 /// <param name="templeteContent"></param>
 /// <param name="isDirectPrint"></param>
 /// <returns></returns>
 public int Print(string moduleID, PrintTempleteContentInfo templeteContent, bool isPopUpPrintDialog)
 {
     _CurrentTempleteContent = templeteContent;
     DIYReport.ReportModel.RptReport report = createRptReport(moduleID, templeteContent);
     if (report != null)
     {
         if (!isPopUpPrintDialog)
         {
             PrinterSettings settings = new PrinterSettings();
             report.PrintName = settings.PrinterName;
         }
         DIYReport.UserDIY.DesignEnviroment.CurrentReport = report;
         DIYReport.Extend.Print.XPrintingSystem printSystem = new DIYReport.Extend.Print.XPrintingSystem();
         printSystem.Print(report);
     }
     else
     {
         throw new MB.Util.APPException(string.Format("该报表模板 {0} 还没有开始绘制,请在报表打印设计器中先设计。", templeteContent.Name), MB.Util.APPMessageType.DisplayToUser);
     }
     return(0);
 }
コード例 #7
0
 /// <summary>
 /// 报表直接打印。弹出打印对话框
 /// </summary>
 /// <param name="moduleID"></param>
 /// <param name="templeteID"></param>
 /// <param name="parmValues"></param>
 /// <returns></returns>
 public int Print(string moduleID, PrintTempleteContentInfo templeteContent)
 {
     return(Print(moduleID, templeteContent, true));
 }