<!--#include file="conn.asp"-->
<!--#include file="config.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><%=webname%>--您的购物车</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Robots" content="index,follow">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<%
ProductList = Session("ProductList")
Products = Split(Request("Prodid"), ",")
For I=0 To UBound(Products)
   PutToShopBag Products(I), ProductList
Next
Session("ProductList") = ProductList

if request("payment")="去收银台" then
response.redirect "payment.asp?action=1"
end if

If Request("cmdShow") = "Yes" Then
   ProductList = ""
   Products = Split(Request("ProdId"), ", ")
   For I=0 To UBound(Products)
      PutToShopBag Products(I), ProductList
   Next
   Session("ProductList") = ProductList
End If
If Len(Session("ProductList")) = 0 Then
Response.write "<table  height=100% width=100%  ><tr><td align=center>您的购物车为空，<a href=index.asp><b>继续购物</b></a>&nbsp;<a href=""JavaScript:onClick=window.close();""><B>关闭窗口</B></a></td></tr></table>"
Response.end
end if
%>
<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> 
    <td><br>&nbsp;&nbsp;<font color="#FF3333"><b>以下是您购物车中的商品信息，请核对，非注册用户请牢记你的订单号以便日后查询！<br> &nbsp; </b></font></td>
 </tr>
<%
Set rsCheck=Server.CreateObject("ADODB.RecordSet") 
strsql="select ID,Name,Score,Price1,Price2," & LstPrice & ",amount,VipPrice,Stock from Product where ID in ("&Session("ProductList")&") order by ID"
rsCheck.open strsql,conn,1,1
%>
<tr> <td>
<form action="check.asp" method="POST" name="check">
        <table border="0" cellspacing="1" cellpadding="4" align="center" width="100％" bgcolor="#227776">
          <tr bgcolor="#FFFFFF" height="25" align="center"> 
            <td width="40">编 号</td>
            <td width="300">商 品 名 称</td>
            <td width="40">数量</td>
			 <td width="40">积分</td>
			 <td width="60">市场价</td>
			 <td width="60">会员价</td>
			 <td width="40">邮费</td>
            <td width="60">成交价</td>
			<td width="70">总 计</td>
          </tr>
<%
Sum = 0
SumS = 0
Quatity = 1
Do While Not rsCheck.EOF
     Quatity = CInt( Request.Form( "Q_" & rsCheck("ID")) )
     If Quatity <= 0 Then 
        Quatity = CInt( Session(rsCheck("ID")) )
        If Quatity <= 0 Then Quatity = 1
     End If
Session(rsCheck("ID")) = Quatity

IF rsCheck("Stock") < Quatity Then
Quatity = 1
Session(rsCheck("ID")) = 1
response.write "<script language=javascript>alert('对不起，"&rsCheck("Name")&"暂时库存不足，请过段时间再来购买该商品！');window.close();</script>" 
Response.End()
Conn.Close
Set Conn = Nothing
End IF

Dim YourPrice,strprice2,strvipprice,ProScore
strprice1 = Round(rsCheck("Price1"),2)
strprice2 = Round(rsCheck("Price2"),2)
strvipprice = Round(rsCheck("VipPrice"),2)
ProScore = rsCheck("Score")
YourPrice =  Round(rsCheck("" & LstPrice & ""),2)
Sum = Sum + (YourPrice + strvipprice)*Quatity
Sum=Round(Sum,2) 
SumS = SumS + ProScore*Quatity
%> 
          <tr bgcolor="#FFFFFF" height="25"align="center"> 
            <td><input type="CheckBox" name="ProdId" value="<%=rsCheck("ID")%>" Checked></td>
			 
            <td align="left">&nbsp;<a href="product.asp?ID=<%=rsCheck("ID")%>" target="_blank"><%=rsCheck("Name")%></a></td>
            <td><input type="Text" name="<%="Q_" & rsCheck("ID")%>" value="<%=Quatity%>" size="2" class="form"></td>
			<td><%=ProScore %></td>
			<td><%=strprice1 %></td>
			<td><%=strprice2 %></td>
			<td><%=strvipprice %></td>
			<td><%=YourPrice %></td>
			<td><%=Round((YourPrice + strvipprice)*Quatity,2) %></td>
          </tr>
          <%
     rsCheck.MoveNext
     Loop
rsCheck.close
set rsCheck=nothing
%> 
<tr bgcolor="#FFFFFF"> 
 <td colspan="5" align="center" valign="middle">             
                <input type="submit" name="order" value="更新商品"> &nbsp;&nbsp;&nbsp;
                <input type="submit" name="payment" value="去收银台"> &nbsp;&nbsp;&nbsp; 
                <input type="button" value="继续购物" language=javascript onClick="javascript:window.close()" name="button">
                <input type="hidden" name="cmdShow" value="Yes">
                </td>
<td colspan="4" height="25">
您现在是：<font color="#FF6600"><%= strTitle %></font><br>
价格总计：<font color="#FF6600"><%=Round(Sum,2) %></font>&nbsp;元<br>
获得积分：<font color="#FF6600"><%=SumS %></font>&nbsp;分
            </td>
          </tr>
      </table>
	          </form>
 </td>
</tr>
      </table>
</body>
</html>