示例#1
0
 public void btnRefer_Click(object sender, EventArgs e)
 {
     if (this.ValidateConvert())
     {
         ProductReviewInfo target = new ProductReviewInfo();
         target.ReviewDate = DateTime.Now;
         target.ProductId = this.productId;
         target.UserId = HiContext.Current.User.UserId;
         target.UserName = this.txtUserName.Text;
         target.UserEmail = this.txtEmail.Text;
         target.ReviewText = this.txtContent.Text;
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<ProductReviewInfo>(target, new string[] { "Refer" });
         string msg = string.Empty;
         if (!results.IsValid)
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>) results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             this.ShowMessage(msg, false);
         }
         else if (((HiContext.Current.User.UserRole == UserRole.Member) || (HiContext.Current.User.UserRole == UserRole.Underling)) || this.userRegion(this.txtReviewUserName.Value, this.txtReviewPsw.Value))
         {
             if (string.IsNullOrEmpty(this.txtReviewCode.Value))
             {
                 this.ShowMessage("请输入验证码", false);
             }
             else if (!HiContext.Current.CheckVerifyCode(this.txtReviewCode.Value.Trim()))
             {
                 this.ShowMessage("验证码不正确", false);
             }
             else
             {
                 int buyNum = 0;
                 int reviewNum = 0;
                 ProductBrowser.LoadProductReview(this.productId, out buyNum, out reviewNum);
                 if (buyNum == 0)
                 {
                     this.ShowMessage("您没有购买此商品,因此不能进行评论", false);
                 }
                 else if (reviewNum >= buyNum)
                 {
                     this.ShowMessage("您已经对此商品进行了评论,请再次购买后方能再进行评论", false);
                 }
                 else if (ProductProcessor.InsertProductReview(target))
                 {
                     this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "success", string.Format("<script>alert(\"{0}\");window.location.href=\"{1}\"</script>", "评论成功", Globals.GetSiteUrls().UrlData.FormatUrl("productReviews", new object[] { this.productId })));
                 }
                 else
                 {
                     this.ShowMessage("评论失败,请重试", false);
                 }
             }
         }
     }
 }
示例#2
0
 public bool InsertProductReview(ProductReviewInfo review)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Hishop_ProductReviews (ProductId, UserId, ReviewText, UserName, UserEmail, ReviewDate) VALUES(@ProductId, @UserId, @ReviewText, @UserName, @UserEmail, @ReviewDate)");
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, review.ProductId);
     this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, review.UserId);
     this.database.AddInParameter(sqlStringCommand, "ReviewText", DbType.String, review.ReviewText);
     this.database.AddInParameter(sqlStringCommand, "UserName", DbType.String, review.UserName);
     this.database.AddInParameter(sqlStringCommand, "UserEmail", DbType.String, review.UserEmail);
     this.database.AddInParameter(sqlStringCommand, "ReviewDate", DbType.DateTime, DateTime.Now);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
示例#3
0
 public ProductReviewInfo GetProductReview(int reviewId)
 {
     ProductReviewInfo info = new ProductReviewInfo();
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_ProductReviews WHERE ReviewId=@ReviewId");
     this.database.AddInParameter(sqlStringCommand, "ReviewId", DbType.Int32, reviewId);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = ReaderConvert.ReaderToModel<ProductReviewInfo>(reader);
         }
     }
     return info;
 }
示例#4
0
 private void AddProductReview(HttpContext context)
 {
     int num2;
     int num3;
     context.Response.ContentType = "application/json";
     MemberInfo currentMember = MemberProcessor.GetCurrentMember();
     int productId = Convert.ToInt32(context.Request["ProductId"]);
     ProductBrowser.LoadProductReview(productId, currentMember.UserId, out num2, out num3);
     if (num2 == 0)
     {
         context.Response.Write("{\"success\":false, \"msg\":\"您没有购买此商品(或此商品的订单尚未完成),因此不能进行评论\"}");
     }
     else if (num3 >= num2)
     {
         context.Response.Write("{\"success\":false, \"msg\":\"您已经对此商品进行过评论(或此商品的订单尚未完成),因此不能再次进行评论\"}");
     }
     else
     {
         ProductReviewInfo review = new ProductReviewInfo {
             ReviewDate = DateTime.Now,
             ReviewText = context.Request["ReviewText"],
             ProductId = productId,
             UserEmail = currentMember.Email,
             UserId = currentMember.UserId,
             UserName = currentMember.UserName
         };
         if (ProductBrowser.InsertProductReview(review))
         {
             context.Response.Write("{\"success\":true}");
         }
         else
         {
             context.Response.Write("{\"success\":false, \"msg\":\"提交失败\"}");
         }
     }
 }
示例#5
0
 public override ProductReviewInfo GetProductReview(int reviewId)
 {
     ProductReviewInfo info = new ProductReviewInfo();
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_ProductReviews WHERE ReviewId=@ReviewId");
     database.AddInParameter(sqlStringCommand, "ReviewId", DbType.Int32, reviewId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateProductReview(reader);
         }
     }
     return info;
 }
示例#6
0
 public static ProductReviewInfo PopulateProductReview(IDataRecord reader)
 {
     if (null == reader)
     {
         return null;
     }
     ProductReviewInfo info = new ProductReviewInfo();
     info.ReviewId = (long) reader["ReviewId"];
     info.ProductId = (int) reader["ProductId"];
     info.UserId = (int) reader["UserId"];
     info.ReviewText = (string) reader["ReviewText"];
     info.UserName = (string) reader["UserName"];
     info.UserEmail = (string) reader["UserEmail"];
     info.ReviewDate = (DateTime) reader["ReviewDate"];
     return info;
 }
示例#7
0
 public static bool InsertProductReview(ProductReviewInfo review)
 {
     Globals.EntityCoding(review, true);
     return ProductProvider.Instance().InsertProductReview(review);
 }
示例#8
0
 public override bool InsertProductReview(ProductReviewInfo review)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO distro_ProductReviews (ProductId, UserId,DistributorUserId, ReviewText, UserName, UserEmail, ReviewDate) VALUES(@ProductId, @UserId,@DistributorUserId, @ReviewText, @UserName, @UserEmail, @ReviewDate)");
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, review.ProductId);
     this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, HiContext.Current.User.UserId);
     this.database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.SiteSettings.UserId.Value);
     this.database.AddInParameter(sqlStringCommand, "ReviewText", DbType.String, review.ReviewText);
     this.database.AddInParameter(sqlStringCommand, "UserName", DbType.String, review.UserName);
     this.database.AddInParameter(sqlStringCommand, "UserEmail", DbType.String, review.UserEmail);
     this.database.AddInParameter(sqlStringCommand, "ReviewDate", DbType.DateTime, DateTime.Now);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
示例#9
0
 public abstract bool InsertProductReview(ProductReviewInfo review);
示例#10
0
 public static bool InsertProductReview(ProductReviewInfo review)
 {
     return new ProductReviewDao().InsertProductReview(review);
 }
示例#11
0
 public void btnRefer_Click(object sender, EventArgs e)
 {
     if (this.ValidateConvert())
     {
         bool flag = true;
         Dictionary<string, string> dictionary = new Dictionary<string, string>();
         foreach (RepeaterItem item in this.orderItems.Items)
         {
             HtmlTextArea area = item.FindControl("txtcontent") as HtmlTextArea;
             HtmlInputHidden hidden = item.FindControl("hdproductId") as HtmlInputHidden;
             if (string.IsNullOrEmpty(area.Value.Trim()) || string.IsNullOrEmpty(hidden.Value.Trim()))
             {
                 flag = false;
                 break;
             }
             dictionary.Add(hidden.Value, area.Value);
         }
         if (!flag)
         {
             this.ShowMessage("请输入评价内容呀!", false);
         }
         else
         {
             string msg = "";
             foreach (KeyValuePair<string, string> pair in dictionary)
             {
                 int productId = Convert.ToInt32(pair.Key.Split(new char[] { '&' })[0].ToString());
                 string str2 = pair.Value;
                 ProductReviewInfo target = new ProductReviewInfo();
                 target.ReviewDate = DateTime.Now;
                 target.ProductId = productId;
                 target.UserId = HiContext.Current.User.UserId;
                 target.UserName = HiContext.Current.User.Username;
                 target.UserEmail = HiContext.Current.User.Email;
                 target.ReviewText = str2;
                 ValidationResults results = Hishop.Components.Validation.Validation.Validate<ProductReviewInfo>(target, new string[] { "Refer" });
                 msg = string.Empty;
                 if (!results.IsValid)
                 {
                     foreach (ValidationResult result in (IEnumerable<ValidationResult>) results)
                     {
                         msg = msg + Formatter.FormatErrorMessage(result.Message);
                     }
                     break;
                 }
                 int buyNum = 0;
                 int reviewNum = 0;
                 ProductBrowser.LoadProductReview(productId, out buyNum, out reviewNum);
                 if (buyNum == 0)
                 {
                     msg = "您没有购买此商品,因此不能进行评论";
                     break;
                 }
                 if (reviewNum >= buyNum)
                 {
                     msg = "您已经对此商品进行了评论,请再次购买后方能再进行评论";
                     break;
                 }
                 if (!ProductProcessor.InsertProductReview(target))
                 {
                     msg = "评论失败,请重试";
                     break;
                 }
             }
             if (msg != "")
             {
                 this.ShowMessage(msg, false);
             }
             else
             {
                 this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "success", string.Format("<script>alert(\"{0}\");window.location.href=\"{1}\"</script>", "评论成功", Globals.GetSiteUrls().UrlData.FormatUrl("user_UserProductReviews")));
             }
         }
     }
 }