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

'添加商品
if GetVariable("action")="add" then
	call AddProduct(GetVariable("spid"),CInt(GetVariable("PtCount")))
end if

'删除商品
if GetVariable("action")="modify" then
	call ModifyProduct(GetVariable("spid"),CInt(GetVariable("PtCount")))
end if

'清空购物车
if GetVariable("action")="clear" then
	call clearProduct()
end if

%>

<HTML>
<HEAD>
<TITLE>Look Shopping Bag</TITLE>
<style>
td {
	font-size: 12px;
	line-height: 18px;
	color: #000000;
	text-decoration: none;
}

</style>
</HEAD>
<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td align="center" valign="top"> 
      <br>
      <form action="" method="post" name="WareList" id="WareList">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td align="center" valign="top"> <table width="90%" border="0" cellpadding="4" bgcolor="#6D8E4D">
                <tr bgcolor="D7EFFD"> 
                  <td height="14" colspan="5" bgcolor="#6D8E4D"><strong><font color="#FFFFFF">My 
                    shopping bag</font></strong><font color="#FFFFFF">(Money unit：$) 
                    </font></td>
                </tr>
                <tr bgcolor="D7EFFD"> 
                  <td height="14" align="center" bgcolor="#E6E4C4">Name </td>
                  <td align="center" bgcolor="#E6E4C4">Price </td>
                  <td align="center" bgcolor="#E6E4C4">Amount</td>
                  <td align="right" bgcolor="#E6E4C4">Total</td>
                  <td align="center" bgcolor="#E6E4C4">Delte</td>
                </tr>
                <SCRIPT language=javascript>
						<!--
							function CheckValue(theValue)
							{
								if (theValue=="")
								{
									alert("Error！\n\nPlease input right number！");
									return false;
								}		
								else if (theValue.indexOf(" ")>=0)
								{
									alert("Error！\n\nPlease input right number！\nCan't include Null！");
									return false;
								}
								else if (isNaN(theValue)) 
								{	
									alert("Error！\n\nPlease input right number！");
									return false;
								}
								else if (theValue.indexOf('.')>=0)
								{
									alert("Error！\n\nPlease input right Integer！")
									return false;
								}
								else if (parseInt(theValue)<=0)
								{
									alert("Error！\n\nPlease input right number！");
									return false;
								}
								return true;
							}
							
							function SetCount(strID,strCount){
								if (CheckValue(strCount)){
									window.location="shopping.asp?action=modify" + "&spid=" + strID + "&PtCount=" + strCount;
								}
							}
							
							function DeleProduct(strID){
								window.location="shopping.asp?action=modify" + "&spid=" + strID + "&PtCount=0";
							}
							
							function clearProduct(){
								window.location="shopping.asp?action=clear";
							}
							
							function buy(){
								var mywin=window.open("order.asp?mnid=<%=GetVariable("mnid")%>","order","");
								mywin.focus();
								window.close();
								
							}
							
						//-->
					  </SCRIPT>
                <%
				'输出商品列表
				ProductList = Session("ProductList")		'商品ID列表
				ProductCount=Session("ProductCount")		'商品数量列表
				Products = Split(ProductList, ",")
				PtCounts = Split(ProductCount, ",")
				
				money=0
				for i=0 to ubound(Products)-1
				
				strSQL="Select * From web_product Where id In (" & Products(i) & ")"
				Rs.open strSQL,conn,1,1
				if rs.recordcount<>0 and PtCounts(i)<>0 then
					dblPrice=Rs("p_price")
					if Session("m_Code")>0 then
						dblPrice=Rs("p_price1")
					End if
%>
                <tr bgcolor="#F6F6F6"> 
                  <td width="33%" height="14" align="center"><%=trim(Rs("p_name"))%></td>
                  <td width="11%" align="center"><%=dblPrice%></td>
                  <td width="34%" align="center"> 
                    <input name="ptCount<%=rs("id")%>" type="text" id="ptCount" size="4" maxlength="4" value="<%=PtCounts(i)%>"> 
                    <input type="button" name="Submit2" value="Change Amount" onClick="SetCount('<%=rs("id")%>',document.WareList.ptCount<%=rs("id")%>.value)"> 
                  </td>
                  <td width="10%" align="right">$
<%
				  
				  xj=dblPrice * Cint(PtCounts(i))
				  money=money+xj
				  response.Write(xj)
				  %></td>
                  <td width="12%" align="center">
				<input type="button" name="Submit" value="Delete" onClick="DeleProduct('<%=rs("id")%>')"></td>
                </tr>
                <%
					end if
					rs.close
				next
				%>
                <tr valign="middle" bgcolor="#E6E4C4"> 
                  <td colspan="5">Total：<font color="#FF0000">$</font><font color="#FF0000"><%=money%></font> </td>
                </tr>
                <tr valign="middle" bgcolor="407BE7"> 
                  <td height="30" colspan="5" align="center" bgcolor="#FFFFFF"> 
                    <input type="button" name="Submit3" value="Clear Shopping bag" onClick="clearProduct()">
                    　 
                    <input type="button" name="Submit32" value=" Refresh " onClick="window.location='shopping.asp'">
                    　 
                    <input type="button" name="Submit4" value="I have select the shopping，Submit！" onClick="buy()"> 
                  </td>
                </tr>
              </table></td>
          </tr>
          <tr> 
            <td align="center" valign="top"><table width="90%" border="0" cellspacing="1" cellpadding="0">
                <tr> 
                  <td height="50" align="center"> 
                    <table width="90%" height="32" border="0" cellpadding="0" cellspacing="0">
                      <tr> 
                        <td width="336" height="16" align="center">未设置<br></td>
                      </tr>
                    </table></td>
                </tr>
              </table></td>
          </tr>
        </table>
      </form> 
      <!----------------新闻首页中间部份结束--------------------------->
    </td>
  </tr>
</table>
</BODY>
</HTML>
 <%
'rs.close
'set rs=nothing
conn.close
set conn=nothing
%>

