<head>
<title>收银台</title>

<STYLE type=text/css>
A:link {COLOR: #000000; FONT-FAMILY: 宋体; TEXT-DECORATION: none}
A:visited {	COLOR: #000000; FONT-FAMILY: 宋体; TEXT-DECORATION: none}
A:active { COLOR: #ff0000; FONT-FAMILY: 宋体; TEXT-DECORATION: none}
A:hover {COLOR: #ff0000; TEXT-DECORATION: none}
body{FONT-SIZE: 9pt}
TH {FONT-SIZE: 9pt}
TD {FONT-SIZE: 9pt}
</STYLE>
<script>
function wop1(url) 
{ 
	var x = (screen.width - 274) / 2 ;
	var y = (screen.height - 320) / 2 ;
	buywin=window.open(url,"home","toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=274,height=260" + ",top="+y+",left="+x);
} 
</script>
</head>
<body bgcolor="#396BA5">
<!--#include file="conn.asp"--> 
<% 
user=cstr(request.form("user")) 
pass=cstr(request.form("pass")) 
user=replace(user,"'","")  
user=replace(user,"""","")  
pass=replace(pass,"'","")  
pass=replace(pass,"""","") 
if len(user) > 20 or len(pass) > 20 then Response.end
set rs = Server.CreateObject("ADODB.Recordset") 
set rs1 = Server.CreateObject("ADODB.Recordset") 
set rs2 = Server.CreateObject("ADODB.Recordset") 
'-----------------------
hjje=0           
sl=0           
set thedict=session("dict")
if thedict.count=0 then  
	Response.End
else
	for each key in thedict
		Rs.open "Select * from Products where id="&key,conn,1
		if rs("Quantity")>=thedict.item(key) then 
			sl=sl+thedict.item(key)           
			hjje=hjje+Rs("Price")*thedict.item(key) 
		end if         
		rs.close                 
		i=i+1                 
	next            
End if
'--------------------------
rs.Open "Select * From userinfo where username='"&user&"'",conn,1,3 
if rs.eof then  
	rs.close 
	%> 
    <script language=vbscript>   
  		MsgBox "错误：该用户不存在或密码错误！"   
  		location.href = "javascript:history.back()"   
	</script>   
<%else 
	if pass<>rs("userpassword") then%> 
	<script language=vbscript>   
  		MsgBox "错误：该用户不存在或密码错误！"   
  		location.href = "javascript:history.back()"   
	</script>   
 
	<%else 
			
		session("userid")=rs("userid") 
		session("username")=rs("username") 
 
		if rs("UserCredit")<hjje then 
			response.redirect("error.asp?id=0")   
		else 
 
		set thedict=session("dict") 
		if thedict.count=0 then   
			response.redirect("error.asp?id=2")   
		end if 
		for each key in thedict      
			Rs1.open "Select * from Products where id="&key,conn,1 
			if rs1("Quantity")<thedict.item(key) or thedict.item(key)<1 then 
				thedict.Remove(key) 
			end if 
			rs1.close 
		next%> 
		 
		 
<div align="center"> 
  <center> 
		 
		 
		<table border="0" width="600" cellspacing="1" height="49" cellpadding="3">                
  <tr>                
    <td width="1200" align="center" bgcolor="#B2B2B2" height="21" colspan="6" style="border-style: ridge; border-width: 1">成  
      交 的 物 品 清 单</td>                 
  </tr>                 
               
  <tr>                 
    <td width="150" align="center" bgcolor="#C6C6C6" height="21">商品名称</td>                 
    <td width="70" align="center" bgcolor="#C6C6C6" height="21">价格</td>                 
    <td width="70" align="center" bgcolor="#C6C6C6" height="21">使用级别</td>                 
    <td width="260" align="center" bgcolor="#C6C6C6" height="21">简介</td>                 
    <td width="50" align="center" bgcolor="#C6C6C6" height="21">数量</td>                 
    <td width="50" align="center" bgcolor="#C6C6C6" height="21">　</td>                 
  </tr>             
		  
		  
		<%hjje=0             
		sl=0    
		for each key in thedict  
		  
			Rs1.open "Select * from Products where id="&key,conn,1  
			  
			sql="Select * from userbox where userid='"&rs("userid")&"'"  
			sql=sql&" and productid='"&rs1("id")&"'"  
			sql=sql&" and ProductName='"&rs1("ProductName")&"'"  
			sql=sql&" and ProductHtml='"&rs1("ProductHtml")&"'"  
			sql=sql&" and Price="&rs1("Price")  
			sql=sql&" and UserLevel="&rs1("ProductLevel")  
			sql=sql&" and type="&rs1("type")  
			Rs2.open sql,conn,1  
			if rs2.eof then  
				sql="insert userbox (userid,productid,ProductName,ProductHtml,Facies,Type,Quantity,Price,UserLevel,Memo)"  
				sql=sql&"values ("&rs("userid")&","&rs1("id")&",'"&rs1("ProductName")&"','"&rs1("Producthtml")&"','"&rs1("Facies")&"',"&rs1("Type")&","&thedict.item(key)&","&rs1("Price")&","&rs1("ProductLevel")&",'"&rs1("Memo")&"')"  
				conn.execute sql  
			else  
				sql="update userbox set Quantity=Quantity+"&thedict.item(key)&" where userid='"&rs("userid")&"'"  
				sql=sql&" and productid='"&rs1("id")&"'"  
				sql=sql&" and ProductName='"&rs1("ProductName")&"'"  
				sql=sql&" and ProductHtml='"&rs1("ProductHtml")&"'"  
				sql=sql&" and Price="&rs1("Price")  
				sql=sql&" and UserLevel="&rs1("ProductLevel")  
				sql=sql&" and type="&rs1("type")  
				conn.execute sql  
			end if	  

			if thedict.item(key)<0 then
					
			response.end
			end if	
 			conn.execute "update Products set Sells=Sells+"&thedict.item(key)&", Quantity=Quantity- "&thedict.item(key)&" where id="&key  
%>  
	 <tr>                 
    <td width="150" align="center" bgcolor="#F5F5F5" height="20">               
      <p align="left"><%=Rs1("ProductName")%></td>                 
  <center>                  
    <td width="70" align="center" bgcolor="#F5F5F5" height="20"><%=Rs1("Price")%></td>                 
    <td width="70" align="center" bgcolor="#F5F5F5" height="20"><%=Rs1("ProductLevel")%></td>                 
  </center>               
    <td width="260" align="center" bgcolor="#F5F5F5" height="20">               
      <p align="left"><%=Rs1("Memo")%></td>                 
  <center>                  
    <td width="50" align="center" bgcolor="#F5F5F5" height="20"><%=thedict.item(key)%></td>                 
    <td width="50" align="center" bgcolor="#F5F5F5" height="20">    
    
    </td>                 
  </tr>                 
  
  
		<%	  
		sl=sl+thedict.item(key)             
		hjje=hjje+Rs1("Price")*thedict.item(key)   
  
			rs2.close  
			rs1.close           
		next  
		sql="update userinfo set UserCredit = UserCredit - "&hjje&" where userid='"&rs("userid")&"'"  
		conn.execute sql  
		thedict.RemoveAll  
		%>  
  
	 <tr>                 
    <td width="150" align="center" bgcolor="#C0C0C0" height="20">               
      合&nbsp;&nbsp;&nbsp; 计</td>                        
    <td width="70" align="center" bgcolor="#C0C0C0" height="20"><%=hjje%>　</td>                      
    <td width="70" align="center" bgcolor="#C0C0C0" height="20">　</td>                      
    <td width="260" align="center" bgcolor="#C0C0C0" height="20">                    
      　</td>                      
    <td width="50" align="center" bgcolor="#C0C0C0" height="20"><%=sl%>　</td>                      
    <td width="50" align="center" bgcolor="#C0C0C0" height="20">　</td>                      
  </tr>                      
	                        
</table>                     
      
      
  </center>      
  </div>      
      
      
</center>      
      
  <div align="center">      
        <table border="0" width="264" cellspacing="10" cellpadding="3">      
          <tr>      
            <td width="84" bgcolor="#D6D6CE" style="border-style: ridge; border-width: 1">      
              <p align="center"><a href="javascript:wop1('home.asp');">我的百宝箱</a></td>    
            <td width="85" bgcolor="#D6D6CE" style="border-style: ridge; border-width: 1">    
              <p align="center"><a href="shop.asp">返回超市</a></td>     
            <td width="85" bgcolor="#D6D6CE" style="border-style: ridge; border-width: 1">    
              <p align="center"><a href="javascript:close();">关闭窗口</a></td>    
          </tr>    
        </table>    
      </div>    
          
<div align="center">   
   
   
<table border="1" width="600" cellspacing="7" height="34" bgcolor="#C0C0C0">   
  <tr>   
    <td width="100%" height="22" bgcolor="#BDD6FF">   
        <p align="left"><font size="2">&nbsp;<b><font color="#FF0000">收银小姐：</font></b>您购的商品已经放入你的百宝箱的物品中，请你查收，谢谢您的光临，再见!</font></p>   
	 
       
        <hr noshade size="1"> 
	 
       
        <p align="left"><font size="2"><b><font color="#FF0000">系统提示：</font></b>购买的商品可以自己使用，也可以送给你的朋友，请进入你自己的百宝箱里的[我的物品]进行操作，谢谢您的使用！</font></p>   
	 
       
    </td>    
  </tr>    
</table>    
    
    
</div>    
    
    
  <center> 
		 
		 
<p></p> 
 
		 
		 
<%		rs.close	    
	end if    
	end if    
end if    
%>