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

            if (DataValid.IsNull(notices.ReleaseTime))
            {
                throw new CustomException("“发布时间”不能为空,请您确认输入是否正确。");
            }

            if (DataValid.IsNull(notices.ReadStatus))
            {
                throw new CustomException("“已读状态”不能为空,请您确认输入是否正确。");
            }

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

            #endregion

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            #endregion
        }
Exemple #3
0
 /// <summary>
 /// 将提示消息(Notices)数据,采用INSERT操作插入到数据库中,并返回受影响的行数。
 /// </summary>
 /// <param name="notices">提示消息(Notices)实例对象</param>
 public static int Insert(PTNotices notices)
 {
     CheckValid(notices);
     return(DataAccess.Insert(notices));
 }