<!--#include file="inc_top.asp" -->
<table width="762" bgcolor="#ffffff" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="350" valign="middle"> 
<%
'如果session为空，转入错误界面
if session.sessionid="" then
Response.Write("<script>alert(""本网站购物系统需要cookies的支持，请先调整您的浏览器设置!"");window.history.go(-1);</script>")
end if
'购买物品的处理
if request("x")="del-q" then
conn.execute("Delete ls_cart where sessionid="&session.sessionid&"")
conn.execute("Delete ls_userid where sessionid="&session.sessionid&"")
end if
if request("x")="del" then
set rs = conn.execute("select * from ls_cart where sessionid="&session.sessionid&" and cpid="&request("cpid")&"")
set rs2 = conn.execute("select * from ls_cart where sessionid="&session.sessionid&" and userid="&rs("userid")&"")
if rs2.RecordCount>1 then
conn.execute("Delete ls_cart where sessionid="&session.sessionid&" and cpid="&request("cpid")&"")
else
conn.execute("Delete ls_cart where sessionid="&session.sessionid&" and cpid="&request("cpid")&"")
conn.execute("Delete ls_userid where sessionid="&session.sessionid&" and userid="&rs2("userid")&"")
end if
rs.close
rs2.close
set rs2=nothing
end if
'批量更新
if request("x")="yes" then
On Error Resume Next
set rs = conn.execute("select * from ls_cart where sessionid="&session.sessionid&" order by id")
do while not rs.eof
id=rs("id")
sl=CInt(request(rs("id")))
     If sl <= 0 Then 
        sl =rs("sl")
        If sl <= 0 Then sl = 1
     End If
conn.execute("Update ls_cart set sl = "&sl&" where id="&id&"")
rs.movenext
loop
rs.close
end if

'显示购物车内产品
set rs = conn.execute("select * from ls_cart where sessionid="&session.sessionid&" order by id")
if rs.eof then
Response.redirect "nothing.asp"
end if%>
      <form action=cart.asp?x=yes method="POST" name=form1>
        <input type="hidden" name="cmdShow" value="Yes">
        <script language="javascript">
    function confirmdel(){
       if (confirm("您确定清空购物车中选购的全部产品？！！")) 
       window.location.href="cart.asp?x=del-q"
     }  
</script>
<script language=javascript>
function onlyNum()
{
  if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode>=96&&event.keyCode<=105)))
    event.returnValue=false;
}
</script>
        <table width="580" border="0" align="center">
          <tr align="center"> 
            <td colspan="6"><img src="image/lc.gif" width="496" height="22"></td>
          </tr>
          <tr> 
            <td colspan="6">您选购的产品清单如下：</td>
          </tr>
          <tr valign="middle" bgcolor="#ff6600"> 
            <td width="255" height="20" align="center"><font color="#FFFFFF">产 
              品 名 称</font></td>
            <td width="75" align="center"><font color="#FFFFFF">市场价</font></td>
            <td width="75" height="20" align="center"><font color="#FFFFFF">会员价</font></td>
            <td width="50" height="20" align="center"><font color="#FFFFFF">数 
              量</font></td>
            <td width="75" height="20" align="center"><font color="#FFFFFF">金 
              额</font></td>
            <td width="50" align="center"><font color="#FFFFFF">删除</font></td>
          </tr>
          <%
   On Error Resume Next
   Sum1 = 0
   Sum2 = 0
   While Not rs.EOF
     Quatity = CInt( Request( rs("id")) )
     If Quatity <= 0 Then 
        Quatity = rs("sl")
        If Quatity <= 0 Then Quatity = 1
     End If
     Sum1 = Sum1 + csng(rs("jg1")) * Quatity
     Sum2 = Sum2 + csng(rs("jg2")) * Quatity
     Sum1=FormatNumber(Sum1,2) 
     Sum2=FormatNumber(Sum2,2) 
	 js=Sum1-Sum2
%>
          <tr valign="middle" bgcolor="#f7f7f7"> 
            <td width="255" height="20"><%=rs("mc")%></td>
            <td width="75" align="center"><%=rs("jg1")%></td>
            <td width="75" height="20" align="center"><%=rs("jg2")%></td>
            <td width="50" height="20" align="center"> 
              <input name="<%=rs("id")%>" type="Text" class="wenbenkuang" value="<%=Quatity%>" size="4" maxlength="5" onkeydown="onlyNum();"> 
            </td>
            <td width="75" height="20" align="center"> 
              <div align="center"><%=FormatNumber(csng(rs("jg2"))*Quatity,2)%></div></td>
            <td width="50" align="center"><a href="?x=del&cpid=<%=rs("cpid")%>">删除</a></td>
          </tr>
          <%
     rs.MoveNext
     Wend
%>
          <tr valign="middle" bgcolor="#f7f7f7"> 
            <td height="20" colspan="6" align="right">市场价:<font color="#ff3333">￥<%=Sum1%>元</font>&nbsp;会员价:<font color="#ff3333">￥<%=Sum2%>元</font>&nbsp;立即节省:<font color="#ff3333">￥<%=js%>元&nbsp;</td>
          </tr>
          <tr valign="middle"> 
            <td height="40" colspan="6" align="center"><a href="#" onclick="javascript:window.history.go(-1)" onFocus="this.blur()"><img src="image/cart01.gif" width="93" height="43" border="0"></a> 
              <input name="imageField" type="image" src="image/cart03.gif" width="97" height="43" border="0" onFocus="this.blur()">
              <a href="#" onClick="javascript: confirmdel()" onFocus="this.blur()"><img src="image/cart02.gif" width="107" height="43" border="0"></a> 
              <a href="go-cart.asp" onFocus="this.blur()"><img src="image/cart04.gif" width="87" height="43" border="0"></a>&nbsp; 
              <div align="right"> </div></td>
          </tr>
          <tr valign="middle"> 
            <td height="25" colspan="6"><img src="image/tp06.gif" align="absmiddle"> 
              如果您想<a href="?del=yes">继续</a>购物，请点选继续购物 </td>
          </tr>
          <tr valign="middle"> 
            <td height="25" colspan="6"><img src="image/tp06.gif" align="absmiddle"> 
              如果您想更新已在购物车内的产品，请先修改，然后点选修改数量</td>
          </tr>
          <tr valign="middle"> 
            <td height="25" colspan="6"><img src="image/tp06.gif" align="absmiddle"> 
              如果您想全部取消已订购在购物车中的产品，请点选清空购物车</td>
          </tr>
          <tr valign="middle"> 
            <td height="25" colspan="6"> <img src="image/tp06.gif" align="absmiddle"> 
              如果您满意您所购买的产品，请点选去收银台(会员须先登陆，非会员<br> &nbsp;&nbsp;&nbsp; 须先<a href="zhuce-1.asp">免费注册成为会员</a>)<br> 
            </td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<% rs.close
set rs=nothing%>
<!--#include file="inc_end.asp" -->