using System; using System.Collections; using System.Data; using BP.DA; using BP.En; namespace BP.Sys { /// /// 控件类型 /// public class GroupCtrlType { /// /// 框架 /// public const string Frame = "Frame"; /// /// 从表 /// public const string Dtl = "Dtl"; /// /// 附件 /// public const string Ath = "Ath"; /// /// 审核组件 /// public const string FWC = "FWC"; /// /// 子流程 /// public const string SubFlow = "SubFlow"; /// /// 轨迹 /// public const string Track = "Track"; /// /// 子线程 /// public const string Thread = "Thread"; /// /// 流转自定义组件 /// public const string FTC = "FTC"; /// /// 按钮控件 /// public const string Btn = "Btn"; } /// /// 分组 - 属性 /// public class GroupFieldAttr : EntityOIDAttr { /// /// 表单ID /// public const string FrmID = "FrmID"; /// /// 标签 /// public const string Lab = "Lab"; /// /// 顺序 /// public const string Idx = "Idx"; /// /// 控件类型 /// public const string CtrlType = "CtrlType"; /// /// 控件ID /// public const string CtrlID = "CtrlID"; /// /// PC端是否折叠显示? /// public const string IsZDPC = "IsZDPC"; /// /// 手机端是否折叠显示? /// public const string IsZDMobile = "IsZDMobile"; /// /// 分组显示的模式 显示 PC端折叠 隐藏 /// public const string ShowType = "ShowType"; } /// /// 分组 /// public class GroupField : EntityOID { #region 权限控制 /// /// 权限控制. /// public override UAC HisUAC { get { UAC uac = new UAC(); if (BP.Web.WebUser.No.Equals("admin") == true || BP.Web.WebUser.IsAdmin) { uac.IsDelete = true; uac.IsInsert = false; uac.IsUpdate = true; return uac; } uac.Readonly(); uac.IsView = false; return uac; } } #endregion 权限控制 #region 属性 public bool IsUse = false; /// /// 表单ID /// public string FrmID { get { return this.GetValStrByKey(GroupFieldAttr.FrmID); } set { this.SetValByKey(GroupFieldAttr.FrmID, value); } } public string EnName { get { return this.GetValStrByKey(GroupFieldAttr.FrmID); } set { this.SetValByKey(GroupFieldAttr.FrmID, value); } } /// /// 标签 /// public string Lab { get { return this.GetValStrByKey(GroupFieldAttr.Lab); } set { this.SetValByKey(GroupFieldAttr.Lab, value); } } /// /// 顺序号 /// public int Idx { get { return this.GetValIntByKey(GroupFieldAttr.Idx); } set { this.SetValByKey(GroupFieldAttr.Idx, value); } } /// /// 控件类型 /// public string CtrlType { get { return this.GetValStrByKey(GroupFieldAttr.CtrlType); } set { this.SetValByKey(GroupFieldAttr.CtrlType, value); } } /// /// 控件ID /// public string CtrlID { get { return this.GetValStrByKey(GroupFieldAttr.CtrlID); } set { this.SetValByKey(GroupFieldAttr.CtrlID, value); } } #endregion #region 构造方法 /// /// GroupField /// public GroupField() { } public GroupField(int oid) : base(oid) { } /// /// EnMap /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("Sys_GroupField", "傻瓜表单分组"); #region 字段. map.AddTBIntPKOID(); map.AddTBString(GroupFieldAttr.Lab, null, "标签", true, false, 0, 500, 20, true); map.AddTBString(GroupFieldAttr.FrmID, null, "表单ID", true, true, 0, 200, 20); map.AddTBString(GroupFieldAttr.CtrlType, null, "控件类型", true, false, 0, 50, 20); map.SetHelperUrl("CtrlType", "https://gitee.com/opencc/JFlow/wikis/pages/preview?sort_id=8108065&doc_id=31094"); // map.SetHelperAlert(GroupFieldAttr.CtrlType, "对章节表单有效,类型有:ChapterFrmLinkFrm,Dtl,Ath,FWC"); map.AddTBString(GroupFieldAttr.CtrlID, null, "控件ID", true, false, 0, 500, 20); //map.AddBoolean(GroupFieldAttr.IsZDPC, false, "是否折叠(PC)", true, true); map.AddBoolean(GroupFieldAttr.IsZDMobile, false, "是否折叠(Mobile)", true, true); map.AddDDLSysEnum(GroupFieldAttr.ShowType, 0, "分组显示模式", true, true, GroupFieldAttr.ShowType, "@0=显示@1=PC折叠@2=隐藏"); map.AddTBString("ParentOID", null, "父级", true, false, 0, 128, 20, false); map.SetHelperAlert("ParentOID", "对章节表单有效:章节表单的目录父子关系,默认为0,就是跟目录."); map.AddTBInt(GroupFieldAttr.Idx, 99, "顺序号", true, false); map.AddTBString(MapAttrAttr.GUID, null, "GUID", true, true, 0, 128, 20, true); map.AddTBAtParas(3000); map.AddLang(); //增加多语言. #endregion 字段. #region 方法. RefMethod rm = new RefMethod(); rm = new RefMethod(); rm.Title = "删除隶属分组的字段"; rm.Warning = "您确定要删除该分组下的所有字段吗?"; rm.ClassMethodName = this.ToString() + ".DoDelAllField"; rm.RefMethodType = RefMethodType.Func; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "章节表单分组扩展"; rm.ClassMethodName = this.ToString() + ".DoSetGFType"; // rm.HisAttrs.AddDDLSysEnum("Type", 0, "设置类型", true, true, "MyGFType", "@0=链接到其它表单@1=自定义URL"); rm.HisAttrs.AddTBInt("Type", 0, "设置类型:0链接到其它表单,1自定义URL", true, false); rm.HisAttrs.AddTBString("val", null, "输入对应的值", true, false, 0, 1000, 1000); map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "调整字段顺序"; rm.ClassMethodName = this.ToString() + ".DoGroupFieldIdx"; rm.RefMethodType = RefMethodType.RightFrameOpen; // map.AddRefMethod(rm); #endregion 方法. this._enMap = map; return this._enMap; } } #endregion #region 方法. /// /// 设置分组解析类型(对章节表单有效) /// /// 类型 /// 值 /// 执行结果 public string DoSetGFType(int type, string val) { MapData md = new MapData(this.FrmID); if (md.HisFrmType != FrmType.ChapterFrm) return "err@该设置对章节表单有效."; //链接到其他表单上 if (type == 0) { md.No = val; if (md.RetrieveFromDBSources() == 0) return "err@表单ID输入错误[" + val + "]."; this.CtrlType = "ChapterFrmLinkFrm"; this.CtrlID = val; } //如果是自定义url. if (type == 1) { this.CtrlType = "ChapterFrmSelfUrl"; this.CtrlID = val; } this.Update(); return "执行成功."; } /// /// 外部调用的 /// /// public string AddGroup() { this.InsertAsNew(); return "执行成功."; } /// /// 删除所有隶属该分组的字段. /// /// public string DoDelAllField() { string sql = "DELETE FROM Sys_MapAttr WHERE FK_MapData='" + this.FrmID + "' AND GroupID=" + this.OID + " AND KeyOfEn NOT IN ('OID','RDT','REC','RefPK','FID')"; int i = DBAccess.RunSQL(sql); return "删除字段{" + i + "}个,被删除成功."; } /// /// 分组内的字段顺序调整 /// /// public string DoGroupFieldIdx() { return "../../Admin/FoolFormDesigner/GroupFieldIdx.htm?FrmID=" + this.FrmID + "&GroupField=" + this.OID; } protected override bool beforeUpdate() { string sql = "UPDATE Sys_GroupField SET LAB='" + this.Lab + "' WHERE OID=" + this.OID; DBAccess.RunSQL(sql); return base.beforeUpdate(); } public string DoDown() { this.DoOrderDown(GroupFieldAttr.FrmID, this.FrmID, GroupFieldAttr.Idx); return "执行成功"; } public string DoUp() { this.DoOrderUp(GroupFieldAttr.FrmID, this.FrmID, GroupFieldAttr.Idx); return "执行成功"; } protected override bool beforeDelete() { string sql = "SELECT Name,KeyOfEn FROM Sys_MapAttr WHERE GroupID=" + this.OID; DataTable dt = DBAccess.RunSQLReturnTable(sql); string str = ""; foreach (DataRow dr in dt.Rows) { str += " \t\n" + dr[0].ToString() + " - " + dr[1].ToString(); } if (DataType.IsNullOrEmpty(str) == false) { str = "err@分组ID:" + this.OID + "删除分组错误:如下字段存在,您不能删除:" + str; str += "\t\n 您要删除这个分组,请按照如下操作。"; str += "\t\n 1. 移除字段到其他分组里面去. "; str += "\t\n 2. 删除字段. "; str += "\t\n 3. 如果是隐藏字段,您可以在表单设计器中,表单属性点开隐藏字段,打开隐藏字段,并编辑所在分组. "; str += "\t\n +++++++++ 容器存在的字段 +++++++++++ "; str += "\t\n " + str; throw new Exception(str); } return base.beforeDelete(); } protected override bool beforeInsert() { try { string sql = "SELECT MAX(Idx) FROM " + this.EnMap.PhysicsTable + " WHERE FrmID='" + this.FrmID + "'"; this.Idx = DBAccess.RunSQLReturnValInt(sql, 0) + 1; } catch { this.Idx = 1; } return base.beforeInsert(); } protected override void afterInsertUpdateAction() { if (this.CtrlType.Equals("Frame") == true) { MapFrame frame = new MapFrame(this.CtrlID); if (this.Lab.Equals(frame.Name) == false) { frame.setName(this.Lab); frame.DirectUpdate(); } } base.afterInsertUpdateAction(); } #endregion 方法. } /// /// 分组-集合 /// public class GroupFields : EntitiesOID { #region 构造 /// /// GroupFields /// public GroupFields() { } /// /// GroupFields /// /// 名称 public GroupFields(string enName) { int i = this.Retrieve(GroupFieldAttr.FrmID, enName, GroupFieldAttr.Idx); if (i == 0) { GroupField gf = new GroupField(); gf.FrmID = enName; MapData md = new MapData(); md.No = enName; if (md.RetrieveFromDBSources() == 0) gf.Lab = "基础信息"; else gf.Lab = md.Name; gf.Idx = 0; gf.Insert(); this.AddEntity(gf); } } /// /// 得到它的 Entity /// public override Entity GetNewEntity { get { return new GroupField(); } } /// /// 查询 /// /// /// public int RetrieveFieldGroup(string enName) { QueryObject qo = new QueryObject(this); qo.AddWhere(GroupFieldAttr.FrmID, enName); qo.addAnd(); qo.AddWhereIsNull(GroupFieldAttr.CtrlID); //qo.AddWhereLen(GroupFieldAttr.CtrlID, " = ", 0, BP.Difference.SystemConfig.AppCenterDBType); int num = qo.DoQuery(); if (num == 0) { GroupField gf = new GroupField(); gf.FrmID = enName; MapData md = new MapData(); md.No = enName; if (md.RetrieveFromDBSources() == 0) gf.Lab = "基础信息"; else gf.Lab = md.Name; gf.Idx = 0; gf.Insert(); this.AddEntity(gf); return 1; } return num; } #endregion #region 为了适应自动翻译成java的需要,把实体转换成List. /// /// 转化成 java list,C#不能调用. /// /// List public System.Collections.Generic.IList ToJavaList() { return (System.Collections.Generic.IList)this; } /// /// 转化成list /// /// List public System.Collections.Generic.List Tolist() { System.Collections.Generic.List list = new System.Collections.Generic.List(); for (int i = 0; i < this.Count; i++) { list.Add((GroupField)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }