<%
public newname

sub upjob
   rs("money")=rs("money")-100
   rs("userlife")=rs("userlife")-10
   rs.update
   rs1.close

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

   sql1="select * from [job] where username='"&Request.Cookies("username")&"'"
   rs1.Open sql1,Conn1,1,3
   rs1("workname")=newname
   rs1("num")=newnum
   rs1.update
   rs1.close
   succeed("恭喜，你已经成功的升级为---"&newname&"---！<meta http-equiv=refresh content=3;url='work.asp'>")
end sub

sub getnewname(newnum)
  select case newnum
     case "1"
	newname=rs1("one")
     case "2"
	newname=rs1("two")
     case "3"
	newname=rs1("three")
     case "4"
	newname=rs1("four")
     case "5"
	newname=rs1("five")
   end select
end sub

jobtype=request.querystring("worktype")
uptype=request.form("uptype")

if rs("money")<100 or rs("userlife")<20 then
error("你的身体太虚弱了！！快去看医生！")
end if

if jobtype="" then
  error("出错了！！！")
end if

select case uptype
  case ""
	error("请选择申请的级别！")
  case "1"
	jobnum=1
	newnum=1
  case "2"
	jobnum=3
	newnum=2
  case "3"
	jobnum=5
	newnum=3
  case "4"
	jobnum=7
	newnum=4
  case "5"
	jobnum=9
	newnum=5
end select

exx=800*jobnum
lov=300*jobnum
wen=200*jobnum
yi=200*jobnum
jiao=200*jobnum
ti=200*jobnum
ji=200*jobnum

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

if rs1("num")=newnum then
   error("你现在已经是这个级别了！")
else
   if rs1("num")>newnum then
      error("你现在的级别高于这个级别了！")
   end if
end if

if rs1("exp")>=exx and rs1("lover")>=lov and rs1("wenxue")>=wen and rs1("yishu")>=yi and rs1("jiaoji")>=jiao and rs1("tiyu")>=ti and rs1("jishu")>=ji then

select case jobtype

case "教师"

if rs1("wenxue")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

case "作家"
if rs1("wenxue")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

case "画家"
if rs1("yishu")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

case "歌手"
if rs1("yishu")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

case "记者"
if rs1("jiaoji")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

case "商人"
if rs1("jiaoji")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

case "警察"
if rs1("tiyu")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

case "体育"
if rs1("tiyu")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

case "医护"
if rs1("jishu")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

case "科技"
if rs1("jishu")>=300*jobnum then
   call upjob
else
   error("你的属性不够！！")
end if

end select

else
   error("你的属性不够！！")
end if

%>