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