<%@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"/>
<%!
String classid;
String paperid;
ResultSet rs = null;

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

<%
classid = request.getParameter("classid");
paperid = request.getParameter("paperid");

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

try{
	sql = "delete from test_paper_lib ";
	sql+= " where paper_id=" + paperid;
	result = conn.executeUpdate( sql );

	if(result == 0 ) {
		out.println("<center>");
		out.println("试卷信息删除失败！<br><br>");
		out.println("请将下列信息告知管理员<br><br>");
		out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
		out.println("</center>");
	}

    // 更新班级信息表中某个班级的试卷数目
	sql = "update test_classinfo set totalpaper=totalpaper-1";
	sql+= " where classid='" + classid + "'";
	conn.executeUpdate( sql );
}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>");
}
%>
<jsp:forward page="paperview.jsp">
   <jsp:param name="classid" value="<%=classid%>"/>
   <jsp:param name="operflag" value="1"/>
</jsp:forward>
</center>
</Body>

</html>