public static RptReport NewReport(string pReportName, System.Guid pRptID) { RptReport report = new RptReport(); report.ID = pRptID; if (pReportName != null && pReportName != "") { report.Name = pReportName; } else { report.Name = "Bank-Report" + System.DateTime.Now.ToShortDateString() + System.DateTime.Now.Millisecond.ToString(); } //PageSettings ps = DIYReport.Print.RptPageSetting.GetDefaultPageSetting(); int paperWidth = report.IsLandscape?report.PaperSize.Height:report.PaperSize.Width; int reportDetailWidth = paperWidth - report.Margins.Left - report.Margins.Right; DIYReport.ReportModel.RptSection section = new DIYReport.ReportModel.RptSection(DIYReport.SectionType.Detail); section.Width = reportDetailWidth; section.Report = report; section.Height = 3 * DEFAULT_SELCTION_HEIGHT; report.SectionList.Add(section); report.Width = report.PaperSize.Width; report.Height = report.PaperSize.Height; return(report); }
private DesignSection getDesignSectionByDataSection(DIYReport.ReportModel.RptSection rptSection) { foreach (DesignSection section in this) { if (section.DataObj.Equals(rptSection)) { return(section); } } return(null); }
//加载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; } }
//把对象集合中需要统计计算的对象加入到表达的集合中 //把需要统计的字段加上表达试做为主键 #region 构造函数... /// <summary> /// /// </summary> /// <param name="pObjects"></param> public ExpressValueList(DIYReport.ReportModel.RptSection pSection) { if (pSection != null) { DIYReport.ReportModel.RptSingleObjList objList = pSection.RptObjList; foreach (DIYReport.ReportModel.RptSingleObj obj in objList) { if (obj.Type == DIYReport.ReportModel.RptObjType.Express) { DIYReport.ReportModel.RptObj.RptExpressBox box = obj as DIYReport.ReportModel.RptObj.RptExpressBox; if (box.ExpressType == DIYReport.ReportModel.ExpressType.Express) { this.Add(new ExpressValue(obj)); } //end if } //end if } //end foreach } //end if }
private void _DataObj_BeforeRemoveSection(object sender, DIYReport.ReportModel.RptSection e) { DesignSection deSection = null; foreach (DesignSection section in this) { if (section.DataObj.Equals(e)) { deSection = section; break; } } if (deSection != null) { OnBeforeRemoveSection(new DesignSectionEventArgs(-1, deSection)); this.Remove(deSection); } //在删除Section 后重新布置 RefreshDesignLayout(); }
public static bool ValueInTheGroup(DIYReport.ReportModel.RptSection pGroupSection, object pGroupValue, object pValue) { if (pGroupValue == null) { return(true); } //先处理简单的相等分组 if (pGroupValue == System.DBNull.Value) { if (pValue == System.DBNull.Value) { return(true); } } if (pValue == System.DBNull.Value) { return(false); } return(pGroupValue.ToString() == pValue.ToString()); }
private string sectionString(DIYReport.ReportModel.RptSection pSection) { StringBuilder xmlSB = new StringBuilder(); xmlSB.Append("<RptSection Name = '" + pSection.Name + "'"); xmlSB.Append(" Height ='" + pSection.Height.ToString() + "'"); xmlSB.Append(" Width ='" + pSection.Width.ToString() + "'"); xmlSB.Append(" SectionType = '" + ((int)pSection.SectionType).ToString() + "'"); //add by nick 2005-01-27 xmlSB.Append(" Index ='" + pSection.Index.ToString() + "'"); if (pSection.GroupField != null) { 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 + "'"); } // xmlSB.Append(" GroupFieldName ='" + pSection.GroupFieldName + "'"); // xmlSB.Append(" OrderType ='" + pSection.OrderType + "'"); xmlSB.Append(">"); return(xmlSB.ToString()); }
private void createRptObj(DIYReport.ReportModel.RptSection pSection, XmlNodeList pSectionList) { foreach (XmlNode node in pSectionList) { DIYReport.ReportModel.RptSingleObj obj = new DIYReport.ReportModel.RptSingleObj(); int objType = PublicFun.ToInt(node.Attributes["Type"].Value); DIYReport.ReportModel.RptObjType type = (DIYReport.ReportModel.RptObjType)objType; string objName = node.Attributes["Name"].Value; DIYReport.Interface.IRptSingleObj singObj = RptObjectHelper.CreateObj(type); // switch(type){ // case DIYReport.ReportModel.RptObjType.Line: // singObj = new DIYReport.ReportModel.RptObj.RptLine(objName); // break; // case DIYReport.ReportModel.RptObjType.Rect: // singObj = new DIYReport.ReportModel.RptObj.RptRect(objName); // break; // case DIYReport.ReportModel.RptObjType.Text: // singObj = new DIYReport.ReportModel.RptObj.RptLable(objName); // break; // case DIYReport.ReportModel.RptObjType.Express: // singObj = new DIYReport.ReportModel.RptObj.RptExpressBox(objName); // break; // case DIYReport.ReportModel.RptObjType.Image: // singObj = new DIYReport.ReportModel.RptObj.RptPictureBox(objName); // break; // // default: // Debug.Assert("该对象类型" + type.ToString() + "目前还没有处理."); // break; // } fillInfoToRptObj(singObj, node); singObj.Section = pSection; //把控件增加到Section 中 pSection.RptObjList.Add(singObj); } }
public IRptSingleObj AddByType(DIYReport.ReportModel.RptObjType pType, string pDispText, DIYReport.ReportModel.RptSection pSection) { DIYReport.Interface.IRptSingleObj obj = DIYReport.RptObjectHelper.CreateObj(pType, pDispText); if (obj == null) { return(null); } obj.Name = getObjNewName(obj.GetType().Name); obj.Section = pSection; base.Add(obj); return(obj); }
/// <summary> /// 通过指定的类型增加一个 /// </summary> /// <param name="pType"></param> /// <returns></returns> public IRptSingleObj AddByType(DIYReport.ReportModel.RptObjType pType, DIYReport.ReportModel.RptSection pSection) { return(AddByType(pType, null, pSection)); }
public static ExpressValueList GetFooterExpress(DIYReport.ReportModel.RptReport pDataReport) { DIYReport.ReportModel.RptSection section = pDataReport.SectionList.GetSectionByType(DIYReport.SectionType.PageFooter); return(new ExpressValueList(section)); }
/// <summary> /// 根据xml 文件创建对应的报表对象。 /// </summary> /// <param name="xmlDoc"></param> /// <returns></returns> public DIYReport.ReportModel.RptReport BuildReport(XmlDocument xmlDoc) { bool b = DIYReport.UserDIY.DesignEnviroment.IsUserDesign; DIYReport.ReportModel.RptReport report = null; try{ DIYReport.UserDIY.DesignEnviroment.IsUserDesign = false; XmlNode firstNode = xmlDoc.SelectSingleNode("/" + ReportXmlHelper.REPORT_ROOT); TrackEx.Write("正在加载自定义报表组件:" + ReportXmlHelper.REPORT_ASSEMBLY); System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(ReportXmlHelper.REPORT_ASSEMBLY); TrackEx.Write("自定义报表组件加载成功!"); report = new DIYReport.ReportModel.RptReport(); setObjectProperty(asm, firstNode, report); //报表XML文档的结构为: Report/SelectList/Section/RptObjList/RptObj; //现在晕了: 下次再把下面的代码修改修改 foreach (XmlNode reportNode in firstNode.ChildNodes) { if (string.Compare(reportNode.Name, ReportXmlHelper.SECTION_LIST_MARKER, true) != 0) { continue; } foreach (XmlNode sectionNode in reportNode.ChildNodes) { DIYReport.ReportModel.RptSection rptSection = new DIYReport.ReportModel.RptSection(); rptSection.Report = report; setObjectProperty(asm, sectionNode, rptSection); report.SectionList.Add(rptSection); foreach (XmlNode sectionProNode in sectionNode.ChildNodes) { if (string.Compare(sectionProNode.Name, ReportXmlHelper.RPT_OBJ_LIST_MARKER, true) != 0) { continue; } foreach (XmlNode rptObjNode in sectionProNode.ChildNodes) { object rptObj = asm.CreateInstance(rptObjNode.Name); if (rptObj == null) { continue; } setObjectProperty(asm, rptObjNode, rptObj); DIYReport.Interface.IRptSingleObj rpt = rptObj as DIYReport.Interface.IRptSingleObj; if (rpt != null) { rptSection.RptObjList.Add(rpt); rpt.Section = rptSection; } else { DIYReport.TrackEx.Write("把类型" + rptObj.GetType().FullName + "转换为DIYReport.Interface.IRptSingleObj为空。"); } } } } } //特殊处理一些属性 DIYReport.TrackEx.Write("开始执行获取纸张大小"); report.PaperSize = DIYReport.Print.RptPageSetting.GetSizeByFullInfo(report.PrintDocument, report.PrintName, report.PaperName, report.Width, report.Height); } catch (Exception e) { throw e; } finally{ DIYReport.UserDIY.DesignEnviroment.IsUserDesign = b; } return(report); }
private string sectionString(DIYReport.ReportModel.RptSection pSection) { return(objectToXml(pSection, new string[] { "Name", "SectionType", "Height", "Width", "SectionType", "Index", "GroupField", "BackgroundImage" })); }