<!--#include file="../admin/conn.asp" -->
 
<%
Sub PutToShopBag( ProdId, ProductList )
   If Len(ProductList) = 0 Then
      ProductList = "'" & ProdId & "'"
   ElseIf InStr( ProductList, ProdId ) <= 0 Then
      ProductList = ProductList & ", '" & ProdId & "'"
   End If
End Sub
%>
<html>
<head>
<title>购物车-</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Robots" content="index,follow">
<link rel="stylesheet" href="../shop.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onload="self.focus();">


<%
If Request("ok") = "ok" Then
   ProductList = ""
   Products = Split(Request("ProdId"), ", ")


   For I=0 To UBound(Products)
      PutToShopBag Products(I), ProductList
   Next
   Session("ProductList") = ProductList
End If

ProductList = Session("ProductList")
'如果购物列表为空则提示出错
if productlist="" then
	response.redirect "../error.asp?error=007"
	response.end
else
'根据所选商品的编号从数据库读取商品名称、价格
Set rsc=Server.CreateObject("ADODB.RecordSet") 
sqlc="select * from shop where ProdId in ("&productlist&") order by ProdId"
rsc.open sqlc,conn,1,1
end if

if session("user_id")="" then 
userkk=10                        '游客购物折扣为10
session("userkou")=userkk        '将折扣存入session，供后面结算时使用
else
userkk=10
'userkk=session("userkou")        '如果是会员，则读取会员登陆时存入session中的折扣
end if
%>


<table width="630" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr><td height="50">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#FF3333"><b>您选择的商品已经放入购物车，您现在可以前往收银台支付，也可以继续购物。</b></font><br></td></tr>
  <tr><td>
      <table border="0" cellspacing="1" cellpadding="4" align="center" width="567" bgcolor="#CCCCCC">
        <form action="check.asp" method="POST" name="check">
          <tr bgcolor="#FFFFFF"> 
            <td width="56" height="25"> 
              <div align="center"><font color="B0266D">选择</font></div>
            </td>
            <td width="283"> 
              <div align="center"><font color="B0266D">商 品 名 称</font></div>
            </td>
            <td width="57"> 
              <div align="center"><font color="B0266D">数 量</font></div>
            </td>
            <td width="85"> 
              <div align="center"><font color="B0266D">单 价</font></div>
            </td>
			<td width="85"> 
              <div align="center"><font color="B0266D">合 计</font></div>
            </td>
          </tr>

<%
Sum = 0
While Not rsc.EOF

     Quatity = CInt( Request( "Q_" & rsc("ProdId")) )
     If Quatity = 0 Then Quatity = Session(rsc("ProdId"))      '重新进入购物车时，从session中读取商品数量
     If Quatity <= 0 Then Quatity = 1


     Session(rsc("ProdId")) = Quatity
     Sum = Sum + csng(rsc("shop_jg")) * Quatity
     Sum1=FormatNumber(Sum,2) 
     Sum2=FormatNumber(sum*userkk/10,2)     
%> 

          <tr bgcolor="#FFFFFF"> 
            <td width="56" height="20" align="center"> 
              <input type="CheckBox" name="ProdId" value="<%=rsc("ProdId")%>" Checked>
                <input type="hidden" name="subs" value="<%=rsc("shop_Name")%>">          
            </td>
            <td width="283">&nbsp;&nbsp;<%=rsc("shop_name")%></td>
            <td width="57" align="center"> 
              <input name="<%="Q_" & rsc("ProdId")%>" type="Text" class="form" value="<%=Quatity%>" size="4" maxlength="3">
           
            </td>
            <td width="85" align=center><%=FormatNumber(rsc("shop_jg"),2)%></td>
			<td width="85" align=center><font color="B0266D"><%=FormatNumber(csng(rsc("shop_jg"))*Quatity,2)%></font></td>
          </tr>
          <%
     rsc.MoveNext
     Wend
rsc.close
set rsc=nothing
%> 
          <tr bgcolor="#FFFFFF"> 
            <td colspan="2" height="35" align=left valign="middle">             
<font color=red>注意：选择或去除商品、以及修改商品数量后，必须单击“更新商品”才能生效。</font>
            </td>
            <td colspan="3"> 
              <font color="B0266D">
              &nbsp;&nbsp;折前总价  ：<%=Sum1%>  元<br>
              &nbsp;&nbsp;您的折扣  ：
              <%
			  userkk=10 '后来加上去的。
if userkk=10 then
Response.write "无折扣<br>"
else Response.write formatnumber(userkk,2)&" 折<br>"
end if
%>
              &nbsp;&nbsp;折后总价  ：<%=Sum2%>  元<br>
              
              </font>
            </td>
          </tr>
	<tr><td colspan="5" bgcolor="#ffffff" height=40 align=center>

                <input type="submit" name="order" value="更新商品">
                &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="button" name="payment" value="去收银台" onClick="javascript:location.href='payment.asp';"> &nbsp;&nbsp;&nbsp; 
                <input type="button" value="继续购物" language=javascript onClick="javascript:window.close()" name="button">
                <input type="hidden" name="OK" value="ok">
	</td></tr>
        </form>
      </table>       
 </td></tr></table>
</body>
</html>

<%
set conn=nothing
%> 
