using System; using System.Data; using BP.DA; using BP.En; using BP.Web; namespace BP.Cloud { /// /// 部门 /// public class DeptExt : EntityTree { #region 属性 public string OrgNo { get { return this.GetValStrByKey(DeptAttr.OrgNo); } set { this.SetValByKey(DeptAttr.OrgNo, value); } } /// /// adminer /// public string Adminer { get { return this.GetValStrByKey(DeptAttr.Adminer); } set { this.SetValByKey(DeptAttr.Adminer, value); } } /// /// 全名 /// public string NameOfPath { get { return this.GetValStrByKey(DeptAttr.NameOfPath); } set { this.SetValByKey(DeptAttr.NameOfPath, value); } } /// /// 父节点的ID /// public new string ParentNo { get { return this.GetValStrByKey(DeptAttr.ParentNo); } set { this.SetValByKey(DeptAttr.ParentNo, value); } } #endregion #region 构造函数 /// /// 部门 /// public DeptExt() { } /// /// 部门 /// /// 编号 public DeptExt(string no) : base(no) { } #endregion #region 重写方法 public override UAC HisUAC { get { UAC uac = new UAC(); uac.OpenForSysAdmin(); return uac; } } /// /// Map /// public override Map EnMap { get { if (this._enMap != null) return this._enMap; Map map = new Map("Port_Dept", "部门"); map.AddTBStringPK(DeptAttr.No, null, "编号", true, true, 1, 50, 20); map.AddTBString(DeptAttr.Name, null, "名称", true, false, 0, 100, 30); map.AddTBString(DeptAttr.ParentNo, null, "父节点编号", true, true, 0, 100, 30); map.AddTBString(DeptAttr.OrgNo, null, "组织编码", true, false, 0, 100, 30); map.AddTBString(DeptAttr.Adminer, null, "管理员帐号", true, false, 0, 100, 30); map.AddTBInt(DeptAttr.Idx, 0, "顺序号", true, false); //顺序号. //增加隐藏查询条件. map.AddHidden(StationTypeAttr.OrgNo, "=", BP.Web.WebUser.OrgNo); //RefMethod rm = new RefMethod(); //rm.Title = "重置该部门一下的部门路径"; //rm.ClassMethodName = this.ToString() + ".DoResetPathName"; //rm.RefMethodType = RefMethodType.Func; //string msg = "当该部门名称变化后,该部门与该部门的子部门名称路径(Port_DeptExt.NameOfPath)将发生变化."; //msg += "\t\n 该部门与该部门的子部门的人员路径也要发生变化Port_Emp列DeptExtDesc.StaDesc."; //msg += "\t\n 您确定要执行吗?"; //rm.Warning = msg; //map.AddRefMethod(rm); //rm = new RefMethod(); //rm.Title = "增加同级部门"; //rm.ClassMethodName = this.ToString() + ".DoSameLevelDeptExt"; //rm.HisAttrs.AddTBString("No", null, "同级部门编号", true, false, 0, 100, 100); //rm.HisAttrs.AddTBString("Name", null, "部门名称", true, false, 0, 100, 100); //map.AddRefMethod(rm); //rm = new RefMethod(); //rm.Title = "增加下级部门"; //rm.ClassMethodName = this.ToString() + ".DoSubDeptExt"; //rm.HisAttrs.AddTBString("No", null, "同级部门编号", true, false, 0, 100, 100); //rm.HisAttrs.AddTBString("Name", null, "部门名称", true, false, 0, 100, 100); //map.AddRefMethod(rm); this._enMap = map; return this._enMap; } } #endregion /// /// 创建下级节点. /// /// public string DoMyCreateSubNode() { Entity en = this.DoCreateSubNode(); return en.ToJson(); } /// /// 创建同级节点. /// /// public string DoMyCreateSameLevelNode() { Entity en = this.DoCreateSameLevelNode(); return en.ToJson(); } public string DoSameLevelDeptExt(string no, string name) { DeptExt en = new DeptExt(); en.No = no; if (en.RetrieveFromDBSources() == 1) return "err@编号已经存在"; en.Name = name; en.ParentNo = this.ParentNo; en.Insert(); return "增加成功.."; } public string DoSubDeptExt(string no, string name) { DeptExt en = new DeptExt(); en.No = no; if (en.RetrieveFromDBSources() == 1) return "err@编号已经存在"; en.Name = name; en.ParentNo = this.No; en.Insert(); return "增加成功.."; } /// /// 重置部门 /// /// public string DoResetPathName() { this.GenerNameOfPath(); return "重置成功."; } /// /// 生成部门全名称. /// public void GenerNameOfPath() { string name = this.Name; //根目录不再处理 if (this.IsRoot == true) { this.NameOfPath = name; this.DirectUpdate(); this.GenerChildNameOfPath(this.No); return; } DeptExt DeptExt = new DeptExt(); DeptExt.No = this.ParentNo; if (DeptExt.RetrieveFromDBSources() == 0) return; while (true) { if (DeptExt.IsRoot) break; name = DeptExt.Name + "\\" + name; DeptExt = new DeptExt(DeptExt.ParentNo); } //根目录 name = DeptExt.Name + "\\" + name; this.NameOfPath = name; this.DirectUpdate(); this.GenerChildNameOfPath(this.No); ////更新人员路径信息. //BP.Port.Emps emps = new Emps(); //emps.Retrieve(EmpAttr.FK_DeptExt, this.No); //foreach (BP.Port.Emp emp in emps) // emp.Update(); } /// /// 处理子部门全名称 /// /// public void GenerChildNameOfPath(string DeptExtNo) { //DeptExts DeptExts = new DeptExts(DeptExtNo); //if (DeptExts != null && DeptExts.Count > 0) //{ // foreach (DeptExt DeptExt in DeptExts) // { // DeptExt.GenerNameOfPath(); // GenerChildNameOfPath(DeptExt.No); // ////更新人员路径信息. // //BP.Port.Emps emps = new Emps(); // //emps.Retrieve(EmpAttr.FK_DeptExt, this.No); // //foreach (BP.Port.Emp emp in emps) // // emp.Update(); // } //} } } /// ///部门集合 /// public class DeptExts : EntitiesTree { /// /// 得到一个新实体 /// public override Entity GetNewEntity { get { return new DeptExt(); } } /// /// 部门集合 /// public DeptExts() { } public override int RetrieveAll() { return this.Retrieve(EmpAttr.OrgNo, BP.Web.WebUser.OrgNo); } #region 为了适应自动翻译成java的需要,把实体转换成IList, c#代码调用会出错误。 /// /// 转化成 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((DeptExt)this[i]); } return list; } #endregion 为了适应自动翻译成java的需要,把实体转换成IList, c#代码调用会出错误。 } }