Exemplo n.º 1
0
        private void BindComments()
        {
            var iCount = ProductComment.GetCount(product.SiteId, product.ProductId, (int)commentType, 10, -1, -1, null, null, null);

            string pageUrl = ProductHelper.FormatProductUrl(product.Url, product.ProductId, product.ZoneId);

            pageUrl += "?cmtpg={0}";

            pgr.PageURLFormat = pageUrl;
            pgr.ItemCount     = iCount;
            pgr.CurrentIndex  = pageNumber;
            divPager.Visible  = (iCount > pgr.PageSize);

            var lstComments = ProductComment.GetPage(product.SiteId, product.ProductId, (int)commentType, 10, -1, -1, null, null, null, 0, pageNumber, pgr.PageSize);

            if (lstComments.Count > 0)
            {
                rptComments.DataSource = lstComments;
                rptComments.DataBind();

                var lstTopComments = ProductComment.GetPage(product.SiteId, product.ProductId, (int)commentType, 10, 0, 1, null, null, null, 0, 1, 3);
                if (lstTopComments.Count > 0)
                {
                    rptCommentTop.DataSource = lstTopComments;
                    rptCommentTop.DataBind();
                }
            }
            else
            {
                rptComments.Visible = false;
            }
        }
Exemplo n.º 2
0
        public void GetList(int productId, int commentType, int parentId, int pageNumber, int pageSize)
        {
            try
            {
                Context.Response.ContentType = "text/html";
                Encoding encoding = new UTF8Encoding();
                Context.Response.ContentEncoding = encoding;

                SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
                var          lstComments  = ProductComment.GetPage(siteSettings.SiteId, productId, commentType, 10, parentId, -1, null, null, null, 0, pageNumber, pageSize);
                TimeZoneInfo timeZone     = SiteUtils.GetUserTimeZone();
                double       timeOffset   = SiteUtils.GetUserTimeOffset();

                StringBuilder results = new StringBuilder();
                foreach (ProductComment comment in lstComments)
                {
                    results.Append(GetResponse(comment, timeZone, timeOffset, false));
                    results.Append("<ul class='jcmt' id='jcmt-" + comment.CommentId + "'>");

                    var lstChildComments = ProductComment.GetPage(siteSettings.SiteId, comment.ProductId, commentType, 10, comment.CommentId, -1, null, null, null, 1, 1, pageSize);
                    if (lstChildComments.Count > 0)
                    {
                        foreach (ProductComment child in lstChildComments)
                        {
                            results.Append(GetChildResponse(child));
                        }
                    }

                    results.Append("<li class='cmteditarea' id='jcmt-" + comment.CommentId + "-txtrow'><textarea id='jcmt-" + comment.CommentId + "-txt' class='cmteditor'></textarea><div class='editorPlaceholder'>Mời bạn thảo luận hoặc đánh giá về sản phẩm này</div></li><li class='cmtbtn'><div class='cmtinfo'><input type='text' maxlength='100' placeholder='Mời bạn nhập tên (Bắt buộc)' class='cmtname'> <input type='text' maxlength='100' placeholder='Mời bạn nhập email (Không bắt buộc)' class='cmtemail'> <a href='#'>Gửi bình luận</a></div></li>");
                    results.Append("</ul></div>");//end div jid
                }

                if (results.Length > 0)
                {
                    Context.Response.Write(results.ToString());
                }
                else
                {
                    Context.Response.Write(" ");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                Context.Response.Write(" ");
            }
        }
Exemplo n.º 3
0
        private void BindGrid()
        {
            int      status   = Convert.ToInt32(ddStatus.Text.Trim());
            int      orderBy  = Convert.ToInt32(ddOrderBy.SelectedValue);
            DateTime?fromdate = null;
            DateTime?todate   = null;
            string   keyword  = null;

            int position = -1;

            if (ckbPosition.Checked)
            {
                appliedFilter = true;
                position      = 1;
            }
            if (txtKeyword.Text.Trim().Length > 0)
            {
                appliedFilter = true;
                keyword       = txtKeyword.Text.Trim();
            }

            if (status != -10 || orderBy != -1)
            {
                appliedFilter = true;
            }

            int parentId = -1;

            if (dpFromDate.Text.Trim().Length > 0)
            {
                appliedFilter = true;
                DateTime localTime = DateTime.Parse(dpFromDate.Text);
                localTime = new DateTime(localTime.Year, localTime.Month, localTime.Day, 0, 0, 0);

                if (timeZone != null)
                {
                    fromdate = localTime.ToUtc(timeZone);
                }
                else
                {
                    fromdate = localTime.AddHours(-timeOffset);
                }
            }
            if (dpToDate.Text.Trim().Length > 0)
            {
                appliedFilter = true;
                DateTime localTime = DateTime.Parse(dpToDate.Text);
                localTime = new DateTime(localTime.Year, localTime.Month, localTime.Day, 23, 59, 59);

                if (timeZone != null)
                {
                    todate = localTime.ToUtc(timeZone);
                }
                else
                {
                    todate = localTime.AddHours(-timeOffset);
                }
            }

            if (appliedFilter)
            {
                parentId = 0;
            }

            int commentType = Convert.ToInt32(ddCommentType.SelectedValue);
            int iCount      = ProductComment.GetCount(siteSettings.SiteId, -1, commentType, status, parentId, position, fromdate, todate, keyword);
            var lstComments = ProductComment.GetPage(siteSettings.SiteId, -1, commentType, status, parentId, position, fromdate, todate, keyword, orderBy, pageNumber, pgr.PageSize);
            var lstResults  = new List <ProductComment>();
            int i           = 0;

            foreach (ProductComment comment in lstComments)
            {
                i += 1;
                comment.RowNumber = ((pgr.PageSize * (pageNumber - 1)) + i).ToString();
                lstResults.Add(comment);

                if (!appliedFilter)
                {
                    var lstChildComments = ProductComment.GetPage(siteSettings.SiteId, -1, commentType, status, comment.CommentId, position, fromdate, todate, keyword, 1, 1, 100);
                    if (lstChildComments.Count > 0)
                    {
                        foreach (ProductComment child in lstChildComments)
                        {
                            lstResults.Add(child);
                        }
                    }
                }
            }

            grid.DataSource = lstResults;
            grid.DataBind();

            pgr.ShowFirstLast = true;
            pgr.ItemCount     = iCount;
            pgr.Visible       = (iCount > pgr.PageSize);
        }
Exemplo n.º 4
0
        protected List <ProductComment> GetChildComments(int parentId)
        {
            var lstComments = ProductComment.GetPage(product.SiteId, product.ProductId, (int)commentType, 10, parentId, -1, null, null, null, 1, 1, pgr.PageSize);

            return(lstComments);
        }