Пример #1
0
        /// <summary>
        /// 设置打印页面。
        /// </summary>
        /// <param name="dataReport"></param>
        public void PageSetup(DIYReport.ReportModel.RptReport dataReport)
        {
            SetPrintPageInfo(dataReport);
            bool re = printingSystem.PageSetup();

            if (re)
            {
                dataReport.IsLandscape    = printingSystem.PageSettings.Landscape;
                dataReport.Margins.Left   = printingSystem.PageSettings.LeftMargin;
                dataReport.Margins.Top    = printingSystem.PageSettings.TopMargin;
                dataReport.Margins.Right  = printingSystem.PageSettings.RightMargin;
                dataReport.Margins.Bottom = printingSystem.PageSettings.BottomMargin;

                dataReport.PaperKind = printingSystem.PageSettings.PaperKind;
                dataReport.PaperName = printingSystem.PageSettings.PaperName;
                dataReport.PaperSize = DIYReport.Print.RptPageSetting.GetPaperSizeByName(dataReport.PrintDocument, dataReport.PrintName, dataReport.PaperName);
                if (dataReport.ReportDataWidth > 0 && dataReport.ReportDataWidth > dataReport.PaperSize.Width - dataReport.Margins.Left - dataReport.Margins.Right)
                {
                    dataReport.ReportDataWidth = dataReport.PaperSize.Width - dataReport.Margins.Left - dataReport.Margins.Right;
                }

                //System.Windows.Forms.MessageBox.Show("当前PageName" + dataReport.PaperName);

                savePageSetting(dataReport, dataReport.Margins, dataReport.PaperName, dataReport.PaperKind.ToString());
            }
        }
Пример #2
0
        //创建打印的link
        public DevExpress.XtraPrinting.Link CreateLinkDoc(string paperName, DIYReport.ReportModel.RptReport dataReport)
        {
            SetPrintPageInfo(dataReport);

            _DrawObj = new XPrintDocument(dataReport);
            printingSystem.Links.Clear();

            DevExpress.XtraPrinting.Link linkDoc = new MyPrintLink(paperName, printingSystem);           //  DevExpress.XtraPrinting.Link();

            //printingSystem.Links.Add(linkDoc);


            linkDoc.EnablePageDialog = false;


            //linkDoc.PrintingSystem = printingSystem;

            linkDoc.CreateReportHeaderArea   += new DevExpress.XtraPrinting.CreateAreaEventHandler(linkDoc_CreateReportHeaderArea);
            linkDoc.CreateMarginalHeaderArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(linkDoc_CreateMarginalHeaderArea);
            linkDoc.CreateDetailHeaderArea   += new DevExpress.XtraPrinting.CreateAreaEventHandler(linkDoc_CreateDetailHeaderArea);
            linkDoc.CreateDetailArea         += new DevExpress.XtraPrinting.CreateAreaEventHandler(linkDoc_CreateDetailArea);
            linkDoc.CreateDetailFooterArea   += new DevExpress.XtraPrinting.CreateAreaEventHandler(linkDoc_CreateDetailFooterArea);
            linkDoc.CreateMarginalFooterArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(linkDoc_CreateMarginalFooterArea);
            linkDoc.CreateReportFooterArea   += new DevExpress.XtraPrinting.CreateAreaEventHandler(linkDoc_CreateReportFooterArea);


            return(linkDoc);
        }
Пример #3
0
 /// <summary>
 /// 保存报表。 (目前把它当做,报表的导出功能来使用)
 /// </summary>
 /// <param name="pReport"></param>
 /// <returns></returns>
 public bool Save(DIYReport.ReportModel.RptReport pReport)
 {
     System.Windows.Forms.SaveFileDialog fileDialog = new System.Windows.Forms.SaveFileDialog();;
     fileDialog.Filter           = "报表文件 (*.rpt)|*.rpt";
     fileDialog.FilterIndex      = 1;
     fileDialog.RestoreDirectory = true;
     if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         string filePath = fileDialog.FileName;
         _CurrentProcessFilePath = System.IO.Path.GetDirectoryName(filePath);
         if (filePath == null || filePath.Length == 0)
         {
             return(false);
         }
         bool b = System.IO.Directory.Exists(_CurrentProcessFilePath);
         if (!b)
         {
             System.IO.Directory.CreateDirectory(_CurrentProcessFilePath);
         }
         pReport.RptFilePath = filePath;
         XmlDocument doc = new XmlDocument();
         try{
             doc.LoadXml(buildXMLString(pReport));
             doc.Save(filePath);
             System.Windows.Forms.MessageBox.Show("报表导出成功!", "导出报表操作提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
             return(true);
         }
         catch (Exception e) {
             Debug.Assert(false, "报表存储出错!", e.Message);
             System.Windows.Forms.MessageBox.Show("报表导出失败!", "导出报表操作提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
             return(false);
         }
     }
     return(false);
 }
Пример #4
0
        /// <summary>
        ///  根据报表对象构建对应的xml 文档字符窜。
        /// </summary>
        /// <param name="pReport"></param>
        /// <returns></returns>
        public string BuildXMLString(DIYReport.ReportModel.RptReport pReport)
        {
            StringBuilder xmlSB = new StringBuilder();

            //描述
            xmlSB.Append("<?xml version='1.0' encoding='utf-8' ?>");
            xmlSB.Append("<!-- 用户自定义智能报表中心生成的报表 -->");

            writeFirstMarker(xmlSB, pReport.GetType().FullName);
            xmlSB.Append(reportString(pReport));
            DIYReport.ReportModel.RptSectionList sectionList = pReport.SectionList;

            writeFirstMarker(xmlSB, ReportXmlHelper.SECTION_LIST_MARKER);
            foreach (DIYReport.ReportModel.RptSection section in  sectionList)
            {
                writeFirstMarker(xmlSB, section.GetType().FullName);

                xmlSB.Append(sectionString(section));
                writeFirstMarker(xmlSB, ReportXmlHelper.RPT_OBJ_LIST_MARKER);
                DIYReport.ReportModel.RptSingleObjList rptObjList = section.RptObjList;
                foreach (DIYReport.Interface.IRptSingleObj rptObj in rptObjList)
                {
                    writeFirstMarker(xmlSB, rptObj.GetType().FullName);
                    xmlSB.Append(objectToXml(rptObj));
                    writeLastMarker(xmlSB, rptObj.GetType().FullName);
                }
                writeLastMarker(xmlSB, ReportXmlHelper.RPT_OBJ_LIST_MARKER);
                writeLastMarker(xmlSB, section.GetType().FullName);
            }
            writeLastMarker(xmlSB, ReportXmlHelper.SECTION_LIST_MARKER);
            writeLastMarker(xmlSB, pReport.GetType().FullName);
            return(xmlSB.ToString());
        }
Пример #5
0
        private string reportString(DIYReport.ReportModel.RptReport pReport)
        {
            StringBuilder xmlSB = new StringBuilder();

            xmlSB.Append("<RptReport ID = '" + pReport.ID.ToString() + "' Name='" + pReport.Name + "'");
            if (pReport.Text != null && pReport.Text.Trim() != "")
            {
                xmlSB.Append(" Text ='" + pReport.Text + "'");
            }
            //add by Nick 2005-01-27
            xmlSB.Append(" GroupLayoutType ='" + ((int)pReport.GroupLayoutType).ToString() + "'");
            xmlSB.Append(" DetailOrderString ='" + pReport.DetailOrderString + "'");

            xmlSB.Append(" Width = '" + pReport.PaperSize.Width.ToString() + "'");
            xmlSB.Append(" Height = '" + pReport.PaperSize.Height.ToString() + "'");
            xmlSB.Append(" PaperName = '" + pReport.PaperSize.PaperName + "'");

            xmlSB.Append(" PrintName = '" + pReport.PrintName + "'");

            xmlSB.Append(" IsLandscape = '" + pReport.IsLandscape.ToString() + "'");

            xmlSB.Append(" Margins-Left='" + pReport.Margins.Left.ToString() + "'");
            xmlSB.Append(" Margins-Top ='" + pReport.Margins.Top.ToString() + "'");
            xmlSB.Append(" Margins-Right ='" + pReport.Margins.Right.ToString() + "'");
            xmlSB.Append(" Margins-Bottom ='" + pReport.Margins.Bottom.ToString() + "'");

            xmlSB.Append(" FillNULLRow = '" + pReport.FillNULLRow.ToString() + "'");
            xmlSB.Append(">");

            return(xmlSB.ToString());
        }
Пример #6
0
        public virtual bool SaveReport(DIYReport.ReportModel.RptReport pReport, string pFullPath)
        {
            _CurrentProcessFilePath = System.IO.Path.GetDirectoryName(pFullPath);
            if (pFullPath == null || pFullPath == "")
            {
                //_CurrentProcessFilePath = REPORT_FILE_PATH;
                return(Save(pReport));
            }
            bool b = System.IO.Directory.Exists(_CurrentProcessFilePath);

            if (!b)
            {
                System.IO.Directory.CreateDirectory(_CurrentProcessFilePath);
            }
            XmlDocument doc = new XmlDocument();

            try{
                doc.LoadXml(buildXMLString(pReport));
                doc.Save(pFullPath);
                return(true);
            }
            catch (Exception e) {
                Debug.Assert(false, "报表存储出错!", e.Message);
                return(false);
            }
        }
Пример #7
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));
            }
        }
Пример #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pReport"></param>
 public FrmPageSetting(DIYReport.ReportModel.RptReport pReport)
 {
     InitializeComponent();
     _Report = pReport;
     addToPaperName();
     iniPageSetting();
 }
Пример #9
0
        /// <summary>
        /// 创建一个新的报表
        /// </summary>
        /// <returns></returns>
        public DIYReport.ReportModel.RptReport CreateNewReport()
        {
            _DataObj = _ReportIO.NewReport();

            iniNewReportDesign();

            DesignEnviroment.DesignHasChanged = false;
            return(_DataObj);
        }
Пример #10
0
 public ReportDrawInfo(DIYReport.ReportModel.RptReport _Report)
 {
     DIYReport.ReportModel.RptSectionList sectionList = _Report.SectionList;
     _TitleHeight      = sectionList.GetSectionHeightByType(DIYReport.SectionType.ReportTitle);
     _PageHeadHeight   = sectionList.GetSectionHeightByType(DIYReport.SectionType.PageHead);
     _DetailHeight     = sectionList.GetSectionHeightByType(DIYReport.SectionType.Detail);
     _PageFooterHeight = sectionList.GetSectionHeightByType(DIYReport.SectionType.PageFooter);
     _BottomHeight     = sectionList.GetSectionHeightByType(DIYReport.SectionType.ReportBottom);
 }
Пример #11
0
        private void readPageSetting(DIYReport.ReportModel.RptReport dataReport, DevExpress.XtraPrinting.Link printLink)
        {
            string sessionName = getSessionName(dataReport);

            System.Drawing.Printing.Margins margins = printLink.Margins;
            margins.Left   = int.Parse(IniFile.ReadString(sessionName, "LeftMargin", margins.Left.ToString(), DIY_REPORT_CFG_FILE));
            margins.Top    = int.Parse(IniFile.ReadString(sessionName, "TopMargin", margins.Top.ToString(), DIY_REPORT_CFG_FILE));
            margins.Right  = int.Parse(IniFile.ReadString(sessionName, "RightMargin", margins.Right.ToString(), DIY_REPORT_CFG_FILE));
            margins.Bottom = int.Parse(IniFile.ReadString(sessionName, "BottomMargin", margins.Bottom.ToString(), DIY_REPORT_CFG_FILE));
        }
Пример #12
0
//		private void timer1_Tick(object sender, System.EventArgs e) {
//			//刷新控件的属性
//			object obj = _Report.CurrentObj;
//			if(pgridMain.SelectedObject==null || pgridMain.SelectedObject.Equals(obj)!=false){
//				pgridMain.SelectedObject =  _Report.CurrentObj ;
//			}
//		}

//		[DllImport("User32.dll")]
//		private static extern bool SetWindowPos(IntPtr hwnd,int hWndInsertAfter,int x,int y,int cx,int cy,int wFlagslong);
        #region Public 方法...
        /// <summary>
        /// 设置对象的属性。
        /// </summary>
        /// <param name="report"></param>
        /// <param name="pObject"></param>
        public void SetPropertryObject(DIYReport.ReportModel.RptReport report, object pObject)
        {
            _Report = report;

            pgridMain.SelectedObject = pObject;
            if (pObject != null)
            {
                addCtlToList();
                displaySelectedNode(pObject);
            }
        }
Пример #13
0
        /// <summary>
        /// 通过子报表的名称获取子报表的设计内容。
        /// </summary>
        /// <param name="reportName"></param>
        /// <returns></returns>
        public DIYReport.ReportModel.RptReport GetReportContent(string reportName)
        {
            var childInfo = _PrintTemplete.Childs.FirstOrDefault(o => string.Compare(o.Name, reportName, true) == 0);

            if (childInfo == null)
            {
                return(null);
            }
            DIYReport.ReportModel.RptReport reportContent = DIYReport.ReportReader.Instance().ReadFromXmlString(childInfo.TempleteXmlContent);

            return(reportContent);
        }
Пример #14
0
        /// <summary>
        /// 打开已经存在的报表
        /// </summary>
        /// <param name="pReport"></param>
        /// <returns></returns>
        public DIYReport.ReportModel.RptReport OpenReport(DIYReport.ReportModel.RptReport pReport)
        {
            if (pReport != null)
            {
                _DataObj = pReport;
                //判断是否有分组的Section,初始化分组设计的字段,然后当前设计的字段引用到分组的Section 中
                iniGroupFieldOnOpen(_DataObj);

                iniNewReportDesign();
            }
            DesignEnviroment.DesignHasChanged = false;
            return(_DataObj);
        }
Пример #15
0
        /// <summary>
        /// 把报表打印的数据按照统计分组的方式进行排序;
        /// </summary>
        /// <param name="pDs"></param>
        /// <param name="pDataReport"></param>
        /// <returns></returns>
        public static DataRow[] SortData(object pDs, DIYReport.ReportModel.RptReport pDataReport)
        {
            if (pDs == null)
            {
                return(new DataRow[0]);
            }
            DataView dv = PublicFun.GetDataViewByObject(pDs);

            //构造排序的字符窜
            string sortStr = getSortStr(dv.Table, pDataReport);

            return(dv.Table.Select(dv.RowFilter, sortStr));
        }
Пример #16
0
        //加载RptSection 的数据
        private void createSection(DIYReport.ReportModel.RptReport pReport, XmlNodeList pSectionList)
        {
            foreach (XmlNode node in pSectionList)
            {
                int sectionType = PublicFun.ToInt(node.Attributes["SectionType"].Value);
                DIYReport.ReportModel.RptSection section = new DIYReport.ReportModel.RptSection((DIYReport.SectionType)sectionType);
                section.Name   = node.Attributes["Name"].Value;
                section.Height = PublicFun.ToInt(node.Attributes["Height"].Value);
                section.Width  = PublicFun.ToInt(node.Attributes["Width"].Value);
                //add by nick 2005-01-27
                if (node.Attributes["Index"] != null)
                {
                    section.Index = PublicFun.ToInt(node.Attributes["Index"].Value);
                }
//				xmlSB.Append(" GroupField_Name ='" + pSection.GroupField.FieldName + "'");
//				xmlSB.Append(" GroupField_IsAscending ='" + pSection.GroupField.IsAscending.ToString() + "'");
//				xmlSB.Append(" GroupField_OrderIndex ='" + pSection.GroupField.OrderIndex.ToString() + "'");
//				xmlSB.Append(" GroupField_SetSort ='" + pSection.GroupField.SetSort.ToString()  + "'");
//				xmlSB.Append(" GroupField_DivideName ='" + pSection.GroupField.DivideName  + "'");

                if (node.Attributes["GroupField_Name"] != null)
                {
                    string gName = node.Attributes["GroupField_Name"].Value;
                    DIYReport.GroupAndSort.RptFieldInfo field = new DIYReport.GroupAndSort.RptFieldInfo(gName);
                    if (node.Attributes["GroupField_IsAscending"] != null)
                    {
                        field.IsAscending = bool.Parse(node.Attributes["GroupField_IsAscending"].Value);
                    }
                    if (node.Attributes["GroupField_OrderIndex"] != null)
                    {
                        field.OrderIndex = int.Parse(node.Attributes["GroupField_OrderIndex"].Value);
                    }
                    if (node.Attributes["GroupField_SetSort"] != null)
                    {
                        field.SetSort = bool.Parse(node.Attributes["GroupField_SetSort"].Value);
                    }
                    if (node.Attributes["GroupField_DivideName"] != null)
                    {
                        field.DivideName = node.Attributes["GroupField_DivideName"].Value;
                    }
                    section.GroupField = field;
                }

                pReport.SectionList.Add(section);
                //增加Section 总的RptObject
                createRptObj(section, node.ChildNodes);
                section.Report = pReport;
            }
        }
Пример #17
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();
        }
Пример #18
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);
     }
 }
Пример #19
0
        //保存在浏览中设置的边框
        private void savePageSetting(DIYReport.ReportModel.RptReport dataReport, System.Drawing.Printing.Margins margins, string paperName, string paperKind)
        {
            string sessionName = getSessionName(dataReport);

            IniFile.WriteString(sessionName, "LeftMargin", margins.Left.ToString(), DIY_REPORT_CFG_FILE);
            IniFile.WriteString(sessionName, "TopMargin", margins.Top.ToString(), DIY_REPORT_CFG_FILE);
            IniFile.WriteString(sessionName, "RightMargin", margins.Right.ToString(), DIY_REPORT_CFG_FILE);
            IniFile.WriteString(sessionName, "BottomMargin", margins.Bottom.ToString(), DIY_REPORT_CFG_FILE);
            if (paperKind != null && paperKind.Length > 0)
            {
                IniFile.WriteString(sessionName, "PaperKind", paperKind, DIY_REPORT_CFG_FILE);
            }
            if (paperName != null && paperName.Length > 0)
            {
                IniFile.WriteString(sessionName, "PaperName", paperName, DIY_REPORT_CFG_FILE);
            }
        }
Пример #20
0
        /// <summary>
        /// 文档预览...
        /// </summary>
        public void PrintPreview(DIYReport.ReportModel.RptReport dataReport)
        {
            string sessionName = getSessionName(dataReport);;

            SetPrintPageInfo(dataReport);
            string pagerName = IniFile.ReadString(sessionName, "PaperName", printingSystem.PageSettings.PaperName, DIY_REPORT_CFG_FILE);

            if (pagerName == null || pagerName.Length == 0)
            {
                pagerName = printingSystem.PageSettings.PaperName;
            }

            DevExpress.XtraPrinting.Link link = CreateLinkDoc(pagerName, dataReport);

            readPageSetting(dataReport, link);

            try{
                //System.Windows.Forms.MessageBox.Show("当前PageName" + pagerName);
                string kindName = IniFile.ReadString(sessionName, "PaperKind", printingSystem.PageSettings.PaperKind.ToString(), DIY_REPORT_CFG_FILE);
                System.Drawing.Printing.PaperKind pKind = (System.Drawing.Printing.PaperKind)Enum.Parse(typeof(System.Drawing.Printing.PaperKind), kindName, true);
                link.PrintingSystem.PageSettings.PaperKind = pKind;
            }
            catch {}

            link.Landscape = printingSystem.PageSettings.Landscape;
            link.PaperKind = link.PrintingSystem.PageSettings.PaperKind;
            //link.PrintingSystem.PageSettings.PaperName = pagerName;
            link.ShowPreviewDialog();
            // link.ShowRibbonPreview(DevExpress.LookAndFeel.UserLookAndFeel.Default);

            savePageSetting(dataReport, link.Margins, link.PrintingSystem.PageSettings.PaperName, link.PaperKind.ToString());

            //System.Windows.Forms.MessageBox.Show(printingSystem.PageSettings.LeftMargin.ToString());
//			if(_DrawObj!=null)
//				_DrawObj.Dispose();
            //也可以用下面的方法来实现。
//			DevExpress.XtraPrinting.Preview.PrintPreviewForm frm = new DevExpress.XtraPrinting.Preview.PrintPreviewForm();
//			frm.PrintingSystem = this.PrintingSystem;
//
//			link.CreateDocument();
//			frm.ShowDialog();
        }
Пример #21
0
        /// <summary>
        /// 根据dataReport 设置printingSystem 的 pageSetting 信息。
        /// </summary>
        /// <param name="dataReport"></param>
        public void SetPrintPageInfo(DIYReport.ReportModel.RptReport dataReport)
        {
            var existsPrinter = DIYReport.Common.EnumPrintersHelperEx.CheckExistsPrinter(dataReport.PrintName);

            if (existsPrinter)
            {
                printingSystem.PageSettings.PrinterName = dataReport.PrintName;
            }

            printingSystem.PageSettings.Landscape = dataReport.IsLandscape;

            System.Drawing.Printing.Margins mrg = dataReport.Margins;             //DIYReport.PublicFun.GetRegionMargins(dataReport.Margins);
            printingSystem.PageSettings.LeftMargin   = mrg.Left;
            printingSystem.PageSettings.TopMargin    = mrg.Top;
            printingSystem.PageSettings.RightMargin  = mrg.Right;
            printingSystem.PageSettings.BottomMargin = mrg.Bottom;

            printingSystem.PageSettings.PaperKind = dataReport.PaperKind;
            printingSystem.PageSettings.PaperName = dataReport.PaperName;
        }
Пример #22
0
        /// <summary>
        ///  根据DesignEnviroment中的DesignField构造出一个绘制Detail临时存储的信息
        /// </summary>
        /// <param name="pDataReport"></param>
        public DrawDetailInfo(DIYReport.ReportModel.RptReport report)
        {
            //-1 表示当前页还没有开始绘制
            _CurrPageFirstRowIndex = -1;
            _CurrPageNumber        = -1;

            IList fieldList = report.DesignField;

            //对分组的字段进行排序,以获取分组字段的顺序
            (fieldList as ArrayList).Sort(new FieldSortComparer());
            _GroupFields = new ArrayList();
            foreach (DIYReport.GroupAndSort.RptFieldInfo field in fieldList)
            {
                if (field.IsGroup)
                {
                    DrawGroupField drwafield = new DrawGroupField(-1, field.FieldName);
                    _GroupFields.Add(drwafield);
                }
            }
        }
Пример #23
0
        /// <summary>
        ///  根据指定的报表文件打开一张报表
        /// </summary>
        /// <param name="pFullPath"></param>
        /// <returns></returns>
        public static DIYReport.ReportModel.RptReport OpenReport(string pFullPath)
        {
            bool b = System.IO.File.Exists(pFullPath);

            if (b)
            {
                try{
                    XmlDocument doc = new XmlDocument();
                    doc.Load(pFullPath);

                    DIYReport.ReportModel.RptReport report = ReportReader.Instance().BuildReport(doc);

                    report.RptFilePath = pFullPath;
                    return(report);
                }
                catch (Exception e) {
                    Debug.Assert(false, "打开报表出错!", e.Message);
                }
            }
            return(null);
        }
Пример #24
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);
 }
Пример #25
0
        /// <summary>
        /// 打印..
        /// </summary>
        public void Print(DIYReport.ReportModel.RptReport dataReport)
        {
            string sessionName = getSessionName(dataReport);;

            SetPrintPageInfo(dataReport);
            string pagerName = IniFile.ReadString(sessionName, "PaperName", printingSystem.PageSettings.PaperName, DIY_REPORT_CFG_FILE);

            if (pagerName == null || pagerName.Length == 0)
            {
                pagerName = printingSystem.PageSettings.PaperName;
            }

            DevExpress.XtraPrinting.Link link = CreateLinkDoc(pagerName, dataReport);

            readPageSetting(dataReport, link);

            try {
                //System.Windows.Forms.MessageBox.Show("当前PageName" + pagerName);
                string kindName = IniFile.ReadString(sessionName, "PaperKind", printingSystem.PageSettings.PaperKind.ToString(), DIY_REPORT_CFG_FILE);
                System.Drawing.Printing.PaperKind pKind = (System.Drawing.Printing.PaperKind)Enum.Parse(typeof(System.Drawing.Printing.PaperKind), kindName, true);
                link.PrintingSystem.PageSettings.PaperKind = pKind;
            }
            catch { }

            link.Landscape = printingSystem.PageSettings.Landscape;
            link.PaperKind = link.PrintingSystem.PageSettings.PaperKind;

            var existsPrinter = DIYReport.Common.EnumPrintersHelperEx.CheckExistsPrinter(dataReport.PrintName);

            if (existsPrinter)
            {
                link.Print(dataReport.PrintName);
            }
            else
            {
                link.PrintDlg();
            }
//			if(_DrawObj!=null)
//				_DrawObj.Dispose();
        }
Пример #26
0
        private static double SEP_MINI = System.Convert.ToDouble(65 / 25.4f);         // System.Convert.ToDecimal(3.938)  ;//
        /// <summary>
        /// 调用页面设置的窗口
        /// </summary>
        /// <param name="printDocument"></param>
        /// <returns></returns>
        public static void ShowPageSetupDialog(DIYReport.ReportModel.RptReport pReport)
        {
            PageSettings ps = new PageSettings();

            try {
                PageSetupDialog psDlg = new PageSetupDialog();
                psDlg.Document = pReport.PrintDocument;

                //pReport.PrintDocument.DefaultPageSettings.Margins = pReport.Margins;
                pReport.PrintDocument.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(pReport.Margins.Left,
                                                                                                        pReport.Margins.Right,
                                                                                                        pReport.Margins.Top,
                                                                                                        pReport.Margins.Bottom);

                psDlg.PageSettings = pReport.PrintDocument.DefaultPageSettings;
                //psDlg.AllowPaper = true;
                DialogResult result = psDlg.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ps = psDlg.PageSettings;
                    pReport.PrintDocument.DefaultPageSettings = psDlg.PageSettings;
                    pReport.Margins = convertTomini(psDlg.PageSettings.Margins);
                    pReport.PrintDocument.DefaultPageSettings.Margins = pReport.Margins;
                    pReport.PaperSize   = psDlg.PageSettings.PaperSize;
                    pReport.IsLandscape = psDlg.PageSettings.Landscape;
                }
            }
            catch (System.Drawing.Printing.InvalidPrinterException e) {
                MessageBox.Show("未安装打印机,请进入系统控制面版添加打印机!", "打印", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Debug.Assert(false, e.Message, "打印");
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "打印", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            //	return ps;
//
//			FrmPageSetting frm = new FrmPageSetting(pReport);
//			frm.ShowDialog();
        }
Пример #27
0
        private string buildXMLString(DIYReport.ReportModel.RptReport pReport)
        {
            StringBuilder xmlSB = new StringBuilder();

            //描述
            xmlSB.Append("<?xml version='1.0' encoding='utf-8' ?>");
            xmlSB.Append("<!-- 用户自定义智能报表中心生成的报表 -->");
            xmlSB.Append(reportString(pReport));
            DIYReport.ReportModel.RptSectionList sectionList = pReport.SectionList;
            foreach (DIYReport.ReportModel.RptSection section in  sectionList)
            {
                xmlSB.Append(sectionString(section));
                DIYReport.ReportModel.RptSingleObjList rptObjList = section.RptObjList;
                foreach (DIYReport.Interface.IRptSingleObj rptObj in rptObjList)
                {
                    xmlSB.Append(rptObjString(rptObj));
                }
                xmlSB.Append("</RptSection>");
            }
            xmlSB.Append("</RptReport>");
            return(xmlSB.ToString());
        }
Пример #28
0
        /// <summary>
        ///  根据指定的报表文件打开一张报表
        /// </summary>
        /// <param name="pFullPath"></param>
        /// <returns></returns>
        public virtual DIYReport.ReportModel.RptReport OpenReport(string pFullPath)
        {
            bool b = System.IO.File.Exists(pFullPath);

            if (b)
            {
                try{
                    XmlDocument doc = new XmlDocument();
                    doc.Load(pFullPath);
                    XmlNode node = doc.SelectSingleNode(REPORT_NODE);
                    _CurrentProcessFilePath = System.IO.Path.GetDirectoryName(pFullPath);
                    DIYReport.ReportModel.RptReport report = createReportData(node);

                    report.RptFilePath = pFullPath;
                    return(report);
                }
                catch (Exception e) {
                    Debug.Assert(false, "打开报表出错!", e.Message);
                }
            }
            return(null);
        }
Пример #29
0
        //构造排序的字符窜
        private static string getSortStr(DataTable pDt, DIYReport.ReportModel.RptReport pDataReport)
        {
            DIYReport.ReportModel.RptSectionList sectionList = pDataReport.SectionList;
            string filterStr = "";

            foreach (DIYReport.ReportModel.RptSection section in sectionList)
            {
                if (section.SectionType == DIYReport.SectionType.GroupHead)
                {
                    string asc   = section.GroupField.IsAscending ? " ASC ," :" DESC ,";
                    string sname = section.GroupField.FieldName;
                    if (pDt.Columns.Contains(sname))
                    {
                        filterStr += section.GroupField.FieldName + asc;
                    }
                }
            }
            if (filterStr != "")
            {
                filterStr = filterStr.Remove(filterStr.Length - 1, 1);
            }
            return(filterStr);
        }
Пример #30
0
 //
 /// <summary>
 /// 初始化分组设计的字段,然后当前设计的字段引用到分组的Section 中
 /// </summary>
 /// <param name="pReport"></param>
 public static void IniGroupFieldOnOpen(DIYReport.ReportModel.RptReport pReport)
 {
     //判断是否有分组的Section
     DIYReport.ReportModel.RptSectionList sectionList = pReport.SectionList;
     foreach (DIYReport.ReportModel.RptSection section in sectionList)
     {
         if (section.SectionType == SectionType.GroupHead || section.SectionType == SectionType.GroupFooter)
         {
             DIYReport.GroupAndSort.RptFieldInfo groupField = section.GroupField;
             if (groupField == null)
             {
                 Debug.Assert(false, "在获取报表的分组Section 时,得到字段的信息为空。");
             }
             IList fieldList = pReport.DesignField;
             if (fieldList == null)
             {
                 Debug.Assert(false, "没有初始化设计的字段。");
             }
             int count = fieldList.Count;
             for (int i = 0; i < count; i++)
             {
                 DIYReport.GroupAndSort.RptFieldInfo designField = fieldList[i] as DIYReport.GroupAndSort.RptFieldInfo;
                 if (designField.FieldName.Trim().ToUpper() == groupField.FieldName.Trim().ToUpper())
                 {
                     designField.IsGroup     = true;
                     designField.IsAscending = groupField.IsAscending;
                     designField.OrderIndex  = groupField.OrderIndex;
                     designField.SetSort     = groupField.SetSort;
                     designField.DivideName  = groupField.DivideName;
                     section.GroupField      = designField;
                     break;
                 }
             }
         }
     }
 }