<!--#include file="../Inc.asp"-->
<!--#include file="../ydzq.asp"-->
<!--#include file="admin.asp"-->
<!--#include file="conn.asp"-->

<%Call head()
Call saycardd("出售")

  
TP=request("TP")
lx=request("lx")
action=request("action")
num=request.form("num")

Select Case action
	Case "get"   
		Call xxget()
	Case ""
		Call xxdel()
end select 

sub xxget()
response.write "欢迎您"&myni&"(ID："&myid&")<br/>"
if num="" then
  Call Error("选择数量无效！")
  end if



set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from sd where id="&lx,connnong,1,1
If Not rs.eof Then
upnongjb=rs("jiage")-rs("jiage")*salekjb
connnong.execute("update cangku set shuliang=shuliang-"&num&" where usid="&myid&" and lx="&lx)
response.write "恭喜您出售"&num&"个"
response.write nonglx(lx)
response.write "成功！增加"&upnongjb&getcent&"<br/>"

if myid<>0 then
mz="[url=/bbs/nongchang/?userid="&myid&"&amp;saytk=[saytk]&amp;sid=[sid]]"&myni&"[/url]"
else
mz="游客"&Replace(time(),":","")&""
end If
connnong.execute("insert into nongdt(shijian,dz,fid,tid,ids) values('"&now&"','"&mz&"成功出售"&num&"个','"&userid&"','"&myid&"','"&lx&"')")

else
 response.write "出售失败！没有这类型的物种!<br/>"
end if
rs.close
set rs=Nothing
connnong.close
set connnong=Nothing

conn.execute("update users set myjb=myjb+"&upnongjb&" where id="&myid)

End Sub






Sub xxdel()

response.write "欢迎您"&myni&"(ID："&myid&")<br/>"
set rs1=Server.CreateObject("ADODB.Recordset")
rs1.open"select * from cangku where usid="&myid&" and lx="&lx,connnong,1,1
nongnumlx=rs1("shuliang")
rs1.close
set rs1=Nothing

Response.write "你共有"&nongnumlx&"个"
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from sd where id="&lx,connnong,1,1
Response.write ubb(rs("name")) & " 出售单价:"
Response.write rs("jiage")-rs("jiage")*salekjb
Response.write getcent

rs.close
set rs=Nothing

If saytk>1 Then Response.Write "<form name=""form"" method=""post"" action=""sale.asp?action=get&amp;id="&id&"&amp;sid="&sid&"&amp;saytk="&saytk&""">"
Response.Write "<br/>数量<br/>"
Response.Write "<input name=""num"" maxlength=""18"" value=""10""/><br/>"
If saytk>1 Then 
response.write "<input type=""hidden"" name=""userid"" value="""&userid&"""/>"
response.write "<input type=""hidden"" name=""TP"" value=""1""/>"
response.write "<input type=""hidden"" name=""lx"" value="""&lx&"""/>"
response.write "<input type=""submit"" name=""Submit"" value=""确定出售""></form><br/>"
Else
Response.write "<anchor>确定出售<go href='sale.asp?action=get&amp;id="&id&"&amp;sid="&sid&"&amp;saytk="&saytk&"' method='post' accept-charset='utf-8'>"
Response.write "<postfield name='num' value='$(num)'/>"
Response.write "<postfield name='userid' value='"&userid&"'/>"
Response.write "<postfield name='TP' value='1'/>"
Response.write "<postfield name='lx' value='"&lx&"'/>"
Response.write "</go></anchor><br/>"
End If

connnong.close
set connnong=Nothing
end Sub


Response.write "------------<br/>"
Response.write "<a href='cangku.asp?sid="&sid&"&amp;saytk="&saytk&"'>返回上级</a><br/>"
Response.write "<a href='index.asp?sid="&sid&"&amp;saytk="&saytk&"'>返回我的农场</a><br/>"&chr(13)

conn.close
set conn=Nothing
%>
<!--#include file="../../fanhui.asp"-->
<%Call head1()%>