欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

做購物車系統(tǒng)時(shí)利用到得幾個(gè)sqlserver 存儲(chǔ)過程

 更新時(shí)間:2009年12月15日 23:04:26   作者:  
最近使用asp.net+sql2000開始開發(fā)一個(gè)小型商城系統(tǒng),其中涉及到得購物車功能主要是仿照淘寶實(shí)現(xiàn)的.
即以游客身份登錄網(wǎng)站時(shí)以cookie的方式存儲(chǔ)購物車,而以登錄用戶的身份進(jìn)入時(shí)將購物車信息存儲(chǔ)到數(shù)據(jù)庫中去,若是先以游客身份完成購物再登錄繼續(xù)購物,則將cookies購物車存入數(shù)據(jù)庫;
其中涉及到的存儲(chǔ)過程主要如下:
一:已登錄會(huì)員添加商品到購物車功能:
復(fù)制代碼 代碼如下:

/* @store_sum表示要添加的商品數(shù)量,添加同時(shí)確認(rèn)購物車中自己已有的數(shù)量與將要加入的數(shù)量之和是否超過庫存 */
CREATE proc ncp_Cart_Add
(
@store_id int,
@store_sum int=1,
@member_id int
)
as

DECLARE @Amount int
DECLARE @NowAmount int
Begin
select @Amount=(select amount from ncp_store where id=@store_id)
IF EXISTS(SELECT 1 FROM [ncp_cart] WHERE store_id=@store_id and member_id=@member_id)
Begin
select @NowAmount=(select store_sum+@store_sum from ncp_cart WHERE store_id=@store_id and member_id=@member_id)
if @NowAmount>@Amount
return 0
else
UPDATE [ncp_cart] SET store_sum=store_sum+@store_sum,addtime=getDate() where store_id=@store_id and member_id=@member_id
return 1
End
ELSE
Begin
select @NowAmount=(select store_sum from ncp_cart WHERE store_id=@store_id and member_id=@member_id)
if @NowAmount>@Amount
return 0
else
INSERT INTO [ncp_cart](store_id,store_sum,member_id) values(@store_id,@store_sum,@member_id)
return 1
END
End
GO

二:購物車的刪除功能

復(fù)制代碼 代碼如下:

/* type 為1是全部刪 0時(shí)只刪一個(gè) */
CREATE PROCEDURE ncp_Cart_Del
@type int=0,
@store_id int ,
@member_id int
AS
begin
if @type=0
delete from [ncp_cart] where store_id=@store_id and member_id=@member_id
else
delete from [ncp_cart] where member_id=@member_id
End
GO

相關(guān)文章

最新評(píng)論