顾客审核:顾客注册后,系统管理员后台可以以列表形式查看顾客基本信息, 点击顾客姓名,可以查看顾客详细信息,在顾客详细信息页面点击通过按钮,可以通过审核。通过审核的顾客才可以在前台登录界面登录主页面。(3分)
分析:我的方法是在顾客基本信息表加上一列"审核","yes"表示通过审核,其他表示未通过,涉及的知识就是改
代码
Admin_CheckUser.jsp//以列表形式展示顾客基本信息,点击顾客姓名,跳到下一个jsp展示详细信息
<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.Util.util" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>顾客基本信息浏览</title>
</head>
<body>
<table border="1" cellspacing="0" style="text-align:center;">
<tr>
<td align="center" width=10%>顾客姓名</td>
<td align="center" width=10%>顾客性别</td>
<td align="center" width=20%>顾客家庭住址</td>
</tr>
<%
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from 顾客基本信息表";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
%>
<tr>
<td align="center"><a href='Admin_CheckUser_back1.jsp?UserName=<%=rs.getObject(4)%>'><%=rs.getObject(4) %></a></td>
<td align="center"><%=rs.getObject(5) %></td>
<td align="center"><%=rs.getObject(7) %></td>
</tr>
<%
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
%>
</table>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<input type="button" name="back" onclick="javascript:window.history.back();" value=返回上一页>
<input type="button" value="返回菜单" onclick="location.href='menu.jsp'" /> <br>
</p>
</body>
</html>
Admin_CheckUser_back1.jsp//展示详细信息,点击按钮通过审核
<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.Util.util" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>顾客详细信息</title>
</head>
<body>
<%
String UserName = (String)request.getParameter("UserName");
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql = "select * from 顾客基本信息表";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next()){
if(UserName.equals(rs.getObject(4)))
{
//重要
String UserID= (String) rs.getObject(1);
session.setAttribute("UserID",UserID);
%>
<table border="1"cellspacing="0"style="text-align:center;">
<tr>
<td align="center" width=5%>顾客ID</td>
<td align="center" width=5%>身份证号</td>
<td align="center" width=10%>姓名</td>
<td align="center" width=5%>性别</td>
<td align="center" width=5%>手机</td>
<td align="center" width=5%>家庭住址</td>
<td align="center" width=5%>审核</td>
</tr>
<tr>
<td align="center"><%=rs.getObject(1) %></td>
<td align="center"><%=rs.getObject(3) %></td>
<td align="center"><%=rs.getObject(4) %></td>
<td align="center"><%=rs.getObject(5) %></td>
<td align="center"><%=rs.getObject(6) %></td>
<td align="center"><%=rs.getObject(7) %></td>
<td align="center"><%=rs.getObject(8) %></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
%>
</table>
<form action="Admin_CheckUser_back2.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<br>
点击按钮通过审核
<br>
<input type="submit" value="通过" >
</p>
</form>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<input type="button" name="back" onclick="javascript:window.history.back();" value=返回上一页>
<input type="button" value="返回菜单" onclick="location.href='User_Menu.jsp'" /> <br>
</p>
</body>
</html>
Admin_CheckUser_back2.jsp
<%@ page import="com.Dao.dao" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
<%
String UserID= (String) session.getAttribute("UserID");
String Check="yes";
dao dao=new dao();
dao.CheckUser(Check,UserID);
out.print("<script language='javaScript'> alert('成功通过审核');</script>");
response.setHeader("refresh", "0;url=Admin_Menu.jsp");
%>
</table>
</body>
</html>
Dao方法
public void CheckUser(String Check,String UserID)
{
Connection connection =util.getConnection();
PreparedStatement preparedStatement=null;
try {
String sql = "update 顾客基本信息表 set 审核=? where 顾客ID=?";
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,Check);
preparedStatement.setString(2,UserID);
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(preparedStatement);
util.close(connection);
}
}
![](/i/l/?n=22&i=blog/2913422/202211/2913422-20221107222224186-2040415623.png)
![](/i/l/?n=22&i=blog/2913422/202211/2913422-20221107222316639-46143925.png)
![](/i/l/?n=22&i=blog/2913422/202211/2913422-20221107222347283-1586101745.png)
标签:preparedStatement,String,rs,util,connection,房产,信息管理系统,顾客 From: https://www.cnblogs.com/mendianyu/p/16867683.html