/// <summary> /// 将配置值(PTConfigValue)数据,根据主键“编号(Id)”采用UPDATE操作更新到数据库中,并返回受影响的行数。 /// </summary> /// <param name="configValue">配置值(PTConfigValue)实例对象</param> public static int Update(PTConfigValue pTConfigValue) { CheckValid(pTConfigValue); return(DataAccess.Update(pTConfigValue)); }
/// <summary> /// 对配置值(PTConfigValue)实例对象,进行数据有效性检查。 /// </summary> /// <param name="pTConfigValue">配置值(PTConfigValue)实例对象</param> public static void CheckValid(PTConfigValue pTConfigValue) { #region 检查各属性是否符合空值约束 if (DataValid.IsNull(pTConfigValue.ConfigItem)) { throw new CustomException("“配置项”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(pTConfigValue.CurrentValue)) { throw new CustomException("“当前值”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(pTConfigValue.Target)) { throw new CustomException("“适用对象”不能为空,请您确认输入是否正确。"); } #endregion #region 检查字符串是否超出规定长度 if (DataValid.IsOutLength(pTConfigValue.ConfigItem, 50)) { throw new CustomException("“配置项”编号长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(pTConfigValue.CurrentValue, 50)) { throw new CustomException("“当前值”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(pTConfigValue.Target, 50)) { throw new CustomException("“适用对象”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(pTConfigValue.Alternate1, 50)) { throw new CustomException("“备用1”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(pTConfigValue.Alternate2, 50)) { throw new CustomException("“备用2”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(pTConfigValue.Alternate3, 50)) { throw new CustomException("“备用3”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(pTConfigValue.Alternate4, 500)) { throw new CustomException("“备用4”长度不能超过 500 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(pTConfigValue.Alternate5, 500)) { throw new CustomException("“备用5”长度不能超过 500 个汉字或字符,请您确认输入是否正确。"); } #endregion }
/// <summary> /// 将配置值(PTConfigValue)数据,采用INSERT操作插入到数据库中,并返回受影响的行数。 /// </summary> /// <param name="pTConfigValue">配置值(PTConfigValue)实例对象</param> public static int Insert(PTConfigValue pTConfigValue) { CheckValid(pTConfigValue); return(DataAccess.Insert(pTConfigValue)); }