<!--#include file="conn.asp"-->
<!--#include file="conntest.asp"-->
<!-- #include file="inc/const.asp" -->
<!-- #include file="chkuser.asp" -->
<!--#include file=inc/theme.asp -->
<!--#include file="inc/char.asp"-->
<%dim alb,ars,atitle,akey1,akey2,akey3,akey4,aok,aup
if membername="" then
response.write "<script>location.href='login.asp'</script>"
else
stats="知识问答"
call nav()
call headline(1)

if request("ac")="addxz" then
alb=request("clsid")
atitle=request("title")
akey1=request("ans1")
akey2=request("ans2")
akey3=request("ans3")
akey4=request("ans4")
aok=request("clevel")

set ars=server.createobject("adodb.recordset")
sql="select title from [test] where title like'"&atitle&"'"
ars.open sql,aconn,1,1

if ars.eof then
set ars=server.createobject("adodb.recordset")
sql="select lb,title,key1,key2,key3,key4,ok,username,tx from [testtemp]"
ars.open sql,aconn,1,3

	ars.addnew
	ars(0)=alb
	ars(1)=atitle
	ars(2)=akey1
	ars(3)=akey2
    ars(4)=akey3
    ars(5)=akey4
    ars(6)=aok
    ars(7)=membername
    ars(8)=0
	ars.update
	ars.close
set ars=server.createobject("adodb.recordset")
sql="select userup from [testuser] where username='"&membername&"'"
ars.open sql,aconn,1,1
aup=ars(0)
aconn.execute ("update testuser set userup='"&aup+1&"' where username='"&membername&"'")
ars.close
response.write "<script>alert('已将本题正常录入试题临时库，请等待管理员审核！')</script>"
response.write "<script>location.href='addtest.asp'</script>"
else
ars.close
response.write "<script>alert('你录入的题目原题库已存在，请重新录入新题目！')</script>"
response.write "<script>location.href='addtest.asp'</script>"

end if

else
alb=request("clsid")
atitle=request("title")
akey1=request("ans1")

set ars=server.createobject("adodb.recordset")
sql="select title from [test] where title like'"&atitle&"'"
ars.open sql,aconn,1,1

if ars.eof then
set ars=server.createobject("adodb.recordset")
sql="select lb,title,key1,username,tx from [testtemp]"
ars.open sql,aconn,1,3

	ars.addnew
	ars(0)=alb
	ars(1)=atitle
	ars(2)=akey1
    ars(3)=membername
    ars(4)=1
	ars.update
	ars.close
set ars=server.createobject("adodb.recordset")
sql="select userup from [testuser] where username='"&membername&"'"
ars.open sql,aconn,1,1
aup=ars(0)
aconn.execute ("update testuser set userup='"&aup+1&"' where username='"&membername&"'")
ars.close

response.write "<script>alert('已将本题正常录入试题临时库，请等待管理员审核！')</script>"
response.write "<script>location.href='addtest.asp?action=addtk'</script>"
else
ars.close
response.write "<script>alert('你录入的题目原题库已存在，请重新录入新题目！')</script>"
response.write "<script>location.href='addtest.asp?action=addtk'</script>"

end if
end if

end if%>