Пример #1
0
 /// <summary>
 /// 将基础对象名称(YWCourseData)数据,根据主键“(Id)”采用UPDATE操作更新到数据库中,并返回受影响的行数。
 /// </summary>
 /// <param name="yWCourseData">基础对象名称(YWCourseData)实例对象</param>
 public static int Update(YWCourseData yWCourseData)
 {
     CheckValid(yWCourseData);
     return(DataAccess.Update(yWCourseData));
 }
Пример #2
0
        /// <summary>
        /// 对基础对象名称(YWCourseData)实例对象,进行数据有效性检查。
        /// </summary>
        /// <param name="yWCourseData">基础对象名称(YWCourseData)实例对象</param>
        public static void CheckValid(YWCourseData yWCourseData)
        {
            #region 检查各属性是否符合空值约束
            if (DataValid.IsNull(yWCourseData.PlanId))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.PlanName))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.CourseId))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.CourseName))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.CreateUserName))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.CreateUserId))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.UpdateUserName))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.UpdateUserId))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.CreateTime))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.UpdateTime))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(yWCourseData.Status))
            {
                throw new CustomException("“”不能为空,请您确认输入是否正确。");
            }

            #endregion

            #region 检查字符串是否超出规定长度
            if (DataValid.IsOutLength(yWCourseData.PlanName, 50))
            {
                throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.CourseName, 50))
            {
                throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.CreateUserName, 20))
            {
                throw new CustomException("“”长度不能超过 20 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.UpdateUserName, 20))
            {
                throw new CustomException("“”长度不能超过 20 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.Title, 50))
            {
                throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.Content, 500))
            {
                throw new CustomException("“”长度不能超过 500 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.Link, 50))
            {
                throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.Alternate1, 50))
            {
                throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.Alternate2, 50))
            {
                throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.Alternate3, 50))
            {
                throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.Alternate4, 50))
            {
                throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。");
            }

            if (DataValid.IsOutLength(yWCourseData.Alternate5, 50))
            {
                throw new CustomException("“”长度不能超过 50 个汉字或字符,请您确认输入是否正确。");
            }

            #endregion
        }
Пример #3
0
 /// <summary>
 /// 将基础对象名称(YWCourseData)数据,采用INSERT操作插入到数据库中,并返回受影响的行数。
 /// </summary>
 /// <param name="yWCourseData">基础对象名称(YWCourseData)实例对象</param>
 public static int Insert(YWCourseData yWCourseData)
 {
     CheckValid(yWCourseData);
     return(DataAccess.Insert(yWCourseData));
 }