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

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

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

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

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

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

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

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

            #endregion

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

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

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

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

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

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

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

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

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

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

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

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

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

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