📄 buysheep.asp
字号:
<!--#include file="../inc/conn2.asp"-->
<%
if Request.Cookies("NC")="" or Request.Cookies("NC")="访客" then
Response.Write("对不起,您不是社区用户,请先注册!")
Response.End
end if%>
<%
'=====================================================
'转换日期型或字符日期型为全格式如:2000-01-01
'调用:ccdate(日期变量或日期格式字符串)
function ccdate(sdate)
temp=cdate(sdate)
if len(month(temp))=1 then
m="0"&month(temp)
else
m=month(temp)
end if
if len(day(temp))=1 then
d="0"&day(temp)
else
d=day(temp)
end if
ccdate=year(temp)&"-"&m&"-"&d
end function
'=====================================================
'=====================================================
'转换时间字符串为全格式,如:01:01:01
'调用:cctime(字符串)
function cctime (stime)
if len(hour(stime))=1 then
h="0"&hour(stime)
else
h=hour(stime)
end if
if len(minute(stime))=1 then
m="0"&minute(stime)
else
m=minute(stime)
end if
if len(second(stime))=1 then
s="0"&second(stime)
else
s=second(stime)
end if
cctime=h&":"&m&":"&s
end function
'=====================================================
sheepname=request.form("sheepname")
sheepface=request.form("r1")
if sheepname="" or len(sheepname)>16 then
conn.close
set conn=nothing%>
<script language=vbscript>
MsgBox "抱歉,名字输入错误!"
history.back
</script>
<%else
sql="select * from HY where NC='"&Request.Cookies("NC")&"'"
set rs=conn.Execute(sql)
userwealth=rs("JQ")
if userwealth<1000 then
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script language="vbscript">
msgbox"您没有足够的钱!",0,"flush"
history.back
</script>
<%else
rs.close
set rs=nothing
sql="select * from [sheep] where NC='"&Request.Cookies("NC")&"'"
set rs=conn.Execute(sql)
if not rs.eof then
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script language="vbscript">
msgbox"一个人只能领养一只宠物",0,"flush"
history.back
</script>
<%
else
rs.close
set rs=nothing
sql="select * from [sheep]"
set rs=conn.Execute(sql)
if rs.recordcount>1000 then
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script language="vbscript">
msgbox"城市里面的宠物已经超过了1000只,你不能再领养",0,"flush"
history.back
</script>
<%
else
sql="select * from [sheep] where sheepname='"&sheepname&"'"
set rs=conn.Execute(sql)
if not rs.eof then
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script language="vbscript">
msgbox"宠物的昵称已有人使用,请选择其他名字。",0,"flush"
history.back
</script>
<%
else
rs.close
set rs=nothing
sql="select * from [rules]"
set rs=conn.Execute(sql)
cleaninit=rs("cleaninit")
sheephappyinit=rs("happyinit")
sheephealthinit=rs("healthinit")
milkinit=rs("milkinit")
lifeinit=rs("lifeinit")
hungryinit=rs("hungryinit")
sheepdate=date
feeddate=DATEADD("d",-1,DATE)
workload=0
rs.close
set rs=nothing
conn.execute"insert into [sheep](sheephappy,sheephealth,NC,sheepname,sheepdate,life,milk,hungry,workload,clean,feeddate,feedsheepday,logintoday,sheepface) values('"&sheephappyinit&"','"&sheephealthinit&"','"&Request.Cookies("NC")&"','"&sheepname&"','"&sheepdate&"','"&lifeinit&"','"&milkinit&"','"&hungryinit&"','"&workload&"','"&cleaninit&"','"&feeddate&"','0','"&feeddate&"','"&sheepface&"')"
conn.execute"update [sheep] set NC='"&Request.Cookies("NC")&"' where sheepname='"&sheepname&"'"
conn.execute"update HY set JQ=JQ-1000 where NC='"&Request.Cookies("NC")&"'"
conn.close
set conn=nothing%>
<script language=vbscript>
MsgBox "恭喜!您已经成功领养了<%=sheepname%>"
history.back
</script>
<%
end if
end if
end if
end if
end if
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -