<!--#include file="conn.asp"-->
<%dim goods,action,deliveryid
action=FormatSQL(SafeRequest("action",0))
goods=SafeRequest("dan",1)
deliveryid=SafeRequest("id",1)
select case action
case "save"
if request.form("state")<>"" then
set rs=server.CreateObject("adodb.recordset")
rs.Open "select state from orders where goods='"&goods&"'",conn,1,3
do while not rs.EOF
rs("state")=request.form("state")
rs.Update
rs.MoveNext
loop
rs.Close
set rs=nothing
conn.close
set conn = nothing
end if
response.Write "<script language=javascript>alert('订单状态修改成功！');history.go(-1);</script>"

case "del"
set rs=server.CreateObject("adodb.recordset")
rs.open "select orders.id,orders.username,orders.productnum,orders.goods,product.id,product.solded,product.stock from orders inner join product on orders.id=product.id where orders.goods='"&goods&"' " ,conn,1,3
if strUserName<>trim(rs("username")) then
response.Write "您无权删除此订单!"
rs.Close
set rs=nothing
conn.close
set conn = nothing
response.End
end if
do while not rs.eof
rs("solded")=rs("solded")-rs("productnum")
rs("stock")=rs("stock")+rs("productnum")
rs.update
rs.movenext
loop
conn.execute "delete from orders where goods='"&goods&"' "
response.Write "<script language=javascript>alert('订单删除成功！');window.close();</script>"
rs.close
set rs=nothing
conn.close
set conn=nothing
end select

%>
