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

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

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

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

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

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

            #endregion

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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