Beispiel #1
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="roleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>影响行数</returns>
        public int Update(BaseRoleEntity roleEntity, out string statusCode)
        {
            int returnValue = 0;

            // 检查是否已被其他人修改

            if (DbLogic.IsModifed(DbHelper, this.CurrentTableName, roleEntity.Id, roleEntity.ModifiedUserId, roleEntity.ModifiedOn))
            {
                // 数据已经被修改
                statusCode = StatusCode.ErrorChanged.ToString();
            }
            else
            {
                // 检查名称是否重复
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseRoleEntity.FieldSystemId, roleEntity.SystemId));
                parameters.Add(new KeyValuePair <string, object>(BaseRoleEntity.FieldRealName, roleEntity.RealName));
                parameters.Add(new KeyValuePair <string, object>(BaseRoleEntity.FieldDeletionStateCode, 0));
                if (this.Exists(parameters, roleEntity.Id))
                {
                    // 名称已重复
                    statusCode = StatusCode.ErrorNameExist.ToString();
                }
                else
                {
                    returnValue = this.UpdateEntity(roleEntity);
                    if (returnValue == 1)
                    {
                        statusCode = StatusCode.OKUpdate.ToString();
                    }
                    else
                    {
                        statusCode = StatusCode.ErrorDeleted.ToString();
                    }
                }
            }
            return(returnValue);
        }