房产信息管理系统--重置密码

重置密码:管理员可以修改房产经纪人的个人密码,先按照房产经纪人工号查询,显示出基本信息后,点击密码重置,将房产经纪人密码统一修改为“123456”。2

此功能涉及的就是查和改

代码

Admin_ResetPassword.jsp

<%--
Created by IntelliJ IDEA.
User: mendianyu
Date: 2022/11/4
Time: 21:22
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>重置密码</title>
</head>
<body>
<form action="Admin_ResetPassword_back1.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
请输入要重置密码的房产经纪人的工号
<br>
<input type="text" name="AgentID">
<br>
<input type="submit" value="提交" >
<br>
<input type="button" value="返回主菜单" onclick="location.href='Admin_Menu.jsp'">
<br>
</p>
</form>
</body>
</html>

Admin_ResetPassword_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 AgentID= (String)request.getParameter("AgentID");
session.setAttribute("AgentID",AgentID);
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(AgentID.equals(rs.getObject(1)))
{
%>
<table border="1"cellspacing="0"style="text-align:center;">
<tr>
<td align="center" width=10%>房产经纪人ID</td>
<td align="center" width=5%>姓名</td>
<td align="center" width=20%>家庭住址</td>
<td align="center" width=20%>手机号码</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>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
%>
</table>
<form action="Admin_ResetPassword_back2.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<input type="submit" value="重置密码">
</p>
</form>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<input type="button" value="返回菜单" onclick="location.href='Agent_Menu.jsp'" /> <br>
</p>
</body>
</html>

Admin_ResetPassword_back2.jsp

<%@ page import="com.Dao.dao" %><%--
Created by IntelliJ IDEA.
User: mendianyu
Date: 2022/11/5
Time: 19:38
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%

String AgentID= (String)session.getAttribute("AgentID");
String Apassword="123456";
dao dao=new dao();
dao.ResetPassword(Apassword,AgentID);
out.print("<script language='javaScript'> alert('成功重置密码');</script>");
response.setHeader("refresh", "0;url=Admin_Menu.jsp");

%>
</body>
</html>

Dao方法

public void ResetPassword(String Apassword,String AgentID)
{
Connection connection =util.getConnection();
PreparedStatement preparedStatement=null;
try {
String sql = "update 房产经纪人基本信息表 set 登录密码=? where 房产经纪人ID=?";
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,Apassword);
preparedStatement.setString(2,AgentID);
preparedStatement.executeUpdate();

} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(preparedStatement);
util.close(connection);
}
}
posted @ 2022-11-11 11:17  Men!  阅读(172)  评论(0编辑  收藏  举报