<!--#include file="conn.asp"-->
<!--#include file="fuction.asp"-->
<%
if session("username")="" then
response.write "<script language=javascript>alert('Pleas login!');window.history.go(-1);</script>"
response.End
end if
username=nosql(session("username"))
shopid=nosql(request("shopid"))
if shopid="" then
response.write "<script language=javascript>alert('对不起，您没有选择商品！');window.history.go(-1);</script>"
response.End
end if
Set rs_s=Server.CreateObject("Adodb.RecordSet")
rs_s.Open "Select * from wygkcn_shop where shopid in ("&shopid&")",Conn,3,3
while not rs_s.eof 
if session("reglx")=2 then 
	danjia=rs_s("vipjia")
else
	danjia=rs_s("huiyuanjia")
end if
kucun=rs_s("kucun")
shopname=rs_s("shopname")
if kucun<=0 then
response.write "<script language=javascript>alert('你选购的商品“"&shopname&"”暂时缺货不能放到购物车里，请选购其它商品！');window.history.go(-1);</script>"
response.end
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_action where username='"&username&"' and shopid="&trim(rs_s("shopid"))&" and zhuangtai=7",conn,1,3

if rs.recordcount=1 then
'//修改数量
if kucun<(rs("shopcount")+1) then
response.write "<script language=javascript>alert('你选购的商品“"&shopname&"”暂时缺货不能放到购物车里，请选购其它商品！');window.history.go(-1);</script>"
response.end
end if
rs("zonger")=(rs("shopcount")+1)*danjia
rs("shopcount")=rs("shopcount")+1
rs.update
rs.close
set rs=nothing
else
'//添加购物
rs.close
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_action",conn,1,3
rs.addnew
rs("shopid")=trim(rs_s("shopid"))
rs("username")=username
rs("zhuangtai")=7
rs("shopcount")=1
rs("zonger")=danjia
rs.update
rs.close
set rs=nothing
end if
rs_s.movenext
wend
rs_s.close
set rs_s=nothing
response.Redirect "gouwu.asp?action=show"
%>