Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int attachmentID = _Request.Get <int>("attachmentID", Method.Get, 0);

            if (attachmentID < 1)
            {
                ShowError(new InvalidParamError("attachmentID").Message);
            }

            attachment = PostBOV5.Instance.GetAttachment(attachmentID, false);
            if (attachment == null)
            {
                ShowError("该附件不存在或者已被删除!");
            }

            PostV5 post = PostBOV5.Instance.GetPost(attachment.PostID, false);

            if (post == null)
            {
                ShowError("该附件不存在或者已被删除!");
            }

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);

            if (post.UserID != MyUserID && (!permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents)))
            {
                if (!attachment.IsBuyed(My))
                {
                    ShowError("您还没有购买此附件,不能查看购买记录!");
                }
            }

            TradePoint = ForumPointAction.Instance.GetUserPoint(post.UserID, ForumPointValueType.SellAttachment, post.ForumID);

            int pageNumber = _Request.Get <int>("page", Method.Get, 1);

            ExchangeList = PostBOV5.Instance.GetAttachmentExchanges(attachmentID, pageNumber, pageSize, out totalCount, out totalMoney);

            WaitForFillSimpleUsers <AttachmentExchange>(ExchangeList);

            SetPager("list", null, pageNumber, pageSize, totalCount);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int attachmentID = _Request.Get<int>("attachmentID", Method.Get, 0);

            if (attachmentID < 1)
                ShowError(new InvalidParamError("attachmentID").Message);

            attachment = PostBOV5.Instance.GetAttachment(attachmentID, false);
            if (attachment == null)
                ShowError("该附件不存在或者已被删除!");

            PostV5 post = PostBOV5.Instance.GetPost(attachment.PostID, false);
            if (post == null)
            {
                ShowError("该附件不存在或者已被删除!");
            }

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);
            if (post.UserID != MyUserID && (!permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents)))
            {
                if (!attachment.IsBuyed(My))
                {
                    ShowError("您还没有购买此附件,不能查看购买记录!");
                }
            }

            TradePoint = ForumPointAction.Instance.GetUserPoint(post.UserID, ForumPointValueType.SellAttachment, post.ForumID);

            int pageNumber = _Request.Get<int>("page",Method.Get,1);

            ExchangeList = PostBOV5.Instance.GetAttachmentExchanges(attachmentID, pageNumber, pageSize, out totalCount, out totalMoney);

            WaitForFillSimpleUsers<AttachmentExchange>(ExchangeList);

            SetPager("list", null, pageNumber, pageSize, totalCount);
        }
Exemple #3
0
        public override AttachmentExchangeCollection GetAttachmentExchanges(int attachmentID, int pageNumber, int pageSize, out int totalCount, out int totalSellMoney)
        {
            totalCount = 0;
            totalSellMoney = 0;
            using (SqlQuery query = new SqlQuery())
            {
                query.Pager.IsDesc = true;
                query.Pager.ResultFields = "*";
                query.Pager.SortField = "[CreateDate]";

                query.Pager.PrimaryKey = "[UserID]";
                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = pageSize;
                //query.Pager.TotalRecords = totalThreads;
                query.Pager.SelectCount = true;
                query.Pager.TableName = "[bx_AttachmentExchanges]";

                query.Pager.Condition = " [AttachmentID] = @AttachmentID ";

                query.CreateParameter<int>("@AttachmentID", attachmentID, SqlDbType.Int);

                query.Pager.AfterExecute = "SELECT SUM(Price) FROM bx_AttachmentExchanges WITH (NOLOCK) WHERE [AttachmentID] = @AttachmentID;";

                AttachmentExchangeCollection exchanges;
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    exchanges = new AttachmentExchangeCollection(reader);
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            totalCount = reader.Get<int>(0);
                        }
                    }
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            totalSellMoney = reader.Get<int>(0);
                        }
                    }
                }

                return exchanges;
            }
        }