/// <summary> /// 保存用户权限 /// </summary> /// <param name="userRight">用户权限</param> /// <returns>SystemData.ReturnValue</returns> public short SaveUserRight(UserRightBase userRight) { if (userRight == null || GlobalMethods.Misc.IsEmptyString(userRight.UserID)) return SystemData.ReturnValue.PARAM_ERROR; int count = 0; short shRet = this.ExistRightInfo(userRight.UserID, userRight.RightType, ref count); if (shRet != SystemData.ReturnValue.OK) return shRet; if (count > 0) return this.UpdateUserRight(userRight); if (base.MedQCAccess == null) return SystemData.ReturnValue.PARAM_ERROR; string szField = string.Format("{0},{1},{2},{3}" , SystemData.UserRightTable.USER_ID, SystemData.UserRightTable.RIGHT_CODE , SystemData.UserRightTable.RIGHT_DESC, SystemData.UserRightTable.RIGHT_TYPE); string szValue = string.Format("'{0}','{1}','{2}','{3}'" , userRight.UserID, userRight.GetRightCode().Replace('0','1') , userRight.RightDesc, UserRightBase.GetRightTypeName(userRight.RightType)); string szTable = SystemData.DataTable.USER_RIGHT; string szSQL = string.Format(SystemData.SQL.INSERT, szTable, szField, szValue); count = 0; try { count = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text); } catch (Exception ex) { LogManager.Instance.WriteLog("RightAccess.SaveUserRight", new string[] { "szSQL" }, new object[] { szSQL }, ex); return SystemData.ReturnValue.EXCEPTION; } return (count > 0) ? SystemData.ReturnValue.OK : SystemData.ReturnValue.ACCESS_ERROR; }
/// <summary> /// 更新已有编辑器用户权限 /// </summary> /// <param name="userRight">用户权限</param> /// <returns>SystemData.ReturnValue</returns> public short UpdateUserRight(UserRightBase userRight) { if (userRight == null || GlobalMethods.Misc.IsEmptyString(userRight.UserID)) return SystemData.ReturnValue.PARAM_ERROR; if (base.MedQCAccess == null) return SystemData.ReturnValue.PARAM_ERROR; string szField = string.Format("{0}='{1}'", SystemData.UserRightTable.RIGHT_CODE, userRight.GetRightCode()); string szCondition = string.Format("{0}='{1}' AND {2}='{3}'" , SystemData.UserRightTable.USER_ID, userRight.UserID , SystemData.UserRightTable.RIGHT_TYPE, UserRightBase.GetRightTypeName(userRight.RightType)); string szTable = SystemData.DataTable.USER_RIGHT; string szSQL = string.Format(SystemData.SQL.UPDATE, szTable, szField, szCondition); int count = 0; try { count = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text); } catch (Exception ex) { LogManager.Instance.WriteLog("RightAccess.UpdateUserRight", new string[] { "szSQL" }, new object[] { szSQL }, ex); return SystemData.ReturnValue.EXCEPTION; } return (count <= 0) ? SystemData.ReturnValue.RES_NO_FOUND : SystemData.ReturnValue.OK; }