房产授权系统管理员登录后可以浏览所有的在售房产信息,显示结果信息包括序号、地址、销售报价,点击地址,可以查看该套房产的详细信息,输入房产经纪人ID,如果房产经纪人信息不存在,提示错误信息,不允许授权;如果正确,点击“授权”按钮,该房产状态信息改为“待售”状态。(3分)


此功能涉及的功能主要还是改,点击授权按钮后,借助Dao方法,将房产信息状态改为“待售”,另外还有一点题目要起没写,还需要将房产基本表中的房产经纪人ID一列修改为输入的房产经纪人ID。

代码

Admin_AuthorizeHouse.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=6%>房产编号</td>
<td align="center" width=10%>房产地址</td>
<td align="center" width=6%>销售报价</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"><%=rs.getObject(1) %></td>
<td align="center"><a href='Admin_AuthorizeHouse_back1.jsp?Address=<%=rs.getObject(3)%>'><%=rs.getObject(3) %></a></td>
<td align="center"><%=rs.getObject(6) %></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_AuthorizeHouse_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 Address = (String)request.getParameter("Address");
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(Address.equals(rs.getObject(3)))
{
//重要
String HouseID= (String) rs.getObject(1);
session.setAttribute("HouseID",HouseID);
%>
<table border="1"cellspacing="0"style="text-align:center;">
<tr>
<td align="center" width=5%>房产编号</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>
<td align="center" width=5%>房产经纪人ID</td>
<td align="center" width=5%>顾客ID</td>
</tr>
<tr>
<td align="center"><%=rs.getObject(1) %></td>
<td align="center"><%=rs.getObject(2) %></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>
<td align="center"><%=rs.getObject(9) %></td>
</tr>
<%
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
%>
</table>
<form action="Admin_AuthorizeHouse_back2.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<br>
请输入被授权房产经纪人的工号
<br>
<input type="text" name="AgentID" >
<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_AuthorizeHouse_back2.jsp 
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="com.Util.util" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="com.Dao.dao" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
<%

String AgentID=(String)request.getParameter("AgentID");

if(AgentID=="")
{
out.print("<script language='javaScript'> alert('房产经纪人姓名输入为空'); window.history.back(); </script>");
}
else
{

int i=0;
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)))
{i++;}
}
if(i==0)
{
out.print("<script language='javaScript'> alert('该房产经纪人不存在'); window.history.back(); </script>");
}
else
{
String HouseID= (String) session.getAttribute("HouseID");
String Status="待售";
dao dao=new dao();
dao.AuthorizeHouse(AgentID,Status,HouseID);
out.print("<script language='javaScript'> alert('授权成功');</script>");
response.setHeader("refresh", "0;url=Admin_Menu.jsp");
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
}
%>
</table>
</body>
</html>
 Dao方法
public void AuthorizeHouse(String AgentID,String Status,String HouseID)
{
Connection connection =util.getConnection();
PreparedStatement preparedStatement=null;
try {
String sql = "update 房产基本信息表 set 房产经纪人ID=?,销售状态=? where 房产编号=?";
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,AgentID);
preparedStatement.setString(2,Status);
preparedStatement.setString(3,HouseID);
preparedStatement.executeUpdate();

} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(preparedStatement);
util.close(connection);
}
}
 

原文地址:http://www.cnblogs.com/mendianyu/p/16869055.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性