private void GetList(HttpContext context) { ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.Keywords = context.Request["Keywords"]; string text = context.Request["Type"]; if (!string.IsNullOrEmpty(text)) { productReviewQuery.havedReply = text.ToBool(); } productReviewQuery.startDate = base.GetDateTimeParam(context, "startDate"); productReviewQuery.endDate = base.GetDateTimeParam(context, "endDate"); if (productReviewQuery.endDate.HasValue) { productReviewQuery.endDate = productReviewQuery.endDate.Value.AddDays(1.0); } productReviewQuery.SortOrder = SortAction.Desc; productReviewQuery.PageIndex = base.CurrentPageIndex; productReviewQuery.PageSize = base.CurrentPageSize; productReviewQuery.SortBy = "ReviewDate"; Globals.EntityCoding(productReviewQuery, true); DataGridViewModel <Dictionary <string, object> > dataList = this.GetDataList(productReviewQuery); string s = base.SerializeObjectToJson(dataList); context.Response.Write(s); context.Response.End(); }
public DbQueryResult GetProductReviews(ProductReviewQuery reviewQuery) { StringBuilder builder = new StringBuilder(); builder.AppendFormat(" ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(reviewQuery.Keywords)); builder.AppendFormat(" AND wid = '{0}'", reviewQuery.wid); if (!string.IsNullOrEmpty(reviewQuery.ProductCode)) { builder.AppendFormat(" AND ProductCode LIKE '%{0}%'", DataHelper.CleanSearchString(reviewQuery.ProductCode)); } if (reviewQuery.UserId > 0) { builder.AppendFormat(" AND Userid = {0}", reviewQuery.UserId); } if (reviewQuery.productId > 0) { builder.AppendFormat(" AND ProductId = {0}", reviewQuery.productId); } if (reviewQuery.CategoryId.HasValue) { builder.AppendFormat(" AND (CategoryId = {0}", reviewQuery.CategoryId.Value); builder.AppendFormat(" OR CategoryId IN (SELECT CategoryId FROM Hishop_Categories WHERE Path LIKE (SELECT Path FROM Hishop_Categories WHERE CategoryId = {0}) + '%'))", reviewQuery.CategoryId.Value); } return(DataHelper.PagingByRownumber(reviewQuery.PageIndex, reviewQuery.PageSize, reviewQuery.SortBy, reviewQuery.SortOrder, reviewQuery.IsCount, "vw_Hishop_ProductReviews", "ProductId", builder.ToString(), "*")); }
private static string BuildReviewsQuery(ProductReviewQuery reviewQuery) { HiContext current = HiContext.Current; StringBuilder builder = new StringBuilder(); builder.Append("SELECT ReviewId FROM distro_Products p inner join distro_ProductReviews r on (r.productId=p.ProductId AND r.DistributorUserId=p.DistributorUserId)"); builder.AppendFormat(" WHERE r.DistributorUserId ={0}", HiContext.Current.User.UserId); if (!string.IsNullOrEmpty(reviewQuery.ProductCode)) { builder.AppendFormat(" AND ProductCode LIKE '%{0}%'", DataHelper.CleanSearchString(reviewQuery.ProductCode)); } if (!string.IsNullOrEmpty(reviewQuery.Keywords)) { builder.AppendFormat(" AND p.ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(reviewQuery.Keywords)); } if (reviewQuery.CategoryId.HasValue) { builder.AppendFormat(" AND (p.CategoryId = {0}", reviewQuery.CategoryId.Value); builder.AppendFormat(" OR p.CategoryId IN (SELECT CategoryId FROM distro_Categories WHERE Path LIKE (SELECT Path FROM distro_Categories WHERE CategoryId = {0} AND DistributorUserId={1}) + '%' AND DistributorUserId={1}))", reviewQuery.CategoryId.Value, HiContext.Current.User.UserId); } if (!string.IsNullOrEmpty(reviewQuery.SortBy)) { builder.AppendFormat(" ORDER BY {0} {1}", DataHelper.CleanSearchString(reviewQuery.SortBy), reviewQuery.SortOrder.ToString()); } return(builder.ToString()); }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance ProductReview mock = CreateMockInstance(tm); bool result = DataRepository.ProductReviewProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); ProductReviewQuery query = new ProductReviewQuery(); query.AppendEquals(ProductReviewColumn.ProductReviewId, mock.ProductReviewId.ToString()); query.AppendEquals(ProductReviewColumn.ProductId, mock.ProductId.ToString()); query.AppendEquals(ProductReviewColumn.ReviewerName, mock.ReviewerName.ToString()); query.AppendEquals(ProductReviewColumn.ReviewDate, mock.ReviewDate.ToString()); query.AppendEquals(ProductReviewColumn.EmailAddress, mock.EmailAddress.ToString()); query.AppendEquals(ProductReviewColumn.Rating, mock.Rating.ToString()); if (mock.Comments != null) { query.AppendEquals(ProductReviewColumn.Comments, mock.Comments.ToString()); } query.AppendEquals(ProductReviewColumn.ModifiedDate, mock.ModifiedDate.ToString()); TList <ProductReview> results = DataRepository.ProductReviewProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }
public void LoadMoreProductReviews(System.Web.HttpContext context) { StringBuilder stringBuilder = new StringBuilder(); ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.SortBy = "ReviewDate"; productReviewQuery.SortOrder = SortAction.Desc; productReviewQuery.PageIndex = int.Parse(context.Request["pageNumber"]); productReviewQuery.PageSize = int.Parse(context.Request["size"]); productReviewQuery.productId = int.Parse(context.Request["ProductId"]); Globals.EntityCoding(productReviewQuery, true); DataTable dt = (DataTable)ProductCommentHelper.GetProductReviews(productReviewQuery).Data; stringBuilder.Append("{"); if (dt.Rows.Count > 0) { stringBuilder.Append("\"Success\":1,"); stringBuilder.Append("\"productcomments\":"); IsoDateTimeConverter convert = new IsoDateTimeConverter(); convert.DateTimeFormat = "yyyy-MM-dd"; string strReviews = Newtonsoft.Json.JsonConvert.SerializeObject(dt, Formatting.None, convert); stringBuilder.Append(strReviews); stringBuilder.Append("}"); } else { stringBuilder.Append("\"Success\":0"); stringBuilder.Append("}"); } context.Response.Write(stringBuilder.ToString()); context.Response.End(); }
public static DataTable GetProductReviews(int maxNum) { ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.PageIndex = 1; productReviewQuery.PageSize = maxNum; return(new ProductReviewDao().GetProductReviews(productReviewQuery).Data as DataTable); }
private void BindPtAndReviewsAndReplys() { ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.PageIndex = this.pager.PageIndex; productReviewQuery.PageSize = this.pager.PageSize; productReviewQuery.SortBy = "ReviewDate"; productReviewQuery.SortOrder = SortAction.Desc; productReviewQuery.orderId = this.orderId; DbQueryResult userProductReviewsAndReplys = ProductBrowser.GetUserProductReviewsAndReplys(productReviewQuery); this.dlstPts.DataSource = userProductReviewsAndReplys.Data; this.dlstPts.DataBind(); this.pager.TotalRecords = userProductReviewsAndReplys.TotalRecords; }
private DataGridViewModel <Dictionary <string, object> > GetDataList(ProductReviewQuery query) { DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >(); if (query != null) { DbQueryResult productReviews = ProductCommentHelper.GetProductReviews(query); dataGridViewModel.rows = DataHelper.DataTableToDictionary(productReviews.Data); dataGridViewModel.total = productReviews.TotalRecords; foreach (Dictionary <string, object> row in dataGridViewModel.rows) { ProductInfo productById = ProductHelper.GetProductById(row["ProductId"].ToInt(0)); ProductReviewInfo productReviewInfo = row.ToObject <ProductReviewInfo>(); row.Add("Type", query.havedReply); if (productById.ProductName.Trim().Length > 22) { row.Add("ProductNameStr", productById.ProductName.Trim().Substring(0, 22) + "..."); } else { row.Add("ProductNameStr", productById.ProductName.Trim()); } if (productReviewInfo.ReviewText.Trim().Length >= 50) { row.Add("ReviewTextStr", productReviewInfo.ReviewText.Trim().Substring(0, 50) + "..."); } else { row.Add("ReviewTextStr", productReviewInfo.ReviewText.Trim()); } if (query.havedReply.ToBool()) { if (productReviewInfo.ReplyText.Trim().Length >= 50) { row.Add("ReplyTextStr", productReviewInfo.ReplyText.Trim().Substring(0, 50) + "..."); } else { row.Add("ReplyTextStr", productReviewInfo.ReplyText.Trim()); } } } } return(dataGridViewModel); }
private void BindPtReview() { ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.Keywords = this.keywords; productReviewQuery.CategoryId = this.categoryId; productReviewQuery.ProductCode = this.productCode; productReviewQuery.PageIndex = this.pager.PageIndex; productReviewQuery.PageSize = this.pager.PageSize; productReviewQuery.SortOrder = SortAction.Desc; productReviewQuery.SortBy = "ReviewDate"; Globals.EntityCoding(productReviewQuery, true); DbQueryResult productReviews = ProductCommentHelper.GetProductReviews(productReviewQuery); this.dlstPtReviews.DataSource = productReviews.Data; this.dlstPtReviews.DataBind(); this.pager.TotalRecords = productReviews.TotalRecords; }
public override DataSet GetProductReviews(out int total, ProductReviewQuery reviewQuery) { DbCommand storedProcCommand = this.database.GetStoredProcCommand("sub_ProductReviews_Get"); this.database.AddInParameter(storedProcCommand, "PageIndex", DbType.Int32, reviewQuery.PageIndex); this.database.AddInParameter(storedProcCommand, "PageSize", DbType.Int32, reviewQuery.PageSize); this.database.AddInParameter(storedProcCommand, "IsCount", DbType.Boolean, reviewQuery.IsCount); this.database.AddInParameter(storedProcCommand, "sqlPopulate", DbType.String, BuildReviewsQuery(reviewQuery)); this.database.AddOutParameter(storedProcCommand, "Total", DbType.Int32, 4); if (reviewQuery.CategoryId.HasValue) { this.database.AddInParameter(storedProcCommand, "CategoryId", DbType.Int32, reviewQuery.CategoryId.Value); } DataSet set = this.database.ExecuteDataSet(storedProcCommand); total = (int)this.database.GetParameterValue(storedProcCommand, "Total"); return(set); }
private void BindPtReview() { ProductReviewQuery entity = new ProductReviewQuery { Keywords = this.keywords, CategoryId = this.categoryId, ProductCode = this.productCode, PageIndex = this.pager.PageIndex, PageSize = this.pager.PageSize, SortOrder = SortAction.Desc, SortBy = "ReviewDate" }; Globals.EntityCoding(entity, true); DbQueryResult productReviews = ProductCommentHelper.GetProductReviews(entity); this.dlstPtReviews.DataSource = productReviews.Data; this.dlstPtReviews.DataBind(); this.pager.TotalRecords = productReviews.TotalRecords; }
private void BindPtReview() { ProductReviewQuery entity = new ProductReviewQuery(); entity.Keywords = this.keywords; entity.CategoryId = this.categoryId; entity.ProductCode = this.productCode; entity.PageIndex = this.pager.PageIndex; entity.PageSize = this.pager.PageSize; entity.SortOrder = SortAction.Desc; entity.SortBy = "ReviewDate"; Globals.EntityCoding(entity, true); int total = 0; DataSet productReviews = ProductCommentHelper.GetProductReviews(out total, entity); this.dlstPtReviews.DataSource = productReviews.Tables[0].DefaultView; this.dlstPtReviews.DataBind(); this.pager.TotalRecords = total; this.pager1.TotalRecords = total; }
private void BindPtReview() { ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.Keywords = this.keywords; productReviewQuery.CategoryId = this.categoryId; productReviewQuery.ProductCode = this.productCode; productReviewQuery.PageIndex = this.pager.PageIndex; productReviewQuery.PageSize = this.pager.PageSize; productReviewQuery.SortOrder = SortAction.Desc; productReviewQuery.SortBy = "ReviewDate"; int totalRecords = 0; Globals.EntityCoding(productReviewQuery, true); System.Data.DataSet productReviews = SubsiteCommentsHelper.GetProductReviews(out totalRecords, productReviewQuery); this.dlstPtReviews.DataSource = productReviews.Tables[0].DefaultView; this.dlstPtReviews.DataBind(); this.pager.TotalRecords = totalRecords; this.pager1.TotalRecords = totalRecords; }
public void GetProductReviews(System.Web.HttpContext context) { string producId = context.Request["ProductId"]; int Id = 0; int.TryParse(producId, out Id); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{"); if (!int.TryParse(producId, out Id)) { stringBuilder.Append("\"Success\":-1"); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); context.Response.End(); return; } //处理平均数和总数 DataTable dt = ProductCommentHelper.GetReviewsCountAndAvg(Id); if (dt.Rows.Count > 0) { ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.SortBy = "ReviewDate"; productReviewQuery.SortOrder = SortAction.Desc; productReviewQuery.PageIndex = int.Parse(context.Request["pageNumber"]); productReviewQuery.PageSize = int.Parse(context.Request["size"]); productReviewQuery.productId = int.Parse(context.Request["ProductId"]); Globals.EntityCoding(productReviewQuery, true); DataTable dtcomments = (DataTable)ProductCommentHelper.GetProductReviews(productReviewQuery).Data; if (dtcomments.Rows.Count <= 0) { stringBuilder.Append("\"Success\":0"); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); context.Response.End(); return; } else { int amount = 0; try { int.TryParse(dt.Rows[0]["Amount"].ToString(), out amount); } catch { amount = 0; } stringBuilder.Append("\"Success\":1,"); stringBuilder.AppendFormat("\"Amount\":{0},", amount); stringBuilder.Append("\"data\":"); for (int i = 0; i < dtcomments.Rows.Count; i++) { dtcomments.Rows[i]["UserName"] = ReplaceStr(dtcomments.Rows[i]["UserName"].ToString()); } IsoDateTimeConverter convert = new IsoDateTimeConverter(); convert.DateTimeFormat = "yyyy-MM-dd"; string strReviews = Newtonsoft.Json.JsonConvert.SerializeObject(dtcomments, Formatting.None, convert); stringBuilder.Append(strReviews); stringBuilder.Append(","); //stringBuilder.AppendFormat("\"Avg\":{0}", Math.Round((1.0 * count / list.Count), 1)); double avg = 0; try{ double.TryParse(dt.Rows[0]["avg"].ToString(), out avg); } catch { avg = 0; } stringBuilder.AppendFormat("\"Avg\":{0}", avg.ToString("0.0")); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); context.Response.End(); return; } } else { stringBuilder.Append("\"Success\":0"); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); context.Response.End(); return; } }
public static DataSet GetProductReviews(out int total, ProductReviewQuery reviewQuery) { return(CommentsProvider.Instance().GetProductReviews(out total, reviewQuery)); }
public static DbQueryResult GetProductReviews(ProductReviewQuery reviewQuery) { return(new ProductReviewDao().GetProductReviews(reviewQuery)); }
public static DbQueryResult GetUserProductReviewsAndReplys(ProductReviewQuery query) { query.UserId = HiContext.Current.UserId; return(new ProductReviewDao().GetProductReviews(query)); }
public void LoadProductReview(HttpContext context) { if (!string.IsNullOrEmpty(context.Request["PageSize"]) && !string.IsNullOrEmpty(context.Request["CurrentPage"])) { int pageSize = context.Request["PageSize"].ToInt(0); int pageIndex = context.Request["CurrentPage"].ToInt(0); string orderId = context.Request["OrderId"].ToNullString(); ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.PageIndex = pageIndex; productReviewQuery.PageSize = pageSize; productReviewQuery.SortBy = "ReviewDate"; productReviewQuery.orderId = orderId; productReviewQuery.SortOrder = SortAction.Desc; DbQueryResult userProductReviewsAndReplys = ProductBrowser.GetUserProductReviewsAndReplys(productReviewQuery); DataTable data = userProductReviewsAndReplys.Data; string str = "{\"totalCount\":\"" + userProductReviewsAndReplys.TotalRecords + "\",\"data\":["; string text = ""; for (int i = 0; i < data.Rows.Count; i++) { if (text != "") { text += ","; } object[] obj = new object[30] { text, "{\"ProductId\":\"", data.Rows[i]["ProductId"], "\",\"ThumbnailUrl100\":\"", data.Rows[i]["ThumbnailUrl100"], "\",\"ProductName\":\"", data.Rows[i]["ProductName"], "\",\"SKUContent\":\"", data.Rows[i]["SKUContent"], "\",\"ReviewText\":\"", data.Rows[i]["ReviewText"].ToNullString().Replace("\\", ""), "\",\"Score\":\"", data.Rows[i]["Score"], "\",\"ApplicationPath\":\"\",\"ImageUrl1\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl1"].ToNullString()), "\",\"ImageUrl2\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl2"].ToNullString()), "\",\"ImageUrl3\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl3"].ToNullString()), "\",\"ImageUrl4\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl4"].ToNullString()), "\",\"ImageUrl5\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl5"].ToNullString()), "\",\"ReplyText\":\"", data.Rows[i]["ReplyText"], "\",\"ReviewDate\":\"", null, null, null, null }; object obj2; DateTime value; if (!data.Rows[i]["ReviewDate"].ToDateTime().HasValue) { obj2 = ""; } else { value = data.Rows[i]["ReviewDate"].ToDateTime().Value; obj2 = value.ToString("yyyy.MM.dd"); } obj[26] = obj2; obj[27] = "\",\"ReplyDate\":\""; object obj3; if (!data.Rows[i]["ReplyDate"].ToDateTime().HasValue) { obj3 = ""; } else { value = data.Rows[i]["ReplyDate"].ToDateTime().Value; obj3 = value.ToString("yyyy.MM.dd"); } obj[28] = obj3; obj[29] = "\"}"; text = string.Concat(obj); } str += text; str += "]}"; context.Response.Write(str); } }
public void LoadReview(HttpContext context) { if (!string.IsNullOrEmpty(context.Request["PageSize"]) && !string.IsNullOrEmpty(context.Request["CurrentPage"]) && !string.IsNullOrEmpty(context.Request["ProductId"])) { int pageSize = int.Parse(context.Request["PageSize"]); int pageIndex = int.Parse(context.Request["CurrentPage"]); int productId = int.Parse(context.Request["ProductId"]); int value = context.Request["type"].ToInt(0); ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.PageIndex = pageIndex; productReviewQuery.PageSize = pageSize; productReviewQuery.ProductId = productId; productReviewQuery.SortBy = "ReviewDate"; productReviewQuery.ProductSearchType = value; productReviewQuery.SortOrder = SortAction.Desc; DbQueryResult productReviews = ProductBrowser.GetProductReviews(productReviewQuery); DataTable data = productReviews.Data; string str = "{\"totalCount\":\"" + productReviews.TotalRecords + "\",\"data\":["; string text = ""; for (int i = 0; i < data.Rows.Count; i++) { if (text != "") { text += ","; } string text2 = data.Rows[i]["Picture"].ToString(); if (string.IsNullOrWhiteSpace(text2)) { text2 = "/templates/pccommon/images/users/hyzx_25.jpg"; } object[] obj = new object[34] { text, "{\"UserName\":\"", DataHelper.GetHiddenUsername(data.Rows[i]["UserName"].ToNullString()), "\",\"Picture\":\"", Globals.GetImageServerUrl("http://", text2), "\",\"ProductId\":\"", data.Rows[i]["ProductId"], "\",\"ThumbnailUrl100\":\"", data.Rows[i]["ThumbnailUrl100"], "\",\"ProductName\":\"", data.Rows[i]["ProductName"], "\",\"SKUContent\":\"", data.Rows[i]["SKUContent"], "\",\"ReviewText\":\"", data.Rows[i]["ReviewText"].ToNullString().Replace("\\", ""), "\",\"Score\":\"", data.Rows[i]["Score"], "\",\"ApplicationPath\":\"\",\"ImageUrl1\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl1"].ToNullString()), "\",\"ImageUrl2\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl2"].ToNullString()), "\",\"ImageUrl3\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl3"].ToNullString()), "\",\"ImageUrl4\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl4"].ToNullString()), "\",\"ImageUrl5\":\"", Globals.GetImageServerUrl("http://", data.Rows[i]["ImageUrl5"].ToNullString()), "\",\"ReplyText\":\"", data.Rows[i]["ReplyText"], "\",\"ReviewDate\":\"", null, null, null, null }; object obj2; DateTime value2; if (!data.Rows[i]["ReviewDate"].ToDateTime().HasValue) { obj2 = ""; } else { value2 = data.Rows[i]["ReviewDate"].ToDateTime().Value; obj2 = value2.ToString("yyyy/MM/dd"); } obj[30] = obj2; obj[31] = "\",\"ReplyDate\":\""; object obj3; if (!data.Rows[i]["ReplyDate"].ToDateTime().HasValue) { obj3 = ""; } else { value2 = data.Rows[i]["ReplyDate"].ToDateTime().Value; obj3 = value2.ToString("yyyy/MM/dd"); } obj[32] = obj3; obj[33] = "\"}"; text = string.Concat(obj); } str += text.Replace("\n", "").Replace("\t", "").Replace("\r", ""); str += "]}"; context.Response.Write(str); } }
protected override void AttachChildControls() { int num; int num2; if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId)) { base.GotoResourceNotFound(""); } this.litProdcutName = (Literal)this.FindControl("litProdcutName"); this.litSalePrice = (Literal)this.FindControl("litSalePrice"); this.litShortDescription = (Literal)this.FindControl("litShortDescription"); this.litSoldCount = (Literal)this.FindControl("litSoldCount"); this.productImage = (HtmlImage)this.FindControl("productImage"); this.productLink = (HyperLink)this.FindControl("productLink"); this.txtTotal = (HtmlInputHidden)this.FindControl("txtTotal"); this.sub = (HtmlControl)this.FindControl("sub"); string str = this.Page.Request["OrderId"]; string str2 = ""; if (!string.IsNullOrEmpty(str)) { OrderInfo orderInfo = ShoppingProcessor.GetOrderInfo(str); if ((orderInfo != null) && (orderInfo.ReferralUserId > 0)) { str2 = "&&ReferralId=" + orderInfo.ReferralUserId; } } else if (Globals.GetCurrentDistributorId() > 0) { str2 = "&&ReferralId=" + Globals.GetCurrentDistributorId().ToString(); } ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), this.productId); this.litProdcutName.SetWhenIsNotNull(product.ProductName); this.litSalePrice.SetWhenIsNotNull(product.MinSalePrice.ToString("F2")); this.litShortDescription.SetWhenIsNotNull(product.ShortDescription); this.litSoldCount.SetWhenIsNotNull(product.ShowSaleCounts.ToString()); this.productImage.Src = product.ThumbnailUrl180; this.productLink.NavigateUrl = "ProductDetails.aspx?ProductId=" + product.ProductId + str2; if (!int.TryParse(this.Page.Request.QueryString["page"], out num)) { num = 1; } if (!int.TryParse(this.Page.Request.QueryString["size"], out num2)) { num2 = 20; } ProductReviewQuery reviewQuery = new ProductReviewQuery { productId = this.productId, IsCount = true, PageIndex = num, PageSize = num2, SortBy = "ReviewId", SortOrder = SortAction.Desc }; this.rptProducts = (VshopTemplatedRepeater)this.FindControl("rptProducts"); DbQueryResult productReviews = ProductBrowser.GetProductReviews(reviewQuery); this.rptProducts.DataSource = productReviews.Data; this.rptProducts.DataBind(); this.txtTotal.SetWhenIsNotNull(productReviews.TotalRecords.ToString()); PageTitle.AddSiteNameTitle("商品评价"); //如果关闭了商品评论选项,提交按钮消失 SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); if (!masterSettings.EnableProductReviews) { sub.Visible = false; } //this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript",strHide); //this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "ServerMessageScript", "<script language='JavaScript' defer='defer'>alert(111);$('.pbox').hide();</script>"); }
public abstract DataSet GetProductReviews(out int total, ProductReviewQuery reviewQuery);
public DbQueryResult GetProductReviews(ProductReviewQuery reviewQuery) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat(" 1 = 1 "); if (!string.IsNullOrEmpty(reviewQuery.Keywords)) { reviewQuery.Keywords = DataHelper.CleanSearchString(reviewQuery.Keywords); string[] array = Regex.Split(reviewQuery.Keywords.Trim(), "\\s+"); stringBuilder.AppendFormat(" AND ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(array[0])); for (int i = 1; i < array.Length && i <= 4; i++) { stringBuilder.AppendFormat("AND ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(array[i])); } } if (!string.IsNullOrEmpty(reviewQuery.ProductCode)) { stringBuilder.AppendFormat(" AND ProductCode LIKE '%{0}%'", DataHelper.CleanSearchString(reviewQuery.ProductCode)); } if (!string.IsNullOrEmpty(reviewQuery.orderId)) { stringBuilder.AppendFormat(" AND orderId = '{0}'", reviewQuery.orderId); } if (reviewQuery.ProductId > 0) { stringBuilder.AppendFormat(" AND ProductId = {0}", reviewQuery.ProductId); } if (reviewQuery.CategoryId.HasValue) { stringBuilder.AppendFormat(" AND (CategoryId = {0}", reviewQuery.CategoryId.Value); stringBuilder.AppendFormat(" OR CategoryId IN (SELECT CategoryId FROM Hishop_Categories WHERE Path LIKE (SELECT Path FROM Hishop_Categories WHERE CategoryId = {0}) + '%'))", reviewQuery.CategoryId.Value); } if (reviewQuery.UserId.HasValue) { stringBuilder.AppendFormat(" AND UserId = {0}", reviewQuery.UserId); } DateTime value; if (reviewQuery.startDate.HasValue) { StringBuilder stringBuilder2 = stringBuilder; value = reviewQuery.startDate.Value; stringBuilder2.AppendFormat(" AND ReviewDate >= '{0}'", value.ToString()); } if (reviewQuery.endDate.HasValue) { StringBuilder stringBuilder3 = stringBuilder; value = reviewQuery.endDate.Value; stringBuilder3.AppendFormat(" AND ReviewDate <= '{0}'", value.ToString()); } if (reviewQuery.havedReply.HasValue) { if (reviewQuery.havedReply.Value) { stringBuilder.AppendFormat(" AND ReplyDate IS NOT NULL "); } else { stringBuilder.AppendFormat(" AND ReplyDate IS NULL "); } } if (reviewQuery.ProductSearchType.HasValue) { switch (reviewQuery.ProductSearchType.Value) { case 1: stringBuilder.AppendFormat(" AND Score > 3 AND Score < 6 "); break; case 2: stringBuilder.AppendFormat(" AND Score > 1 AND Score < 4 "); break; case 3: stringBuilder.AppendFormat(" AND Score < 2 "); break; case 4: stringBuilder.AppendFormat(" AND ImageUrl1 IS NOT NULL AND LTRIM(RTRIM(ImageUrl1)) <> '' "); break; } } return(DataHelper.PagingByRownumber(reviewQuery.PageIndex, reviewQuery.PageSize, reviewQuery.SortBy, reviewQuery.SortOrder, reviewQuery.IsCount, "(select PR.*,M.Picture from vw_Hishop_ProductReviews as PR left join aspnet_Members as M on PR.UserId=M.UserId) as DataTable", "ProductId", stringBuilder.ToString(), "*")); }
protected override void AttachChildControls() { int num; int num2; if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId)) { base.GotoResourceNotFound(""); } this.litProdcutName = (Literal)this.FindControl("litProdcutName"); this.litSalePrice = (Literal)this.FindControl("litSalePrice"); this.litShortDescription = (Literal)this.FindControl("litShortDescription"); this.litSoldCount = (Literal)this.FindControl("litSoldCount"); this.productImage = (HtmlImage)this.FindControl("productImage"); this.productLink = (HyperLink)this.FindControl("productLink"); this.txtTotal = (HtmlInputHidden)this.FindControl("txtTotal"); string str = this.Page.Request["OrderId"]; string str2 = ""; if (!string.IsNullOrEmpty(str)) { OrderInfo orderInfo = ShoppingProcessor.GetOrderInfo(str); if ((orderInfo != null) && (orderInfo.ReferralUserId > 0)) { str2 = "&&ReferralId=" + orderInfo.ReferralUserId; } } else if (Globals.GetCurrentDistributorId() > 0) { str2 = "&&ReferralId=" + Globals.GetCurrentDistributorId().ToString(); } ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), this.productId); this.litProdcutName.SetWhenIsNotNull(product.ProductName); this.litSalePrice.SetWhenIsNotNull(product.MinSalePrice.ToString("F2")); this.litShortDescription.SetWhenIsNotNull(product.ShortDescription); this.litSoldCount.SetWhenIsNotNull(product.ShowSaleCounts.ToString()); this.productImage.Src = product.ThumbnailUrl180; this.productLink.NavigateUrl = "ProductDetails.aspx?ProductId=" + product.ProductId + str2; if (!int.TryParse(this.Page.Request.QueryString["page"], out num)) { num = 1; } if (!int.TryParse(this.Page.Request.QueryString["size"], out num2)) { num2 = 20; } ProductReviewQuery reviewQuery = new ProductReviewQuery { productId = this.productId, IsCount = true, PageIndex = num, PageSize = num2, SortBy = "ReviewId", SortOrder = SortAction.Desc }; this.rptProducts = (VshopTemplatedRepeater)this.FindControl("rptProducts"); DbQueryResult productReviews = ProductBrowser.GetProductReviews(reviewQuery); this.rptProducts.DataSource = productReviews.Data; this.rptProducts.DataBind(); this.txtTotal.SetWhenIsNotNull(productReviews.TotalRecords.ToString()); PageTitle.AddSiteNameTitle("商品评价"); }
protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId)) { base.GotoResourceNotFound("错误的商品信息!"); } SiteSettings masterSettings = SettingsManager.GetMasterSettings(true); this.litProdcutName = (System.Web.UI.WebControls.Literal) this.FindControl("litProdcutName"); this.litSalePrice = (System.Web.UI.WebControls.Literal) this.FindControl("litSalePrice"); this.litShortDescription = (System.Web.UI.WebControls.Literal) this.FindControl("litShortDescription"); this.litSoldCount = (System.Web.UI.WebControls.Literal) this.FindControl("litSoldCount"); this.productImage = (System.Web.UI.HtmlControls.HtmlImage) this.FindControl("productImage"); this.productLink = (System.Web.UI.WebControls.HyperLink) this.FindControl("productLink"); this.txtTotal = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("txtTotal"); ProductInfo productSimpleInfo = ProductBrowser.GetProductSimpleInfo(this.productId); if (productSimpleInfo == null) { base.GotoResourceNotFound("该件商品已经被管理员删除"); } this.litProdcutName.SetWhenIsNotNull(productSimpleInfo.ProductName); this.litSalePrice.SetWhenIsNotNull(productSimpleInfo.MinSalePrice.ToString("F2")); this.litShortDescription.SetWhenIsNotNull(productSimpleInfo.ShortDescription); this.litSoldCount.SetWhenIsNotNull(productSimpleInfo.ShowSaleCounts.ToString()); if (!string.IsNullOrEmpty(productSimpleInfo.ThumbnailUrl180)) { this.productImage.Src = productSimpleInfo.ThumbnailUrl180; } else { this.productImage.Src = masterSettings.DefaultProductThumbnail5; } this.productLink.NavigateUrl = "ProductDetails.aspx?ProductId=" + productSimpleInfo.ProductId; int pageIndex; if (!int.TryParse(this.Page.Request.QueryString["page"], out pageIndex)) { pageIndex = 1; } int pageSize; if (!int.TryParse(this.Page.Request.QueryString["size"], out pageSize)) { pageSize = 20; } ProductReviewQuery productReviewQuery = new ProductReviewQuery(); productReviewQuery.productId = this.productId; productReviewQuery.IsCount = true; productReviewQuery.PageIndex = pageIndex; productReviewQuery.PageSize = pageSize; productReviewQuery.SortBy = "ReviewId"; productReviewQuery.SortOrder = SortAction.Desc; this.rptProducts = (AliOHTemplatedRepeater)this.FindControl("rptProducts"); DbQueryResult productReviews = ProductBrowser.GetProductReviews(productReviewQuery); this.rptProducts.DataSource = productReviews.Data; this.rptProducts.DataBind(); this.txtTotal.SetWhenIsNotNull(productReviews.TotalRecords.ToString()); PageTitle.AddSiteNameTitle("商品评价"); }
protected override void AttachChildControls() { int num; int num2; if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId)) { base.GotoResourceNotFound(""); } this.litProdcutName = (Literal)this.FindControl("litProdcutName"); this.litSalePrice = (Literal)this.FindControl("litSalePrice"); this.litShortDescription = (Literal)this.FindControl("litShortDescription"); this.litSoldCount = (Literal)this.FindControl("litSoldCount"); this.productImage = (HtmlImage)this.FindControl("productImage"); this.productLink = (HyperLink)this.FindControl("productLink"); this.txtTotal = (HtmlInputHidden)this.FindControl("txtTotal"); this.litPID = (Literal)this.FindControl("litPID"); this.litSkuId = (Literal)this.FindControl("litSkuId"); this.litItemid = (Literal)this.FindControl("litItemid"); this.litOrderId = (Literal)this.FindControl("litOrderId"); string orderID = this.Page.Request["OrderId"]; string str2 = ""; this.litSkuId.Text = Globals.RequestQueryStr("skuid"); this.litItemid.Text = Globals.RequestQueryNum("itemid").ToString(); MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (!string.IsNullOrEmpty(orderID)) { this.litOrderId.Text = orderID; OrderInfo orderInfo = ShoppingProcessor.GetOrderInfo(orderID); if ((orderInfo != null) && (orderInfo.ReferralUserId > 0)) { str2 = "&&ReferralId=" + orderInfo.ReferralUserId; } } else { LineItemInfo latestOrderItemByProductIDAndUserID = ProductBrowser.GetLatestOrderItemByProductIDAndUserID(this.productId, currentMember.UserId); if (latestOrderItemByProductIDAndUserID != null) { orderID = latestOrderItemByProductIDAndUserID.OrderID; this.Page.Response.Redirect(string.Concat(new object[] { "ProductReview.aspx?OrderId=", orderID, "&ProductId=", latestOrderItemByProductIDAndUserID.ProductId, "&skuid=", latestOrderItemByProductIDAndUserID.SkuId, "&itemid=", latestOrderItemByProductIDAndUserID.ID })); this.Page.Response.End(); } if (Globals.GetCurrentDistributorId() > 0) { str2 = "&&ReferralId=" + Globals.GetCurrentDistributorId().ToString(); } } ProductInfo product = ProductBrowser.GetProduct(currentMember, this.productId); this.litProdcutName.SetWhenIsNotNull(product.ProductName); this.litSalePrice.SetWhenIsNotNull(product.MinSalePrice.ToString("F2")); this.litShortDescription.SetWhenIsNotNull(product.ShortDescription); this.litSoldCount.SetWhenIsNotNull(product.ShowSaleCounts.ToString()); this.productImage.Src = product.ThumbnailUrl180; this.litPID.Text = this.productId.ToString(); this.productLink.NavigateUrl = "/ProductDetails.aspx?ProductId=" + product.ProductId + str2; if (!int.TryParse(this.Page.Request.QueryString["page"], out num)) { num = 1; } if (!int.TryParse(this.Page.Request.QueryString["size"], out num2)) { num2 = 20; } ProductReviewQuery reviewQuery = new ProductReviewQuery { productId = this.productId, IsCount = true, PageIndex = num, PageSize = num2, SortBy = "ReviewId", SortOrder = SortAction.Desc }; this.rptProducts = (VshopTemplatedRepeater)this.FindControl("rptProducts"); DbQueryResult productReviews = ProductBrowser.GetProductReviews(reviewQuery); this.rptProducts.DataSource = productReviews.Data; this.rptProducts.DataBind(); this.txtTotal.SetWhenIsNotNull(productReviews.TotalRecords.ToString()); PageTitle.AddSiteNameTitle("商品评价"); }