/// <summary> /// 获得部门下的负责人或领导或大于某职位的人 /// </summary> /// <param name="iFloorCode"> ">0"根据层返回部门 "-1"返回所有部门</param> /// <param name="type">部门</param> /// <param name="strPostName">职位名称</param> /// <returns></returns> public ViewBase GetManagerOrLeader(int iFloorCode, Common.LeaderType type, string strPostName) { Position post = Position.GetPosition(strPostName); string strCondition = string.Empty; string strSubDptIDs = string.Empty; strCondition = post == null ? "1<>1" : " e.SortNum <=" + post.SortNum.ToString(); if (type == Common.LeaderType.LeaderAndManager) { strCondition = " ( " + strCondition + " or b.LeaderType = " + (int)Common.LeaderType.Leader + " OR b.LeaderType = " + (int)Common.LeaderType.Manager; strCondition += " or b.LeaderType = " + (int)Common.LeaderType.LeaderAndManager + ")"; } else if (type != Common.LeaderType.User) { strCondition = " ( " + strCondition + " or b.LeaderType = " + (int)type + " or b.LeaderType = " + (int)Common.LeaderType.LeaderAndManager + ")"; } if (iFloorCode == 0) { strCondition += " AND d.ID = " + base.ID.ToString(); } else { strSubDptIDs = this.GetChildDeptID(base.ID, iFloorCode); strSubDptIDs = strSubDptIDs.Length > 0 ? strSubDptIDs + "," + base.ID.ToString() : base.ID.ToString(); strCondition += strSubDptIDs.Length > 0 ? " AND d.ID IN (" + strSubDptIDs + ")" : " AND 1<>1"; } ViewUser vwUser = new ViewUser(); vwUser.BaseCondition = strCondition; return(vwUser); }
/// <summary> /// 设置领导和负责人 /// </summary> /// <param name="mType">领导或负责人枚举</param> /// <param name="strIDs">用户IDs</param> /// <param name="bSetOrReset">取消或者设置</param> /// <param name="strMessage">错误消息</param> /// <returns></returns> public static bool SetUserLeaderType(Common.LeaderType mType, List <string> strIDs, bool bSetOrReset, out string strMessage) { bool bRet = false; strMessage = string.Empty; DeptPost dp = new DeptPost(); User user = new User(); ViewDeptPost v_dp = new ViewDeptPost(); dp.EnTrans.Begin(); dp.EnTrans.IsBatch = true; foreach (string strID in strIDs) { if (strID.Length == 0) { continue; } bRet = dp.Load(Convert.ToInt32(strID)); if (mType == Common.LeaderType.Manager && bSetOrReset) { v_dp.EnTrans = dp.EnTrans; v_dp.Field = "a.ID"; v_dp.Condition = " FK_DeptID = " + dp.FK_DeptID + " and LeaderType in (" + (int)Common.LeaderType.Manager + "," + (int)Common.LeaderType.LeaderAndManager + ")"; if (v_dp.DtTable != null) { if (v_dp.DtTable.Rows.Count > 0) { user.EnTrans = dp.EnTrans; user.Load(dp.FK_UserID); bRet = false; strMessage = string.Format("({0})所在的部门以存在负责人", user.Name); return(bRet); } } } if (dp.LeaderType == int.MinValue) { dp.LeaderType = 0; } if (bSetOrReset) { dp.LeaderType |= (int)mType; } else { if (dp.LeaderType == (int)mType || (dp.LeaderType == ((int)(Common.LeaderType.Leader | Common.LeaderType.Manager)))) { dp.LeaderType ^= (int)mType; } } bRet = dp.Save(); } dp.EnTrans.Commit(); return(bRet); }
/// <summary> /// 根据部门ID取出部门负责人、部门领导和大于某职位的人 /// </summary> /// <param name="strDeptID">部门ID</param> /// <param name="strPost">职位名称</param> /// <param name="enmuType">职务类型枚举</param> /// <param name="iFloorCode">层级(0自己,>0 子部门层数,-1所有)</param> /// <returns></returns> private static ViewBase GetUserByDeptPost(string strDeptID, string strPost, Common.LeaderType enmuType, int iFloorCode) { ViewBase vb = null; Department dept = Department.GetDepartment(OADept.ConvertInt(strDeptID)); if (dept != null) { vb = OAUser.FilterUser(dept.GetManagerOrLeader(iFloorCode, enmuType, strPost)); } return(vb); }
/// <summary> /// 根据部门ID取出部门负责人、部门领导和大于某职位的人(向下遍历) /// </summary> /// <param name="strDeptID">部门ID</param> /// <param name="strPostName">职位名称</param> /// <param name="bDeptManger">是否绑定部门负责人</param> /// <param name="bDeptLeader">是否绑定部门领导</param> /// <param name="iFloorCode">层级(0自己,>0 子部门层数,-1所有)</param> /// <returns>DataTable</returns> private static ViewBase GetUserByDeptPost(string strDeptID, string strPostName, bool bDeptManger, bool bDeptLeader, int iFloorCode) { Common.LeaderType enmuType = Common.LeaderType.User; if (bDeptLeader && bDeptManger) { enmuType = Common.LeaderType.LeaderAndManager; } if (bDeptManger == false && bDeptLeader) { enmuType = Common.LeaderType.Leader; } if (bDeptManger && bDeptLeader == false) { enmuType = Common.LeaderType.Manager; } if (bDeptLeader == false && bDeptManger == false) { enmuType = Common.LeaderType.User; } return(OAUser.GetUserByDeptPost(strDeptID, strPostName, enmuType, iFloorCode)); }
/// <summary> /// 获取部门及子部门领导或负责人 /// </summary> /// <param name="iFloorCode">0自己,>0 子部门层数 -1所有</param> /// <param name="type">领导或负责人</param> /// <returns></returns> private ViewBase GetManagerOrLeader(int iFloorCode, Common.LeaderType type) { string strSubDptIDs = string.Empty; int iType = (int)(Common.LeaderType.Leader | Common.LeaderType.Manager); string strCondition = "(b.LeaderType = " + iType + " OR b.LeaderType = " + ((int)type).ToString() + ")"; if (iFloorCode == 0) { strCondition += " AND d.ID = " + base.ID.ToString(); } else { strSubDptIDs = this.GetChildDeptID(base.ID, iFloorCode); strSubDptIDs = strSubDptIDs.Length > 0 ? strSubDptIDs + "," + base.ID.ToString() : base.ID.ToString(); strCondition += strSubDptIDs.Length > 0 ? " AND d.ID IN (" + strSubDptIDs + ")" : " AND 1<>1"; } ViewUser vwUser = new ViewUser(); vwUser.BaseCondition = strCondition; return(vwUser); }