<%
jobtype=request.form("selectjob")
if jobtype="" then
  error("请先选择职业！")
end if
if rs("money")<100 then
  error("你的金币不够！")
else
  rs("money")=rs("money")-100
  rs.update
end if

sql1="select * from [jobtype] where worktype='"&jobtype&"'"
rs1.Open sql1,Conn1,1,3
jobname=rs1("first")
rs1.close

sql1="select * from [job] where username='"&Request.Cookies("username")&"'"
rs1.Open sql1,Conn1,1,3

if rs1.eof and rs1.bof then
  rs1.close
  sql2="insert into job(username,workname,worktype) values ('"&Request.Cookies("username")&"','"&jobname&"','"&jobtype&"')"
  conn1.Execute(sql2)
else
  rs1("workname")=jobname
  rs1("worktype")=jobtype
  rs1("num")=0
  rs1.update
  rs1.close
end if

succeed("恭喜你,你已成功转换职业为"&jobtype&",级别为"&jobname&",你的金币减少100！<meta http-equiv=refresh content=3;url='work.asp?jobsel=changejob'>")
%>