<%@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 rs1 = null;
ResultSet rs2 = null;

String username = "";
String password = "";

String priv1 = "";
String priv2 = "";
%>

<html>

<head>
	<title>权限管理</title>
	<link rel="stylesheet" href="../public/style.css">
</head>

<Body class="ss">
<center>

<%
try{
	rs1 = conn.executeQuery("select * from test_admin");
	if(!rs1.next()) {
		out.println("数据库中还没有用户！<br>");
		out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
	} else {
		do {
			username = rs1.getString("username");
			password = rs1.getString("password");

			priv1 = request.getParameter("check1" + username);
			priv2 = request.getParameter("check2" + password);

			if(priv1 == null) {
				// 清空用户所有权限
				conn.executeUpdate("update test_admin set PRIVILEDGE=0 where username='" + username + "'");
			}else if(priv1.equals("ok") && priv2 == null) {
				// 只有面试权限
				conn.executeUpdate("update test_admin set PRIVILEDGE=1 where username='" + username + "'");
			}else if(priv2.equals("ok")) {
				// 具备管理权限权限
				conn.executeUpdate("update test_admin set PRIVILEDGE=8 where username='" + username + "'");
			}

		}while(rs1.next());
	}
}catch(Exception ee) {
	out.println("权限更新失败！<br>");
	out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
	return;
}
response.sendRedirect("privmanager.jsp");
%>

</center>
</Body>

</html>