/* * 将专辑作为参数加入到购物车中,在 Cart 表中跟踪每个专辑的数量,在这个方法中,我们将会检查是在表中增加一个新行,还是仅仅在用户已经选择的专辑上增加数量。 */ public void AddToCart(album album) { Maticsoft.BLL.cart item = new Maticsoft.BLL.cart(); List <Maticsoft.DAL.SqlWhereClass> lssqlwhere = new List <Maticsoft.DAL.SqlWhereClass>(); Maticsoft.DAL.SqlWhereClass sqlwhere = new Maticsoft.DAL.SqlWhereClass("CartId", "CartId", Maticsoft.DAL.NetOperate.EQ, "'" + ShoppingCartid + "'"); lssqlwhere.Add(sqlwhere); sqlwhere = new Maticsoft.DAL.SqlWhereClass("AlbumId", "AlbumId", Maticsoft.DAL.NetOperate.EQ, album.AlbumId.ToString()); lssqlwhere.Add(sqlwhere); var CartItem = item.GetModel(lssqlwhere); if (CartItem == null) { CartItem = new cart { AlbumId = album.AlbumId, CartId = ShoppingCartid, Count = 1, DateCreated = DateTime.Now }; item.Add(CartItem); } else { CartItem.Count++; item.Update(CartItem); } }
public void MigrateCart(string userName) { Maticsoft.BLL.cart cartbll = new Maticsoft.BLL.cart(); List <Maticsoft.DAL.SqlWhereClass> lssqlwhere = new List <Maticsoft.DAL.SqlWhereClass>(); Maticsoft.DAL.SqlWhereClass sqlwhere = new Maticsoft.DAL.SqlWhereClass("CartId", "CartId", Maticsoft.DAL.NetOperate.EQ, "'" + ShoppingCartid + "'"); lssqlwhere.Add(sqlwhere); var cartitem = cartbll.GetModel(lssqlwhere); if (cartitem == null) { return; } cartitem.CartId = userName; cartbll.Update(cartitem); }