<%@page contentType="text/html;charset=GBK"%>
<%@page import="java.sql.*" errorPage="/public/error.jsp"%>
<%@ include file="/public/checkvalidadmin.jsp"%>
<%@ include file="/public/checkvalidadmin8.jsp"%>

<jsp:useBean id="conn" scope="page" class="test.ConnOracle"/>

<%!
ResultSet rs = null;

String questionid;
String selectid;
String classid;
String qname;
String choice1;
String choice2;
String choice3;
String choice4;
String answer;

String sql = "";
int result = 0;
%>

<%
request.setCharacterEncoding("GBK");

selectid = request.getParameter("selectid");
classid = request.getParameter("classid");
qname = request.getParameter("qname");
choice1 = request.getParameter("choice1");
choice2 = request.getParameter("choice2");
choice3 = request.getParameter("choice3");
choice4 = request.getParameter("choice4");
answer = request.getParameter("answer");

// 避免用户直接在浏览器地址栏输入页面地址所产生的Exception
if(qname==null || qname.equals("")) {
    out.println("<center>");
	out.println("请进行合法操作！");
	out.println("</center>");
	return;
}

try{
	sql = "insert into test_question_lib values(test_seq_question.nextval";
    sql+= "," + selectid;
	sql+= ",'" + classid + "'";
	sql+= ",'" + qname + "'";
	sql+= ",'" + choice1 + "'";
	sql+= ",'" + choice2 + "'";
	sql+= ",'" + choice3 + "'";
	sql+= ",'" + choice4 + "'";
	sql+= ",'"  + answer + "')";
	result = conn.executeUpdate( sql );
	if(result !=1 ) {
			out.println("<center>");
			out.println("增加试题信息失败！<br><br>");
			out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
			out.println("</center>");
			return;
	}
}catch(Exception ee) {
	out.println("<center>");
	out.println("增加试题信息失败！<br><br>");
	out.println("请将下列信息告知管理员<br><br>");
	out.println(ee.toString() + "<br><br>");
	out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
	out.println("</center>");
	return;
}
%>
<jsp:forward page="questionmanager.jsp"/>
</center>
</Body>

</html>