public Boolean isSubmitterLeader(string submitterId, string approverUserId) { string submitterDepartmentId = SqlHelper.Find("select departmentId from v_user_department_post where userId = '" + submitterId + "'").Tables[0].Rows[0][0].ToString(); string approverDepartmentId = SqlHelper.Find("select departmentId from v_user_department_post where userId = '" + approverUserId + "'").Tables[0].Rows[0][0].ToString(); DataTable dt = new DataTable(); dt.Columns.Add("departmentId", Type.GetType("System.String")); dt.Rows.Add(approverDepartmentId); DataTable table = RightSrv.GetDepartmentIds(dt); string[] parentDepartmentIds = table.Rows[0][0].ToString().Split(','); Boolean flag = false; int index = 0; foreach (string parentDptId in parentDepartmentIds) { if (index == 0) { index++; continue; } if (parentDptId == submitterDepartmentId.ToString()) { flag = true; break; } } return(flag); }
/// <summary> /// 由企业微信ID获取该成员的一级级往上的所有部门 /// </summary> /// <param name="wechatUserId">企业微信ID</param> /// <returns>该成员的部门链</returns> public static DataTable GetDepartmentIds(string wechatUserId) { DataTable theBottomDepartmentIds = RightSrv.GetTheBottomDepartmentId(wechatUserId); if (theBottomDepartmentIds != null) { DataTable dt = RightSrv.GetDepartmentIds(theBottomDepartmentIds); DataTable departmentIds = new DataTable(); departmentIds.Columns.Add("departmentId", Type.GetType("System.String")); if (dt != null) { foreach (DataRow row in dt.Rows) { string[] departmentId = row[0].ToString().Split(','); foreach (string str in departmentId) { departmentIds.Rows.Add(str); } } } return(departmentIds); } return(null); }