Exemple #1
0
        /// <summary>
        /// 对基本角色信息(PTRoles)实例对象,进行数据有效性检查。
        /// </summary>
        /// <param name="pTRoles">基本角色信息(PTRoles)实例对象</param>
        public static void CheckValid(PTRoles pTRoles)
        {
            #region 检查各属性是否符合空值约束
            if (DataValid.IsNull(pTRoles.RoleName))
            {
                throw new CustomException("“角色名称”不能为空,请您确认输入是否正确。");
            }

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

            #endregion

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

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

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

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

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

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

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

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

            #endregion
        }
Exemple #2
0
 /// <summary>
 /// 将基本角色信息(PTRoles)数据,根据主键“编号(Id)”采用UPDATE操作更新到数据库中,并返回受影响的行数。
 /// </summary>
 /// <param name="pTRoles">基本角色信息(PTRoles)实例对象</param>
 public static int Update(PTRoles pTRoles)
 {
     CheckValid(pTRoles);
     return(DataAccess.Update(pTRoles));
 }
Exemple #3
0
 /// <summary>
 /// 将基本角色信息(PTRoles)数据,采用INSERT操作插入到数据库中,并返回受影响的行数。
 /// </summary>
 /// <param name="pTRoles">基本角色信息(PTRoles)实例对象</param>
 public static int Insert(PTRoles pTRoles)
 {
     CheckValid(pTRoles);
     return(DataAccess.Insert(pTRoles));
 }