<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%

webtitle="购物车"
webkeywords="购物车"
webdescription="购物车|"&webname
%> 

<!--#include file="include/header.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
%>

<%
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;</td></tr></table>"
Response.end
end if
%>
<table width="980" border="0" cellspacing="0" cellpadding="0" align="center"  bgcolor="#FFFFFF">
<tr> 
    <td><br>&nbsp;&nbsp;<font color="#484848"><b>以下是您购物车中的商品信息，请核对正确无误后下单，非注册用户请牢记你的订单号以便日后查询！<br> &nbsp; </b></font></td>
 </tr>
<%
Set rsCheck=Server.CreateObject("ADODB.RecordSet") 
strsql="select ID,Name,Score,Price2,amount,VipPrice,Stock from Product where ID in ("&Session("ProductList")&") order by ID"
rsCheck.open strsql,conn,1,1
%>
<tr> <td>

<form action="shopcart.asp" method="POST" name="check">

      <table border="0" cellspacing="1" cellpadding="4" align="center" width="100%" bgcolor="#cccccc">
            <tr  height="25" align="center"   BGCOLOR=#ffffff> 
            <td width="10%" ><FONT COLOR=#333333>选中/清除</font></td>
            <td width="40%"><FONT COLOR=#333333>商 品 名 称</font></td>
            <td width="10%"><FONT COLOR=#333333>数量</font></td>
	    <td width="10%"><FONT COLOR=#333333>积分</font></td>
			 
	    <td width="10%"><FONT COLOR=#333333>平衡费</font></td>
            <td width="10%"><FONT COLOR=#333333>您的价格</font></td>
	    <td width="10%"><FONT COLOR=#333333>总 计</font></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 = rsCheck("Stock")
Session(rsCheck("ID")) = Quatity
response.write "<script language=javascript>alert('对不起，"&rsCheck("Name")&"暂时库存不足，库存只有"&rsCheck("Stock")&"！');location.href='shopcart.asp';</script>" 
End IF



Dim YourPrice,strprice2,strvipprice,ProScore
strprice2 = Round(rsCheck("Price2"),2)
strvipprice = Round(rsCheck("VipPrice"),2)
ProScore = rsCheck("Score")
YourPrice = strprice2
YourPrice1= strprice2*LngDiscount
If rsCheck("amount") = 0 or LngUserID=0 or Lnggrpid = 4 Then
YourPricex = YourPrice
Else
YourPricex = YourPrice1
End If
YourPricex = Round(YourPricex,2) 
Sum = Sum + (YourPricex + 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"><FONT COLOR=#333333><%=rsCheck("Name")%></font></a></td>
            <td><input type="Text" name="<%="Q_" & rsCheck("ID")%>" value="<%=Quatity%>" onchange='javascript:this.form.submit();name="cmdShow"' size="4" class="form"></td>
			<td><FONT COLOR=#333333><%=ProScore %></font></td>
			
			<td><FONT COLOR=#333333><%=strvipprice %></font></td>
			<td><FONT COLOR=#333333><%=YourPricex %></font></td>
			<td><FONT COLOR=#333333><%=Round((YourPricex + strvipprice)*Quatity,2) %></font></td>
          </tr>
          <%
     rsCheck.MoveNext
     Loop
rsCheck.close
set rsCheck=nothing
%> 
<tr BGCOLOR="#ffffff" > 
 <td colspan="4" 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=#333333>您现在是：</font><font color="#333333"><%= strTitle %></font>&nbsp;
<FONT COLOR=#333333>享受折扣：</font><font color="#333333"><% = LngDiscount*100&"%" %></font><br>
<FONT COLOR=#333333>折后总计：</font><font color="#333333"><%=Round(Sum,2) %>&nbsp;元</font><br>
<FONT COLOR=#333333>获得积分：</font><font color="#333333"><%=SumS %>&nbsp;分</font>
            </td>
          </tr>
      </table>
	          </form>
 </td>
</tr>
<tr><td height="100">&nbsp;&nbsp;<FONT COLOR=#484848>温馨提示--清除选购商品的方法:去掉商品名称前的选中钩,然后点更新商品即可!</font></td></tr>
      </table>
<!--#include file="include/footer.asp"-->
</body>
</html>
