首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

关于购物车的代码修改~小女子~

2012-04-20 
关于购物车的代码修改~~小女子请求帮助~~~二次开发的项目~~ 我要在这个基础上修改1.原来它的代码是它接收

关于购物车的代码修改~~小女子请求帮助~~~
二次开发的项目~~ 我要在这个基础上修改 

1.原来它的代码是 它接收一件商品的id通过页面传值过来,到这里
  ProfileCommon Profile = new ProfileCommon();
  string itemId = Request.QueryString["addItem"];
 if (!string.IsNullOrEmpty(itemId))
  {
  Profile.ShoppingCart.Add(itemId);
  HttpContext.Current.Profile.Save();
  Response.Redirect("~/ShoppingCart.aspx", true);
  }

 2..............ProfileCommon()是这个里面的
 public virtual YXShop.BLL.Cart ShoppingCart
  {
  get
  {
  return ((YXShop.BLL.Cart)(HttpContext.Current.Profile.GetPropertyValue("ShoppingCart")));
  }
  set
  {
  this.SetPropertyValue("ShoppingCart", value);
  }
  }


3..YXShop.BLL.Cart里面的
public void Add(string ProId)
  {
  CartItemInfo cartItem;

  if (!cartItems.TryGetValue(ProId, out cartItem))
  {
  Item item = new Item();
  ItemInfo data = item.GetItem(ProId);

  if (data != null)
  {
  CartItemInfo newItem = new CartItemInfo(data.Makeprice, data.ProductName, 1, (decimal)data.Price, data.CategoryId, Convert.ToInt32(ProId), data.Integral, data.Image, data.NeedIntegral, data.NeedDummyMoney, data.PutoutTyID, data.PutoutID);

  cartItems.Add(ProId, newItem);

  }
  }
  else
  {
  cartItem.Quantity++;
  }
  }

4..这是前台显示购物车的代码
  #region 购车信息
  public static string ShoppingCartControl()
  {
  ProfileCommon Profile = new ProfileCommon();
  StringBuilder shtml = new StringBuilder();
  ICollection<CartItemInfo> cart = Profile.ShoppingCart.CartItems;
  if (cart.Count > 0)
  {
  YXShop.Common.SystemicParameter.SystemicParameters();
  if (YXShop.Common.SystemicParameter.GeldMode == 1)
  {
  shtml.Append("<div id=\"ShopInfo\">");
  foreach (CartItemInfo info in cart)
  {
  shtml.Append("<ul class=\"shop4\">");
  shtml.Append("<li class=\"shop4-1\"><input type=\"checkbox\" name=\"ShoppCartID\" value=\"" + info.ProductId + "\"></li>");
  shtml.Append("<li class=\"shop4-2\"><img src=\"" + YXShop.Common.SystemicParameter.DummyList + info.Image + "\" width=\"83px\" height=\"60px\"></li>");
  shtml.Append("<li class=\"shop4-3\">" + info.ProductName + "</li>");

  shtml.Append("<li class=\"shop4-4\"><span style=\"color:#FF6600\">" + info.MarckerPricr + "</span></li>");

  shtml.Append("<li class=\"shop4-7\"><span style=\"color:#FF6600; font-weight:700\">" + info.Integral + "</span></li>");

  shtml.Append("<li class=\"shop4-4\"><span style=\"color:#FF6600; font-weight:700\">" + info.Price + "</span></li><li class=\"shop4-8\"><span style=\"color:#FF6600; font-weight:700\">");


  string str1 = "";
  if (info.NeedIntegral.ToString() != "0")
  {
  str1 = info.NeedIntegral.ToString();
  }
  shtml.Append("" + str1 + "</span></li>");
  shtml.Append("<li class=\"shop4-6\"><input type=\"text\" style=\"width:36px\" value=\"" + info.Quantity + "\" onBlur=\"UpdataShoppCart(this.value,'" + info.ProductId + "')\"></input></li>");

  shtml.Append("<li class=\"shop4-7\"><span style=\"color:#FF6600; font-weight:700\">" + Convert.ToDecimal(info.Price) * Convert.ToInt32(info.Quantity) + "</span></li>");
  shtml.Append("</ul>");
  }
  shtml.Append("</div>");
  shtml.Append("<ul class=\"shop5\">");
  shtml.Append("<li>");
  shtml.Append("<input type=\"button\" value=\"删除\" onclick=\"AbuthDle()\" /></li>");
  shtml.Append("<li style=\"text-align:right;width:90%\"><a href=\"Default.aspx\">");
  shtml.Append("<img src=\"" + YXShop.Common.SystemicParameter.DummyList + YXShop.Common.SystemicParameter.WhetherfilePath + "/images/shop_bt2.jpg\" border=\"0\"></a>&nbsp;&nbsp;<a href=\"" + YXShop.Common.SystemicParameter.DummyList + "Membercenter/submitOrder.aspx?MeId=0&MeTyId=0\"><img src=\"" + YXShop.Common.SystemicParameter.DummyList + YXShop.Common.SystemicParameter.WhetherfilePath + "/images/shop_bt3.jpg\" border=\"0\"></a></li>");
  shtml.Append("</ul>");
  }
  }

}


————————————————————————————————————————————————————————————————————————————
我现在的问题是:我要传入一件商品,当然是商品表中的商品,但是我想这个商品的价格一律10元,我刚开始做的是传二个参数,但是似乎行不通,是不是需要代码的重写?但是我不知道在哪修改?

原来的代码是传入的商品通过id查询出来商品的一些信息放在一个自己建的实体类里面.....这是我理解的.不知道是不是???
如果有这样情况的请帮帮我~~~




[解决办法]
CartItemInfo newItem = new CartItemInfo(data.Makeprice, data.ProductName, 1, (decimal)data.Price, data.CategoryId, Convert.ToInt32(ProId), data.Integral, data.Image, data.NeedIntegral, data.NeedDummyMoney, data.PutoutTyID, data.PutoutID);
data.Price是不是价格,是的话,你直接给10就行了
[解决办法]
呵呵,系统是参照petshop4的架构做的YxShop商城系统,利用.Net个性化配置类Profile实现的购物车功能,需要在Profile.ShoppingCart配置类中添加你要添加的属性,在这里不行。
[解决办法]
不是解决了吗?呵呵,小女子~~~~

热点排行