/// <summary> /// 将基础对象名称(YWComment)数据,根据主键“(Id)”采用UPDATE操作更新到数据库中,并返回受影响的行数。 /// </summary> /// <param name="yWComment">基础对象名称(YWComment)实例对象</param> public static int Update(YWComment yWComment) { CheckValid(yWComment); return(DataAccess.Update(yWComment)); }
/// <summary> /// 对基础对象名称(YWComment)实例对象,进行数据有效性检查。 /// </summary> /// <param name="yWComment">基础对象名称(YWComment)实例对象</param> public static void CheckValid(YWComment yWComment) { #region 检查各属性是否符合空值约束 if (DataValid.IsNull(yWComment.PlanId)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.PlanName)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.CourseId)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.CourseName)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.CreateUserName)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.CreateUserId)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.UpdateUserName)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.UpdateUserId)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.CreateTime)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.UpdateTime)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.Status)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.Support)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } if (DataValid.IsNull(yWComment.Oppose)) { throw new CustomException("“”不能为空,请您确认输入是否正确。"); } #endregion #region 检查字符串是否超出规定长度 if (DataValid.IsOutLength(yWComment.PlanName, 50)) { throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(yWComment.CourseName, 50)) { throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(yWComment.CreateUserName, 20)) { throw new CustomException("“”长度不能超过 20 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(yWComment.UpdateUserName, 20)) { throw new CustomException("“”长度不能超过 20 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(yWComment.Content, 500)) { throw new CustomException("“”长度不能超过 500 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(yWComment.Alternate1, 50)) { throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(yWComment.Alternate2, 50)) { throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(yWComment.Alternate3, 50)) { throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(yWComment.Alternate4, 50)) { throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } if (DataValid.IsOutLength(yWComment.Alternate5, 50)) { throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。"); } #endregion }
/// <summary> /// 将基础对象名称(YWComment)数据,采用INSERT操作插入到数据库中,并返回受影响的行数。 /// </summary> /// <param name="yWComment">基础对象名称(YWComment)实例对象</param> public static int Insert(YWComment yWComment) { CheckValid(yWComment); return(DataAccess.Insert(yWComment)); }