<!--#include file="conn.asp"-->
<%
if request.Cookies("bjx")("username")="" then
response.write "<script language=javascript>alert('对不起，您还没有登陆！');window.location.href='login.asp';</script>"
response.End
end if
dim bookid,username,action
action=request.QueryString("action")
username=trim(request.Cookies("bjx")("username"))
bookid=request.QueryString("id")

if InStr(action,"'")>0 then
response.write"<script>alert(""非法访问!"");window.location.href='index.asp';</script>"
response.end
end if

if bookid<>"" then
if not isnumeric(bookid) then 
response.write"<script>alert(""非法访问!"");window.location.href='index.asp';</script>"
response.end
else
if not isinteger(bookid) then
response.write"<script>alert(""非法访问!"");window.location.href='index.asp';</script>"
end if
end if
end if
'//删除收藏
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("bjx")("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">
<style type="text/css">
<!--
.style2 {font-weight: bold}
.style3 {font-size: 14pt}
.style4 {font-size: 14}
.style5 {font-size: 14px}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width=900 border=0 align=center  cellpadding=0 cellspacing=0><tr> <td><!--#include file=top.asp--></td>
<%
response.write ""
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("bjx")("username")&"' and shop_action.zhuangtai=7",conn,1,1 
%>
    <td bgcolor="#E1E1E1">　
　　　　　　　　　</tr><tr><td bgcolor=e1e1e1 height=28>您目前的位置：<a href="index.asp">首页</a> -&gt;  购物车</td></tr></table>       
<div align="center">
  <center> 
<table width="900" border="0" cellspacing="1" cellpadding="0" >
<tr><td bgColor=#E1E1E1 colSpan=6 height=1 width="900"></TD></tr>
<form name='form1' method='post' action=xgsl.asp>
<tr bgcolor=#f1f1f1 align=center> 
<td width=172 height="0" bgcolor="#ff6600">商家名称</td>
<td width=228 bgcolor="#ff6600">产品名称</td>	  
<td width=135 bgcolor="#ff6600">单价       
          <%if request.Cookies("bjx")("reglx")=2 then %>
          (VIP)        
          <%else%>
          (会员)        
          <%end if%>
</td>
<td width=135 bgcolor="#ff6600">数量</td>
<td width=135 bgcolor="#ff6600">总价</td>
<td width=60 bgcolor="#ff6600">删除</td>
</tr>
<%shuliang=rs.recordcount
jianshu=0
zongji=0
do while not rs.eof%>
<tr bgcolor="#FFFFFF">
<td height="30" width="172" 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="228" class="table-xia" align="center">
	  <a href=list.asp?id=<%=rs("bookid")%> ><%=rs("bookname")%></a> 
          <input name=bookid type=hidden value="<%=rs("bookid")%>">
          <input name=actionid type=hidden value="<%=rs("actionid")%>">
      </td>
      <td width="135" height="30" align="center" class="table-xia">
	  <%
	if request.Cookies("bjx")("reglx")=2 then 
	response.write rs("vipjia")
	else
	response.write rs("huiyuanjia")
	end if%>
	元</td>
	<td align="center" width="135" height="30" class="table-xia">
	<input class=wenbenkuang name=bookcount value="<%=rs("bookcount")%>" size=5>
	</td>
	<td align="center" width="135" height="30" class="table-xia">
	<font color=red><%=rs("zonger")%></font>
	元</td>
	<td align="center" width="60" 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 width="885">
	购物车里有产品：<font color=red><%=shuliang%></font> 件　总数：<font color=red><%=jianshu%></font> 件　共计：<font color=red><%=zongji%></font> 元　您有预存款：<%=request.Cookies("bjx")("yucun")%> 元
	</td>
	</tr>
    <tr bgcolor="#FFFFFF"> 
      <td align="center" height=50 colspan=6 width="885"> 
          <input name="imageField" type="image" src="imagess/cart01.gif" width="93" height="43" border="0" onFocus="this.blur()" onclick="javascript:window.close()">
          <input name="imageField2" type="image" src="imagess/cart03.gif" width="97" height="43" border="0" onFocus="this.blur()" onClick="this.form.action='xgsl.asp';this.form.submit()">
          <input name="imageField22" type="image" src="imagess/cart02.gif" width="107" height="43" border="0" onFocus="this.blur()" onClick="this.form.action='qkgwc.asp';this.form.submit()">
          <input name="imageField222" type="image" src="imagess/cart04.gif" width="87" height="43" border="0" onFocus="this.blur()" onClick="this.form.action='jszx.asp';this.form.submit()">
      </td>
    </tr>
    <tr bgcolor="#FFFFFF">
	  <td height="29" colspan="6" width="894"><img src="imagess/tp06.gif" width="17" height="17" align="absmiddle"> 
      如果您想继续购物，请点选继续购物</tr>
          <tr valign="middle"> 
            <td height="25" colspan="6" width="885"><img src="imagess/tp06.gif" width="17" height="17" align="absmiddle"> 
              如果您想更新已在购物车内的产品，请先修改，然后点选修改数量</td>
          </tr>
          <tr valign="middle"> 
            <td height="25" colspan="6" width="885"><img src="imagess/tp06.gif" width="17" height="17" align="absmiddle"> 
              如果您想全部取消已订购在购物车中的产品，请点选清空购物车</td>
          </tr>
          <tr valign="middle"> 
            <td height="25" colspan="6" width="885"> <img src="imagess/tp06.gif" width="17" height="17" align="absmiddle"> 
            如果您满意您所购买的产品，请点选去收银台(会员须先 <a href="login.asp">[<font color=red>登陆</font>]</a> ，非会员须先 <a href="reg.asp">[<font color=red>免费注册成为会员</font>]</a> )<br>            </td>  
	</tr>
    <%set Godbook=server.CreateObject("adodb.recordset")
	Godbook.open "select * from shop_action_jp where username='"&request.Cookies("bjx")("username")&"' and zhuangtai=7",conn,1,1
	if Godbook.recordcount>0 then%>
    <tr bgcolor="#ffffff"> 
      <td colspan=6 width="885"> 
        <table width="95%" border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF" align="center">
          <tr bgcolor="#FFFFFF"> 
            <td colspan="3" height="30" align="center">您已选择的奖品清单</td>
          </tr>
          <tr bgcolor="#FF6600" align="center"> 
            <td height="20"><b><font color="#ffffff">奖品名称</font></b></td>
            <td height="20"><b><font color="#ffffff">使用积分</font></b></td>
            <td height="20"><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")&"' >"&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>
  </center>
</div>
<!--#include file="copyright.asp"-->
</body>
</html>
<%end select%>








