修复无法修改岗位和管理员
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
String name = request.getParameter("adminname");
|
||||
String adminsex = request.getParameter("sex");
|
||||
String adminjob = request.getParameter("job");
|
||||
String oldname = request.getParameter("OldAdminName");
|
||||
%>
|
||||
<%
|
||||
String driver = "com.mysql.jdbc.Driver";
|
||||
@@ -42,11 +43,12 @@
|
||||
try{
|
||||
Connection conn = DriverManager.getConnection(url, use, password);
|
||||
PreparedStatement sql = conn
|
||||
.prepareStatement("update adminstrator_record set AdminNo=?,AdminSex=?,AdminJob=? where AdminName=?");
|
||||
.prepareStatement("update adminstrator_record set AdminNo=?,AdminSex=?,AdminJob=?,AdminName=? where AdminName=?;");
|
||||
sql.setString(1, adminNo);
|
||||
sql.setString(2, adminsex);
|
||||
sql.setString(3, adminjob);
|
||||
sql.setString(4, name);
|
||||
sql.setString(5, oldname);
|
||||
int rtn = sql.executeUpdate();
|
||||
if (rtn != 0) {
|
||||
flag = true;
|
||||
@@ -65,6 +67,11 @@
|
||||
<%
|
||||
} else if (flag == false) {
|
||||
%>
|
||||
<%-- <%=adminNo %>
|
||||
<%=adminsex %>
|
||||
<%=adminjob %>
|
||||
<%=name %>
|
||||
<%=oldname %> --%>
|
||||
<jsp:forward page="insert_fail.jsp" />
|
||||
<%
|
||||
}
|
||||
|
||||
71
WebRoot/JSPhandle/adminjob_update.jsp
Normal file
71
WebRoot/JSPhandle/adminjob_update.jsp
Normal file
@@ -0,0 +1,71 @@
|
||||
<%@ page language="java" import="java.sql.*"
|
||||
contentType="text/html;charset=utf-8"%>
|
||||
<%
|
||||
String path = request.getContextPath();
|
||||
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
|
||||
+ path + "/";
|
||||
%>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<base href="<%=basePath%>">
|
||||
|
||||
<title>检验插入页面</title>
|
||||
<meta http-equiv="pragma" content="no-cache">
|
||||
<meta http-equiv="cache-control" content="no-cache">
|
||||
<meta http-equiv="expires" content="0">
|
||||
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
|
||||
<meta http-equiv="description" content="This is my page">
|
||||
<!--
|
||||
<link rel="stylesheet" type="text/css" href="styles.css">
|
||||
-->
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<br>
|
||||
<%
|
||||
boolean flag = false;
|
||||
request.setCharacterEncoding("utf-8");
|
||||
String Adminjob = request.getParameter("Adminjob");
|
||||
String Adminduty = request.getParameter("jobduty");
|
||||
String oldname = request.getParameter("OldAdminJob");
|
||||
%>
|
||||
<%
|
||||
String driver = "com.mysql.jdbc.Driver";
|
||||
String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8";
|
||||
String use = "root";
|
||||
String password = "";
|
||||
Class.forName(driver);
|
||||
try{
|
||||
Connection conn = DriverManager.getConnection(url, use, password);
|
||||
PreparedStatement sql = conn
|
||||
.prepareStatement("update administrator_job set AdminJob=?,AdminDuty=? where AdminJob=?");
|
||||
sql.setString(1, Adminjob);
|
||||
sql.setString(2, Adminduty);
|
||||
sql.setString(3, oldname);
|
||||
int rtn = sql.executeUpdate();
|
||||
if (rtn != 0) {
|
||||
flag = true;
|
||||
}
|
||||
sql.close();
|
||||
conn.close();
|
||||
}catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
%>
|
||||
<!-- 判断是否是插入成功 -->
|
||||
<%
|
||||
if (flag == true) {
|
||||
%>
|
||||
<jsp:forward page="insert_success.jsp" />
|
||||
<%
|
||||
} else if (flag == false) {
|
||||
%>
|
||||
<jsp:forward page="insert_fail.jsp" />
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</body>
|
||||
</html>
|
||||
88
WebRoot/change_adminjob.jsp
Normal file
88
WebRoot/change_adminjob.jsp
Normal file
@@ -0,0 +1,88 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<%@page import="java.sql.Connection"%>
|
||||
<%@page import="java.sql.*"%>
|
||||
<%@page import="java.sql.DriverManager"%>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>学生管理</title>
|
||||
<link rel="stylesheet" href="css/manage.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/footer.css" type="text/css">
|
||||
<script src="js/ie-emulation-modes-warning.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="/module/top.jsp"%>
|
||||
<%@ include file="/module/limits_check.jsp"%>
|
||||
<div class="container">
|
||||
<%
|
||||
if (session.getAttribute("actualuser") == null) {
|
||||
out.println("<script>alert('登录超时 (1440 秒未活动)或未登录,请重新登录。');window.location.href='index.html';</script>");
|
||||
return;
|
||||
}
|
||||
Object actualuser = session.getAttribute("actualuser");
|
||||
%>
|
||||
<div class="row">
|
||||
<%@ include file="module/sidebar.jsp"%>
|
||||
<div class="col-lg-1 col-md-1 hidden-xs"></div>
|
||||
<h3 class="text-center">修改岗位</h3>
|
||||
<div class="col-sm-12 col-lg-9 col-md-9">
|
||||
<form class="form-horizontal" role="form" id="edit_adminjob"
|
||||
name="edit_adminjob" action="edit_adminjob.jsp" method="post">
|
||||
<div class="form-group">
|
||||
<label for="inputText1" class="col-sm-2 control-label">要修改的岗位名</label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="AdminJob">
|
||||
<%
|
||||
String driverClass = "com.mysql.jdbc.Driver";
|
||||
String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8";
|
||||
String user = "root";
|
||||
String password = "";
|
||||
Class.forName(driverClass);
|
||||
try {
|
||||
ResultSet rs = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement sql = null;
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
Statement stmt = conn.createStatement();
|
||||
sql = conn.prepareStatement("select * from administrator_job");
|
||||
rs = sql.executeQuery();
|
||||
while (rs.next()) {
|
||||
%>
|
||||
<option value="<%=rs.getString("AdminJob")%>"><%=rs.getString("AdminJob")%></option>
|
||||
<%
|
||||
}
|
||||
sql.close();
|
||||
rs.close();
|
||||
conn.close();
|
||||
stmt.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
%>
|
||||
<%
|
||||
|
||||
%>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-primary pull-right">选择</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Footer -->
|
||||
<%@ include file="module/footer.jsp"%>
|
||||
<!-- //Footer -->
|
||||
</div>
|
||||
<script src="js/jquery-1.11.2.min.js" type="text/javascript"></script>
|
||||
<script src="js/bootstrap.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -45,53 +45,66 @@
|
||||
<div class="col-lg-1 col-md-1 hidden-xs"></div>
|
||||
<h3 class="text-center">修改管理员</h3>
|
||||
<div class="col-sm-12 col-lg-9 col-md-9">
|
||||
<%
|
||||
try {
|
||||
ResultSet rs = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement sql = null;
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
Statement stmt = conn.createStatement();
|
||||
sql = conn.prepareStatement("select * from adminstrator_record where AdminName=?");
|
||||
sql.setString(1, adminName);
|
||||
rs = sql.executeQuery();
|
||||
while (rs.next()) {
|
||||
%>
|
||||
<%
|
||||
try {
|
||||
ResultSet rs = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement sql = null;
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
Statement stmt = conn.createStatement();
|
||||
sql = conn.prepareStatement("select * from adminstrator_record where AdminName=?");
|
||||
sql.setString(1, adminName);
|
||||
rs = sql.executeQuery();
|
||||
while (rs.next()) {
|
||||
%>
|
||||
<form class="form-horizontal" role="form" id="add_admin"
|
||||
name="add_admin" action="JSPhandle/admin_update.jsp" method="post">
|
||||
<div class="form-group">
|
||||
<label for="disabledTextInput" class="col-sm-2 control-label">原管理员名</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="<%=rs.getString("AdminName")%>" name="OldAdminName"
|
||||
id="disabledTextInput" value="<%=rs.getString("AdminName")%>"
|
||||
readonly>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputText1" class="col-sm-2 control-label">管理员号</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="<%=rs.getString("AdminNo")%>" name="adminno" value='<%=rs.getString("AdminNo")%>'>
|
||||
placeholder="<%=rs.getString("AdminNo")%>" name="adminno"
|
||||
value='<%=rs.getString("AdminNo")%>'>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputText2" class="col-sm-2 control-label" value="">管理员姓名</label>
|
||||
<div class="col-sm-10">
|
||||
|
||||
|
||||
<input type="text" class="form-control"
|
||||
placeholder='<%=rs.getString("AdminName")%>' name="adminname" value='<%=rs.getString("AdminName")%>'>
|
||||
|
||||
placeholder='<%=rs.getString("AdminName")%>' name="adminname"
|
||||
value='<%=rs.getString("AdminName")%>'>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputText3" class="col-sm-2 control-label">管理员性别</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="<%=rs.getString("AdminSex")%>" name="sex" value='<%=rs.getString("AdminSex")%>'>
|
||||
placeholder="<%=rs.getString("AdminSex")%>" name="sex"
|
||||
value='<%=rs.getString("AdminSex")%>'>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
sql.close();
|
||||
rs.close();
|
||||
conn.close();
|
||||
stmt.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
%>
|
||||
}
|
||||
sql.close();
|
||||
rs.close();
|
||||
conn.close();
|
||||
stmt.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
%>
|
||||
<div class="form-group">
|
||||
<label for="inputText1" class="col-sm-2 control-label">管理员角色</label>
|
||||
<div class="col-sm-10">
|
||||
@@ -99,8 +112,8 @@
|
||||
<%
|
||||
try {
|
||||
ResultSet rs = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement sql = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement sql = null;
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
Statement stmt = conn.createStatement();
|
||||
sql = conn.prepareStatement("select * from administrator_job");
|
||||
@@ -110,10 +123,10 @@
|
||||
<option value="<%=rs.getString("AdminJob")%>"><%=rs.getString("AdminJob")%></option>
|
||||
<%
|
||||
}
|
||||
sql.close();
|
||||
rs.close();
|
||||
conn.close();
|
||||
stmt.close();
|
||||
sql.close();
|
||||
rs.close();
|
||||
conn.close();
|
||||
stmt.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
117
WebRoot/edit_adminjob.jsp
Normal file
117
WebRoot/edit_adminjob.jsp
Normal file
@@ -0,0 +1,117 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<%@page import="java.sql.Connection"%>
|
||||
<%@page import="java.sql.*"%>
|
||||
<%@page import="java.sql.DriverManager"%>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>学生管理</title>
|
||||
<link rel="stylesheet" href="css/manage.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/footer.css" type="text/css">
|
||||
<script src="js/ie-emulation-modes-warning.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="/module/top.jsp"%>
|
||||
<%@ include file="/module/limits_check.jsp"%>
|
||||
<div class="container">
|
||||
<%
|
||||
boolean flag = false;
|
||||
request.setCharacterEncoding("utf-8");
|
||||
String AdminJob = request.getParameter("AdminJob");
|
||||
%>
|
||||
<%
|
||||
if (session.getAttribute("actualuser") == null) {
|
||||
out.println("<script>alert('登录超时 (1440 秒未活动)或未登录,请重新登录。');window.location.href='index.html';</script>");
|
||||
return;
|
||||
}
|
||||
Object actualuser = session.getAttribute("actualuser");
|
||||
String driverClass = "com.mysql.jdbc.Driver";
|
||||
String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8";
|
||||
String user = "root";
|
||||
String password = "";
|
||||
Class.forName(driverClass);
|
||||
%>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<%@ include file="module/sidebar.jsp"%>
|
||||
<div class="col-lg-1 col-md-1 hidden-xs"></div>
|
||||
<h3 class="text-center">修改岗位</h3>
|
||||
<div class="col-sm-12 col-lg-9 col-md-9">
|
||||
<%
|
||||
try {
|
||||
ResultSet rs = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement sql = null;
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
Statement stmt = conn.createStatement();
|
||||
sql = conn.prepareStatement("select * from administrator_job where AdminJob=?");
|
||||
sql.setString(1, AdminJob);
|
||||
rs = sql.executeQuery();
|
||||
while (rs.next()) {
|
||||
%>
|
||||
<form class="form-horizontal" role="form" id="add_admin"
|
||||
name="add_admin" action="JSPhandle/adminjob_update.jsp"
|
||||
method="post">
|
||||
<div class="form-group">
|
||||
<label for="disabledTextInput" class="col-sm-2 control-label">原岗位名称</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="<%=rs.getString("AdminJob")%>" name="OldAdminJob"
|
||||
id="disabledTextInput" value="<%=rs.getString("AdminJob")%>"
|
||||
readonly>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputText1" class="col-sm-2 control-label">岗位名称</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="<%=rs.getString("AdminJob")%>" name="Adminjob"
|
||||
value='<%=rs.getString("AdminJob")%>'>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputText2" class="col-sm-2 control-label" value="">岗位职责</label>
|
||||
<div class="col-sm-10">
|
||||
|
||||
|
||||
<textarea for="jobduty" class="form-control col-sm-2" rows="3"
|
||||
placeholder="<%=rs.getString("AdminDuty")%>" id="jobduty"
|
||||
name="jobduty"><%=rs.getString("AdminDuty")%></textarea>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
sql.close();
|
||||
rs.close();
|
||||
conn.close();
|
||||
stmt.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
%>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-danger pull-right">修改</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Footer -->
|
||||
<%@ include file="module/footer.jsp"%>
|
||||
<!-- //Footer -->
|
||||
</div>
|
||||
<script src="js/jquery-1.11.2.min.js" type="text/javascript"></script>
|
||||
<script src="js/bootstrap.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -47,10 +47,10 @@
|
||||
<div class="col-sm-12 col-lg-9 col-md-9">
|
||||
<%
|
||||
try {
|
||||
ResultSet rs = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement sql = null;
|
||||
|
||||
ResultSet rs = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement sql = null;
|
||||
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
Statement stmt = conn.createStatement();
|
||||
sql = conn.prepareStatement("select userName,Email, VIP,Administrator from show_user where userName=?");
|
||||
@@ -75,7 +75,8 @@
|
||||
<div class="col-sm-10">
|
||||
|
||||
<input type="text" class="form-control"
|
||||
placeholder='<%=rs.getString("userName")%>' name="userName" value='<%=rs.getString("userName")%>'>
|
||||
placeholder='<%=rs.getString("userName")%>' name="userName"
|
||||
value='<%=rs.getString("userName")%>'>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -83,7 +84,8 @@
|
||||
<label for="inputText3" class="col-sm-2 control-label">邮箱</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="<%=rs.getString("Email")%>" name="Email" value='<%=rs.getString("Email")%>'>
|
||||
placeholder="<%=rs.getString("Email")%>" name="Email"
|
||||
value='<%=rs.getString("Email")%>'>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -123,10 +125,10 @@
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
sql.close();
|
||||
rs.close();
|
||||
conn.close();
|
||||
stmt.close();
|
||||
sql.close();
|
||||
rs.close();
|
||||
conn.close();
|
||||
stmt.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
%>
|
||||
<!-- 判断是否是管理员 -->
|
||||
<%
|
||||
Object LimitsName = "管理员";
|
||||
if (!adminuser.equals("管理员")) {/* 已在top.jsp中声明,此处报错正常 */
|
||||
out.println("<script language=javascript>alert('你不是管理员,不能访问此版块');window.location.href='mainframe.jsp'</script>");
|
||||
/* out.println(adminuser); */
|
||||
|
||||
Reference in New Issue
Block a user