<%@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 classid   = "";
String classname = "";
String totaltime    = "";
String totalques    = "";
String totalpaper   = "";

String oper = "";
String sql = "";

int result = 0;
%>

<html>

<head>
	<title>班级信息管理</title>
	<link rel="stylesheet" href="../public/style.css">
</head>

<Body class="ss">
<center>

<%
request.setCharacterEncoding("GBK");

classid   = request.getParameter("classid");
classname = request.getParameter("classname");
totaltime = request.getParameter("totaltime");
totalques = request.getParameter("totalques");
totalpaper= request.getParameter("totalpaper");

oper     = request.getParameter("oper");

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

try{
	rs = conn.executeQuery("select * from test_classinfo where classid='"+classid+"'");
	if(!rs.next()) {
		out.println("<center>");
		out.println("数据库没有代号为" + classid + "的班级信息！<br>");
		out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
		out.println("</center>");
	} else {
		if(oper.equals("修改")) {
			sql = "update test_classinfo set classname='" + classname + "'" ;
			sql+= ",totaltime=" + totaltime;
			sql+= ",totalques=" + totalques;
			sql+= ",totalpaper=" + totalpaper;
			sql+= " where classid='" + classid + "'";
        } else if(oper.equals("删除")){
		    sql = "delete from test_classinfo ";
			sql+= "where classid='" + classid + "'";
		}
		result = 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="classmanager.jsp"/>
</center>
</Body>

</htm