<%@page contentType="text/html;charset=GBK"%>
<%@page import="java.sql.*"%>
<%@ include file="/public/checkvalidadmin.jsp"%>
<jsp:useBean id="conn" scope="page" class="test.ConnOracle"/>

<%!
ResultSet rs = null;
String username = "";
String truename = "";
String password = "";
String priv_ok = "";
int priv = 0;
%>

<html>

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

<Body class="ss">
<center>
<%
priv_ok = (String)session.getAttribute("adminpriv");

if(priv_ok!=null && priv_ok.equals("8")) {

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

	<table bgColor="#00acff" border="1" borderColorDark="#ffff00" borderColorLight="#000000" cellSpacing="1" width="80%">
		<tr>
			<th width="20%">用户名</th>
			<th width="16%">真实姓名</th>
			<th width="16%">密码</th>
			<th width="16%">面试权限</th>
			<th width="16%">管理权限</th>
			<th width="16%" colspan=2>操作</th>
		</tr>
		<%do {
			username = rs.getString("loginname");
			truename = rs.getString("truename");
			password = rs.getString("password");
			priv     = rs.getInt("PRIVILEDGE");
		%>
		<tr align="center">
     	<form action="accountchange.jsp" method="post">
			<td><%=username%></td>
			<input type="hidden"   name="username" value="<%=username%>">
            <td><input type="text" name="truename" value="<%=truename%>"></td>
			<td><input type="text" name="password" value="<%=password%>"></td>
			<%
				if(priv == 1) {
			%>
				<td>
					<Input name="priv" type="radio" value="1" checked>
				</td>
				<td>
					<Input name="priv" type="radio" value="8">
				</td>
			<%
				}else if(priv == 8) {
			%>
				<td>
					<Input name="priv" type="radio" value="1">
				</td>
				<td>
					<Input name="priv" type="radio" value="8"  checked>
				</td>
			<%
				}	
			%>
			<td><input type="submit" name="oper" value="修改"></td>
			<td><input type="submit" name="oper" value="删除"></td>
        </form>
		</tr>
		<% } while(rs.next());%>
		<tr>
			<td colspan=7><hr color="white"></td>		
		</tr>
		<form action="accountadd.jsp">
		<tr align="center">
			<td><input type="text" name="username"></td>
			<td><input type="text" name="truename"></td>
			<td><input type="text" name="password"></td>
			<td><input type="radio" name="priv" value="1" checked></td>
			<td><input type="radio" name="priv" value="8"></td>
			<td colspan="2">
				<Input type="submit" value="添加">
			</td>
		</tr>
		</form>
		</table>
<%
	}	
} else {
	out.println("对不起，您的权限不足！<br>");
	out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
}
%>
</form>
</center>
</Body>

</html>