using System; using BP.DA; using BP.En; using BP.Web; using BP.WF.Port.Admin2Group; using BP.WF.Template; namespace BP.WF.Port.AdminGroup { /// /// 独立组织属性 /// public class OrgAttr : EntityNoNameAttr { /// /// 管理员帐号 /// public const string Adminer = "Adminer"; /// /// 管理员名称 /// public const string AdminerName = "AdminerName"; /// /// 父级组织编号 /// public const string ParentNo = "ParentNo"; /// /// 父级组织名称 /// public const string ParentName = "ParentName"; /// /// 序号 /// public const string Idx = "Idx"; } /// /// 独立组织 /// public class Org : EntityNoName { #region 属性 /// /// 父级组织编号 /// public string ParentNo { get { return this.GetValStrByKey(OrgAttr.ParentNo); } set { this.SetValByKey(OrgAttr.ParentNo, value); } } /// /// 父级组织名称 /// public string ParentName { get { return this.GetValStrByKey(OrgAttr.ParentName); } set { this.SetValByKey(OrgAttr.ParentName, value); } } /// /// 父节点编号 /// public string Adminer { get { return this.GetValStrByKey(OrgAttr.Adminer); } set { this.SetValByKey(OrgAttr.Adminer, value); } } /// /// 管理员名称 /// public string AdminerName { get { return this.GetValStrByKey(OrgAttr.AdminerName); } set { this.SetValByKey(OrgAttr.AdminerName, value); } } #endregion #region 构造函数 /// /// 独立组织 /// public Org() { } /// /// 独立组织 /// /// 编号 public Org(string no) : base(no) { } #endregion #region 重写方法 /// /// UI界面上的访问控制 /// public override UAC HisUAC { get { UAC uac = new UAC(); uac.OpenForSysAdmin(); uac.IsDelete = true; /* if (DataType.IsNullOrEmpty(this.No) == true) { uac.IsUpdate = true; uac.IsInsert = true; return uac; }*/ uac.IsInsert = false; uac.IsUpdate = true; return uac; } } /// /// Map /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("Port_Org", "独立组织"); map.AddTBStringPK(OrgAttr.No, null, "编号(与部门编号相同)", true, false, 1, 30, 40); map.AddTBString(OrgAttr.Name, null, "组织名称", true, false, 0, 60, 200, true); map.AddTBString(OrgAttr.ParentNo, null, "父级组织编号", false, false, 0, 60, 200, true); map.AddTBString(OrgAttr.ParentName, null, "父级组织名称", false, false, 0, 60, 200, true); map.AddTBString(OrgAttr.Adminer, null, "主要管理员(创始人)", true, true, 0, 60, 200, true); map.AddTBString(OrgAttr.AdminerName, null, "管理员名称", true, true, 0, 60, 200, true); map.AddTBInt("FlowNums", 0, "流程数", true, true); map.AddTBInt("FrmNums", 0, "表单数", true, true); map.AddTBInt("Users", 0, "用户数", true, true); map.AddTBInt("Depts", 0, "部门数", true, true); map.AddTBInt("GWFS", 0, "运行中流程", true, true); map.AddTBInt("GWFSOver", 0, "结束的流程", true, true); map.AddTBInt(OrgAttr.Idx, 0, "排序", true, false); RefMethod rm = new RefMethod(); rm.Title = "检查正确性"; rm.ClassMethodName = this.ToString() + ".DoCheck"; map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "修改主管理员"; rm.ClassMethodName = this.ToString() + ".ChangeAdminer"; rm.HisAttrs.AddTBString("adminer", null, "新主管理员编号", true, false, 0, 100, 100); map.AddRefMethod(rm); rm = new RefMethod(); rm.Title = "取消独立组织"; rm.ClassMethodName = this.ToString() + ".DeleteOrg"; rm.Warning = "您确定要取消独立组织吗?系统将要删除该组织以及该组织的管理员,但是不删除部门数据."; map.AddRefMethod(rm); //管理员. map.AddDtl(new OrgAdminers(), OrgAdminerAttr.OrgNo, null, DtlEditerModel.DtlSearch, "icon-people"); //rm = new RefMethod(); //rm.Title = "在集团下新增组织"; //rm.ClassMethodName = this.ToString() + ".AddOrg"; //rm.HisAttrs.AddTBString("no", null, "组织编号", true, false, 0, 100, 100); //rm.HisAttrs.AddTBString("name", null, "组织名称", true, false, 0, 100, 100); //rm.HisAttrs.AddTBString("adminer", null, "管理员编号", true, false, 0, 100, 100); //rm.HisAttrs.AddTBString("adminName", null, "管理员名称", true, false, 0, 100, 100); //map.AddRefMethod(rm); this._enMap = map; return this._enMap; } } #endregion /// /// 调用admin2Group的检查. /// 1. 是否出现错误. /// 1. 数据是否完整. /// /// public string DoCheck() { BP.WF.Port.Admin2Group.Org org = new Admin2Group.Org(this.No); return org.DoCheck(); } /// /// 去掉独立组织 /// /// public string DeleteOrg() { if (WebUser.No.Equals("admin") == false) return "err@只有admin帐号才可以执行。"; if (this.No.Equals("100") == true) return "err@admin组织不能取消."; //流程类别. BP.WF.Template.FlowSorts fss = new Template.FlowSorts(); fss.Retrieve(OrgAdminerAttr.OrgNo, this.No); foreach (BP.WF.Template.FlowSort en in fss) { Flows fls = new Flows(); fls.Retrieve(BP.WF.Template.FlowAttr.FK_FlowSort, en.No); if (fls.Count != 0) return "err@在流程目录:" + en.Name + "有[" + fls.Count + "]个流程没有删除。"; } //表单类别. SysFormTrees ftTrees = new SysFormTrees(); ftTrees.Retrieve(SysFormTreeAttr.OrgNo, this.No); foreach (BP.WF.Template.FlowSort en in fss) { BP.Sys.MapDatas mds = new BP.Sys.MapDatas(); mds.Retrieve(BP.Sys.MapDataAttr.FK_FormTree, en.No); if (mds.Count != 0) return "err@在表单目录:" + en.Name + "有[" + mds.Count + "]个表单没有删除。"; } OrgAdminers oas = new OrgAdminers(); oas.Delete(OrgAdminerAttr.OrgNo, this.No); BP.WF.Template.FlowSorts fs = new Template.FlowSorts(); fs.Delete(OrgAdminerAttr.OrgNo, this.No); fss.Delete(OrgAdminerAttr.OrgNo, this.No); //删除流程目录. ftTrees.Delete(SysFormTreeAttr.OrgNo, this.No); //删除表单目录。 //更新到admin的组织下. string sqls = "UPDATE Port_Emp SET OrgNo='" + BP.Web.WebUser.OrgNo + "' AND OrgNo='" + this.No + "'"; sqls += "@UPDATE Port_Dept SET OrgNo='" + BP.Web.WebUser.OrgNo + "' AND OrgNo='" + this.No + "'"; sqls += "@UPDATE Port_DeptEmp SET OrgNo='" + BP.Web.WebUser.OrgNo + "' AND OrgNo='" + this.No + "'"; sqls += "@UPDATE Port_DeptEmpStation SET OrgNo='" + BP.Web.WebUser.OrgNo + "' AND OrgNo='" + this.No + "'"; DBAccess.RunSQLs(sqls); this.Delete(); return "info@成功注销组织,请关闭窗口刷新页面."; } /// /// 更改管理员(admin才能操作) /// /// /// public string ChangeAdminer(string adminer) { if (WebUser.No.Equals("admin") == false) return "err@非admin管理员,您无法执行该操作."; BP.Port.Emp emp = new BP.Port.Emp(); emp.UserID = adminer; if (emp.RetrieveFromDBSources() == 0) return "err@管理员编号错误."; string old = this.Adminer; this.Adminer = emp.UserID; this.AdminerName = emp.Name; this.Update(); //检查超级管理员是否存在? OrgAdminer oa = new OrgAdminer(); oa.FK_Emp = old; oa.OrgNo = this.No; oa.Delete(OrgAdminerAttr.FK_Emp, old, OrgAdminerAttr.OrgNo, this.No); //插入到管理员. oa.FK_Emp = emp.UserID; oa.Save(); //检查超级管理员是否存在? return "修改成功,请关闭当前记录重新打开."; } } /// ///独立组织集合 /// public class Orgs : EntitiesNoName { /// /// 得到一个新实体 /// public override Entity GetNewEntity { get { return new Org(); } } /// /// create ens /// public Orgs() { } #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((Org)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成List. } }