<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%dim goods,action,username
action=FormatSQL(SafeRequest("action",0))
goods=SafeRequest("paygoods",1)
username=SafeRequest("username",0)
select case action
case "pay"


set rs=server.CreateObject("adodb.recordset")
rs.open "select orders.id,orders.goods,orders.productnum,orders.state,product.id,product.solded,product.stock from orders inner join product on orders.id=product.id where orders.goods='"&goods&"' " ,conn,1,3
do while not rs.EOF
rs("solded")=rs("solded")+rs("productnum")
rs("stock")=rs("stock")-rs("productnum")
rs.Update
rs.MoveNext
loop
rs.Close


set rs=server.CreateObject("adodb.recordset")
rs.open "select state from orders  where orders.goods='"&goods&"' " ,conn,1,3
do while not rs.EOF
rs("state")=3
rs.Update
rs.MoveNext
loop
rs.Close
set rs=nothing

set rspay=server.CreateObject("adodb.recordset")
rspay.Open "select Deposit,score from dv_user where username='"&username&"'",conn,1,3
rspay("Deposit") =rspay("Deposit")-request.form("paysum")
rspay("score") =rspay("score")+request.form("paysums")  
rspay.Update
rspay.Close
set rspay=nothing
conn.close
set conn = nothing

response.Write "<script language=javascript>alert('支付款已经从预付款中扣除了！');window.close();</script>"
case ""
end select

%>