예제 #1
0
        /*通过专辑的标识从用户的购物车中将这个专辑的数量减少 1,如果用户仅仅剩下一个,那么就删除这一行。*/
        public int RemoveFromCart(int id)
        {
            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("RecordId", "RecordId", Maticsoft.DAL.NetOperate.EQ, id.ToString());

            var CartItem = item.GetModel(lssqlwhere);

            int itemcount = 0;

            if (CartItem != null)
            {
                if (CartItem.Count > 1)
                {
                    CartItem.Count--;
                    itemcount = CartItem.Count;
                }
                else
                {
                    item.Delete(id);
                }
            }
            return(itemcount);
        }
예제 #2
0
        /*
         * 将专辑作为参数加入到购物车中,在 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);
            }
        }
예제 #3
0
        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);
        }