<!--#include file="../inc.asp"-->
<!--#include file="../ydzq.asp"-->
<!--#include file="admin.asp"-->
<!--#include file="conn.asp"-->
<%Call head()
Call saycardd("开垦")
dim TP,ids,Action


'检查ID是否存在
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT id FROM users where id="&myid,conn,1,1
if rs.eof then
  rs.close
  set rs=Nothing
  Call Error("ID不存在！")
end If

 dim nongnum1
    nongnum1=connnong.execute("Select count(ID) from [farm] where usid="&myid&"")(0)
	If nongnum1>=6 Then Call Error("最多只能开垦6块土地")
kaikejb=request("kaikejb")
If kaikejb="" Then
response.write "开垦一块土地需要"&kaikejbb&getcent&",你是否拥有足够的"&getcent&""
Response.write "<br/><a href='kaiken.asp?kaikejb=1&amp;sid="&sid&"&amp;saytk="&saytk&"'>确定</a>|<a href='index.asp?sid="&sid&"&amp;saytk="&saytk&"'>取消</a><br/>"&chr(13)
Else

if myjb<CLng(kaikejbb) then
response.write ""&getcent&"不足"&kaikejbb&"无法开垦!"
else
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from farm where usid="&myid&"",connnong,1,2
rs.addnew
rs("usid")=myid
rs.update
rs.close
set rs=nothing


'set rs=Server.CreateObject("ADODB.Recordset")
'rs.open"select * from guest",conn,1,2
'rs.addnew
'rs("fnr")="您在农场开垦了一块土地，花费了"&vipjb*10&getcent&""
'rs("sid")=myid
'rs("fid")=0
'rs.update
rs.close
set rs=nothing
 Response.Write "成功地开垦了一块土地！"
conn.execute("update users set myjb=myjb-"&CLng(kaikejbb)&" where id="&myid)

If not(connnong.execute("select userid from farm_user where userid="&myid).eof) Then
connnong.execute("update farm_user set fid=fid+1 where userid="&myid)
Else
connnong.execute("insert into farm_user(userid,logintime,fid) values('"&myid&"','"&now&"','1')")
End if



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,tid) values('"&now&"','"&mz&"成功地开垦了一块土地!','"&myid&"')")
end If

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

connnong.close
set connnong=nothing%>
<%Call head1()%>