
<!--#include file="Include/Iheeo_Conn.asp"-->
<!--#include file="Include/Iheeo_config.asp"-->
<%
dim bookid,username,action
action=request.QueryString("action")
if request.Cookies("bjx")("username")<>"" then
username=trim(request.Cookies("bjx")("username"))
else
if request.Cookies("bjx")("dingdanusername")="" then
username=now()
username=replace(trim(username),"-","")
username=replace(username,":","")
username=replace(username," ","")
response.Cookies("bjx")("dingdanusername")=username
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from bjx_User ",conn,1,3
rs.addnew
rs("username")=username
rs("niming")=1
rs.update
rs.close
set rs=nothing

else
username=request.Cookies("bjx")("dingdanusername")
end if
end if
bookid=request.QueryString("id")

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

if bookid<>"" then
if not isnumeric(bookid) then 
response.write"<script>alert(""非法访问!"");window.close();</script>"
response.end
else
if not isinteger(bookid) then
response.write"<script>alert(""非法访问!"");window.close();</script>"
end if
end if
end if
'//删除收藏
select case action
case "del"
conn.execute "delete from BJX_action where actionid="&request.QueryString("actionid")
if request.QueryString("ll")=22 then
response.redirect "myuser.asp?action=shoucang"
else
response.redirect "buy.asp?action=show"
end if
response.End
case "add"
'//商品，判断是否存在
set rs_s=server.CreateObject("adodb.recordset")
rs_s.open "select * from BJX_goods where bookid="&bookid,conn,1,1
if request.Cookies("bjx")("reglx")="2" then 
	danjia=rs_s("vipjia")*(rs_s("shuilv")+1)
else
	danjia=rs_s("huiyuanjia")*(rs_s("shuilv")+1)
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 BJX_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 "buy.asp?action=show"
else
'//添加购物
rs.close
set rs=server.CreateObject("adodb.recordset")
rs.open "select bookid,username,shjiaid,zhuangtai,zonger,bookcount,niming from BJX_action",conn,1,3
rs.addnew
rs("bookid")=bookid
rs("username")=username
rs("zhuangtai")=7
rs("bookcount")=1
rs("shjiaid")=shjiaid
rs("zonger")=danjia
if request.Cookies("bjx")("username")="" then
rs("niming")=1
end if
rs.update
rs.close
set rs=nothing
response.Redirect "buy.asp?action=show"
end if
case "show"
'//////////////////
%>
<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="Include/Iheeo_head.asp"-->
<TABLE cellSpacing=0 cellPadding=0 width=970 align=center border=0>
  <TBODY>
    <TR>
      <TD class=b vAlign=top align=left><%
response.write "<table width=970 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 bjx_action.actionid,bjx_action.bookid,bjx_action.bookcount,bjx_action.zonger,bjx_action.shjiaid,BJX_goods.bookname,BJX_goods.shichangjia,BJX_goods.huiyuanjia,BJX_goods.vipjia,BJX_goods.shuilv from BJX_goods inner join  bjx_action on BJX_goods.bookid=bjx_action.bookid where bjx_action.username='"&username&"' and bjx_action.zhuangtai=7",conn,1,1 
%>
        <table width="970" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
          <tr>
            <td bgColor=#ffffff colSpan=5 height=1></TD>
          </tr>
          <form name='form1' method='post' action=xgsl.asp>
            <tr bgcolor=#f1f1f1 align=center>
              <td width=25% height="30">商品名称</td>
              <td width=15%>单价
                  <%if request.Cookies("bjx")("reglx")="2" then %>
        (VIP)
        <%else%>
        (会员)
        <%end if%>
              </td>
              <td width=15%>数量</td>
              <td width=15%>总价</td>
              <td width=10%>删除</td>
            </tr>
            <tr>
              <td bgColor=#cccccc colSpan=5 height=1></TD>
            </tr>
            <tr>
              <td bgColor=#f1f1f1 colSpan=5 height=3></TD>
            </tr>
            <%shuliang=rs.recordcount
jianshu=0
zongji=0
do while not rs.eof%>
            <tr bgcolor="#FFFFFF">
              <td height="30" width="25%" class="table-xia">　<a target="_blank" href="product.asp?Iheeoid=<%=rs("bookid")%>"><%=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"><%
a=rs("shuilv")
b=a+1
	if request.Cookies("bjx")("reglx")="2" then 
	
	response.write rs("vipjia")*b
	else
	response.write rs("huiyuanjia")*b
		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=buy.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=5 align=center class=table-xia> 购物车里有商品：<font color=red><%=shuliang%></font> 件　总数：<font color=red><%=jianshu%></font> 件　共计：<font color=red><%=zongji%></font> 元　您有预存款：<%
if request.Cookies("bjx")("yucun")<>"" then
response.write request.Cookies("bjx")("yucun")&" 元"
else
response.write "0 元"
end if%></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td align="center" height=50 colspan=5><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='Iheeo_car.asp';this.form.submit()">
              </td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td height="60" colspan="5" STYLE="PADDING-LEFT: 20px"> · 如果您想继续购物，请点选继续购物<br>
        · 如果您想更新已在购物车内的产品，请先修改，然后点选修改数量<br>
        · 如果您想全部取消已订购在购物车中的产品，请点选清空购物车<br>
        · 如果您满意您所购买的产品，请点选去收银台(会员须先登陆，非会员须先免费注册成为会员)<br>
              </td>
            </tr>
            <%set Godbook=server.CreateObject("adodb.recordset")
	Godbook.open "select * from BJX_action_jp where username='"&request.Cookies("bjx")("username")&"' and zhuangtai=7",conn,1,1
	if Godbook.recordcount>0 then%>
            <tr bgcolor="#ffffff">
              <td colspan=5><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 BJX_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></TD>
    </TR>
  </TBODY>
</TABLE>
<!--#include file="Include/Iheeo_service.asp"-->
<!--#include file="Include/Iheeo_foot.asp"-->
</body>
</html>
<%end select%>
