/// <summary> /// 点击职位树节点或者用户列表,获取有权限菜单id字符串 /// </summary> /// <param name="strPostID">职位或者用户id</param> /// <param name="strRightType">职位或者用户,1用户,2职位</param> /// <returns></returns> private string ClickPostTreeNode(string strPostID, string strRightType) { string strResult = ""; TSysMenuPostVo objMenuPostVo = new TSysMenuPostVo(); objMenuPostVo.RIGHT_TYPE = strRightType; objMenuPostVo.POST_ID = strPostID; DataTable dt = new TSysMenuPostLogic().SelectByTable(objMenuPostVo); if (dt.Rows.Count < 1) { return(""); } for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; strResult += (strResult.Length > 0 ? "|":"") + dr[TSysMenuPostVo.MENU_ID_FIELD].ToString(); } return(strResult); }
/// <summary> /// 权限的菜单树节点选中,保存权限 /// </summary> /// <param name="strPostID">职位或者用户id</param> /// <param name="strChkMenuNodes">选择节点id串</param> /// <param name="strRightType">职位或者用户,1用户,2职位</param> /// <returns></returns> private string SaveCheckMenuNode(string strPostID, string strChkMenuNodes, string strRightType) { string strlogName = "用户"; if (strRightType == "2") { strlogName = "职位"; } string strResult = ""; if (strChkMenuNodes == "")//传入空串,将有关该职位或人员的权限全部删除 { TSysMenuPostVo objMenuPostVoDel = new TSysMenuPostVo(); objMenuPostVoDel.POST_ID = strPostID; objMenuPostVoDel.RIGHT_TYPE = strRightType; new TSysMenuPostLogic().Delete(objMenuPostVoDel); base.WriteLog(i3.ValueObject.ObjectBase.LogType.EditUserRight, objMenuPostVoDel.ID, LogInfo.UserInfo.USER_NAME + "删除" + strlogName + ": " + objMenuPostVoDel.ID + " 的所有树菜单权限成功!"); return(strResult); } string[] arrChkMenuNodes = strChkMenuNodes.Split('|'); //查询该该职位或人员原有权限 TSysMenuPostVo objMenuPostVo = new TSysMenuPostVo(); objMenuPostVo.RIGHT_TYPE = strRightType; objMenuPostVo.POST_ID = strPostID; DataTable dt = new TSysMenuPostLogic().SelectByTable(objMenuPostVo); //查询不到,说明原来该职位或人员无权限,直接增加即可 if (dt.Rows.Count < 1) { for (int i = 0; i < arrChkMenuNodes.Length; i++) { TSysMenuPostVo objMenuPostVoAdd = new TSysMenuPostVo(); objMenuPostVoAdd.ID = GetSerialNumber("t_sys_menu_Post_id"); objMenuPostVoAdd.POST_ID = strPostID; objMenuPostVoAdd.RIGHT_TYPE = strRightType; objMenuPostVoAdd.MENU_ID = arrChkMenuNodes[i]; new TSysMenuPostLogic().Create(objMenuPostVoAdd); base.WriteLog(i3.ValueObject.ObjectBase.LogType.EditUserRight, objMenuPostVoAdd.ID, LogInfo.UserInfo.USER_NAME + "增加" + strlogName + ": " + objMenuPostVo.ID + " 的树菜单权限" + objMenuPostVoAdd.MENU_ID + "成功!"); } return(strResult); } //比对传来的权限字符串和数据库查询结果,进行比较 //存在于权限字符串,而不存在于数据库的,增加 //存在于数据库,而不存在于的权限字符串,删除 string strRights = ""; for (int i = 0; i < dt.Rows.Count; i++) { strRights += (strRights.Length > 0 ? "|" : "") + dt.Rows[i][TSysMenuPostVo.MENU_ID_FIELD].ToString(); } //存在于权限字符串,而不存在于数据库的,增加 for (int i = 0; i < arrChkMenuNodes.Length; i++) { if (!strRights.Contains(arrChkMenuNodes[i])) { TSysMenuPostVo objMenuPostVoAdd = new TSysMenuPostVo(); objMenuPostVoAdd.ID = GetSerialNumber("t_sys_menu_Post_id"); objMenuPostVoAdd.POST_ID = strPostID; objMenuPostVoAdd.RIGHT_TYPE = strRightType; objMenuPostVoAdd.MENU_ID = arrChkMenuNodes[i]; new TSysMenuPostLogic().Create(objMenuPostVoAdd); base.WriteLog(i3.ValueObject.ObjectBase.LogType.EditUserRight, objMenuPostVoAdd.ID, LogInfo.UserInfo.USER_NAME + "增加" + strlogName + ": " + objMenuPostVo.ID + " 的树菜单权限" + objMenuPostVoAdd.MENU_ID + "成功!"); } } //存在于数据库,而不存在于的权限字符串,删除 for (int i = 0; i < dt.Rows.Count; i++) { if (!strChkMenuNodes.Contains(dt.Rows[i][TSysMenuPostVo.MENU_ID_FIELD].ToString())) { TSysMenuPostVo objMenuPostVoDel = new TSysMenuPostVo(); objMenuPostVoDel.POST_ID = strPostID; objMenuPostVoDel.RIGHT_TYPE = strRightType; objMenuPostVoDel.MENU_ID = dt.Rows[i][TSysMenuPostVo.MENU_ID_FIELD].ToString(); new TSysMenuPostLogic().Delete(objMenuPostVoDel); base.WriteLog(i3.ValueObject.ObjectBase.LogType.EditUserRight, objMenuPostVoDel.ID, LogInfo.UserInfo.USER_NAME + "删除" + strlogName + ": " + objMenuPostVo.ID + " 的树菜单权限" + objMenuPostVoDel.MENU_ID + "成功!"); } } return(strResult); }