<!--#include file="conn.asp"-->
<%
if request.cookies("godbook")("username")="" then
response.write "<script language=javascript>alert('对不起，您还没有登陆！');window.close();</script>"
response.End
end if
dim bookid,username,action
action=request.QueryString("action")
username=trim(request.cookies("godbook")("username"))
bookid=request.QueryString("id")
'//删除收藏
select case action
case "del"
conn.execute "delete from shop_action where actionid="&request.QueryString("actionid")
if request.QueryString("ll")=22 then
response.redirect "myuser.asp?action=shoucang"
else
response.redirect "gouwu.asp?action=show"
end if
response.End
case "add"
'//商品，判断是否存在
set rs_s=server.CreateObject("adodb.recordset")
rs_s.open "select * from shop_books where bookid="&bookid,conn,1,1
if request.Cookies("godbook")("reglx")=1 then 
	danjia=rs_s("huiyuanjia")
else
	danjia=rs_s("vipjia")
end if
kucun=rs_s("kucun")
bookname=rs_s("bookname")
shjiaid=rs_s("shjiaid")
rs_s.close
set rs_s=nothing
if kucun<=0 then
response.write "<script language=javascript>alert('你选购的商品“"&bookname&"”暂时缺货不能放到购物车里，请选购其它商品！');window.close();</script>"
response.end
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select bookid,username,bookcount,zonger from shop_action where username='"&username&"' and bookid="&bookid&" and zhuangtai=7",conn,1,3
if rs.recordcount=1 then
if kucun<(rs("bookcount")+1) then
response.write "<script language=javascript>alert('你选购的商品“"&bookname&"”暂时缺货不能放到购物车里，请选购其它商品！');window.close();</script>"
response.end
end if
rs("zonger")=(rs("bookcount")+1)*danjia
rs("bookcount")=rs("bookcount")+1
rs.update
rs.close
set rs=nothing
response.Redirect "gouwu.asp?action=show"
else
'//添加购物
rs.close
set rs=server.CreateObject("adodb.recordset")
rs.open "select bookid,username,shjiaid,zhuangtai,zonger,bookcount from shop_action",conn,1,3
rs.addnew
rs("bookid")=bookid
rs("username")=username
rs("zhuangtai")=7
rs("bookcount")=1
rs("shjiaid")=shjiaid
rs("zonger")=danjia
rs.update
rs.close
set rs=nothing
response.Redirect "gouwu.asp?action=show"
end if
case "show"
'//////////////////
%>
<!--#include file="webconfig.asp"-->
<html><head><title><%=webname%>--我的购物车</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/css.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!--#include file="webtop.asp"-->
<%
response.write "<table width=760 align=center border=0 cellspacing=0 cellpadding=0 class=table-zuoyou bordercolor=#CCCCCC><tr><td background=images/class_bg.jpg height=50 class=table-shangxia>　<img src=images/ring02.gif align=absmiddle> <a href=index.asp>"&webname&"</a> >> 我的购物车</td</tr></table>"
set rs=server.CreateObject("adodb.recordset")
rs.open "select shop_action.actionid,shop_action.bookid,shop_action.bookcount,shop_action.zonger,shop_action.shjiaid,shop_books.bookname,shop_books.shichangjia,shop_books.huiyuanjia,shop_books.vipjia from shop_books inner join  shop_action on shop_books.bookid=shop_action.bookid where shop_action.username='"&request.cookies("godbook")("username")&"' and shop_action.zhuangtai=7",conn,1,1 
%>
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr><td bgColor=#ffffff colSpan=6 height=1></TD></tr>
<form name='form1' method='post' action=xgsl.asp>
<tr bgcolor=#f1f1f1 align=center> 
<td width=20% height="30">商家名称</td>
<td width=25%>商品名称</td>	  
<td width=15%>单价
          <%if request.cookies("godbook")("reglx")=2 then %>
          (VIP) 
          <%else%>
          (会员) 
          <%end if%>
          </font></div>
</td>
<td width=15%>数量</td>
<td width=15%>总价</td>
<td width=10%>删除</td>
</tr>
<tr><td bgColor=#cccccc colSpan=6 height=1></TD></tr>
<tr><td bgColor=#f1f1f1 colSpan=6 height=3></TD></tr>
<%shuliang=rs.recordcount
jianshu=0
zongji=0
do while not rs.eof%>
<tr bgcolor="#FFFFFF">
<td height="30" width="20%" align="center" class="table-xia"><%id=rs("shjiaid")
	if id>1 then
	set rs_shj=server.CreateObject("adodb.recordset")
rs_shj.open "select name from shjia where shjiaid="&id,conn,1,1%>
	<font color=#ff6600><%=rs_shj("name")%>
	<%
		rs_shj.close
	set rs_shj=nothing
	else
	response.write "<font color=#ff6600>"&webname&""
	end if%>
	</font></td>
      <td height="30" width="25%" class="table-xia">
	  <a href=list.asp?id=<%=rs("bookid")%> target=_blank><%=rs("bookname")%></a> 
          <input name=bookid type=hidden value="<%=rs("bookid")%>">
          <input name=actionid type=hidden value="<%=rs("actionid")%>">
      </td>
      <td width="15%" height="30" align="center" class="table-xia">
	  <%
	if request.Cookies("godbook")("reglx")=2 then 
	response.write rs("vipjia")
	else
	response.write rs("huiyuanjia")
	end if%>
	元</td>
	<td align="center" width="15%" height="30" class="table-xia">
	<input class=wenbenkuang name=bookcount value="<%=rs("bookcount")%>" size=5>
	</td>
	<td align="center" width="15%" height="30" class="table-xia">
	<font color=red><%=rs("zonger")%></font>
	元</td>
	<td align="center" width="10%" height="30" class="table-xia">
	<a href=gouwu.asp?action=del&actionid=<%=rs("actionid")%>><img src=images/trash.gif border=0></a>
	</td>
	</tr>
	<%
jianshu=jianshu+rs("bookcount")
zongji=zongji+rs("zonger")
rs.movenext
loop
rs.close
set rs=nothing%>
	<tr bgcolor="#FFFFFF">
	<td height=30 colspan=6 align=center class=table-xia>
	购物车里有商品：<font color=red><%=shuliang%></font> 件　总数：<font color=red><%=jianshu%></font> 件　共计：<font color=red><%=zongji%></font> 元　您有预存款：<%=request.cookies("godbook")("yucun")%> 元
	</td>
	</tr>
    <tr bgcolor="#FFFFFF"> 
      <td align="center" height=50 colspan=6> 
          <input name="imageField" type="image" src="images/cart01.gif" width="115" height="36" border="0" onFocus="this.blur()" onclick="javascript:window.close()">
          <input name="imageField2" type="image" src="images/cart03.gif" width="115" height="36" border="0" onFocus="this.blur()" onClick="this.form.action='xgsl.asp';this.form.submit()">
          <input name="imageField22" type="image" src="images/cart02.gif" width="115" height="36" border="0" onFocus="this.blur()" onClick="this.form.action='qkgwc.asp';this.form.submit()">
          <input name="imageField222" type="image" src="images/cart04.gif" width="115" height="36" border="0" onFocus="this.blur()" onClick="this.form.action='jszx.asp';this.form.submit()">
      </td>
    </tr>
    <tr bgcolor="#FFFFFF">
	  <td height="60" colspan="6" STYLE="PADDING-LEFT: 20px">
· 如果您想继续购物，请点选继续购物<br> 
· 如果您想更新已在购物车内的产品，请先修改，然后点选修改数量<br>
· 如果您想全部取消已订购在购物车中的产品，请点选清空购物车<br> 
· 如果您满意您所购买的产品，请点选去收银台(会员须先登陆，非会员须先免费注册成为会员)<br>
 </td>
	</tr>
    <%set godbook=server.CreateObject("adodb.recordset")
	godbook.open "select * from shop_action_jp where username='"&request.cookies("godbook")("username")&"' and zhuangtai=7",conn,1,1
	if godbook.recordcount>0 then%>
    <tr bgcolor="#ffffff"> 
      <td colspan=6> 
        <table width="95%" border="0" cellspacing="1" cellpadding="1" bgcolor="#cccccc" align="center">
          <tr bgcolor="#FFFFFF"> 
            <td colspan="3" height="30" align="center">您已选择的奖品清单</td>
          </tr>
          <tr bgcolor="#cccccc" align="center"> 
            <td height="30"><b><font color="#ffffff">奖品名称</font></b></td>
            <td height="30"><b><font color="#ffffff">使用积分</font></b></td>
            <td height="30"><b><font color="#ffffff">删除</font></b></td>
          </tr>
          <%
	while not godbook.eof%>
          <tr bgcolor="#FFFFFF"> 
            <td height="22"> 
              <%
	set godbook1=server.CreateObject("adodb.recordset")
	godbook1.open "select * from shop_jiangpin where bookid="&godbook("bookid"),conn,1,1
	if godbook1.recordcount=1 then
	response.write "<a href='listjp.asp?id="&godbook("bookid")&"' target=_blank>"&godbook1("bookname")&"</a>"
	end if
	godbook1.close
	set godbook1=nothing%>
            </td>
            <td align="center" height="30"><%=godbook("jifen")%></td>
            <td align="center" height="30"><a href="jifen.asp?actionid=<%=godbook("actionid")%>&action=del&ll=22"><img src=images/trash.gif border=0></a></td>
          </tr>
	<%
	godbook.movenext
	wend%>
</table>
</td>
</tr>
<%end if
godbook.close
set godbook=nothing%>
</form>
</table>
<script language=javascript>window.opener.location.reload();</script>
<!--#include file="service.asp"-->
<!--#include file="copyright.asp"-->
</body>
</html>
<%end select%>