查询房产信息:可以按照户型、地址、建造年份、建造面积,销售报价五个条件进行综合查询,查询结果以列表形式显示,显示结果信息包括序号、地址、销售报价,点击地址,可以查看该套房产的详细信息;顾客可以看到的结果为所有在售的房产,房产经纪人看到的结果为所有授权给自己销售的房产信息,系统管理员可以查询所有房产信息。
此功能涉及的就是查
关于限制条件,和浏览一样,增加if判断即可
代码:
Agent_SearchHouse.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>房产信息查询</title>
</head>
<body>
<form action="Agent_SearchHouse_part.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
请输入要查询的房产户型/地址/建造年份/建造面积/销售报价(模糊查询)
<br>
<input type="text" name="data">
<br>
<input type="submit" value="提交" >
<input type="reset" value="重置" >
<br>
<input type="button" value="返回主菜单" onclick="location.href='User_Menu.jsp'">
<br>
</p>
</form>
</body>
</html>
Agent_SearchHouse_part.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 contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>部分房产信息</title>
</head>
<body>
<%
String AgentID= (String) session.getAttribute("AgentID");
String data=(String)request.getParameter("data");
if(data=="")
{
out.print("<script language='javaScript'> alert('输入为空'); window.history.back(-1); </script>");
}
else
{
%>
<table border="1" cellspacing="0">
<tr>
<td align="center" width=6%>房产编号</td>
<td align="center" width=10%>房产地址</td>
<td align="center" width=6%>销售报价</td>
</tr>
<%
int i=0;
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql= " select * from 房产基本信息表 where 户型 like ? or 房产地址 like ? or 建造年份 like ? or 建造面积 like ? or 销售报价 like ? ";
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,"%"+data+"%");
preparedStatement.setString(2,"%"+data+"%");
preparedStatement.setString(3,"%"+data+"%");
preparedStatement.setString(4,"%"+data+"%");
preparedStatement.setString(5,"%"+data+"%");
rs=preparedStatement.executeQuery();
while(rs.next())
{
if(AgentID.equals(rs.getObject(8)))
{
i++;
%>
<tr>
<td align="center"><%=rs.getObject(1) %></td>
<td align="center"><a href='Agent_SearchHouse_all.jsp?Address=<%=rs.getObject(3)%>'><%=rs.getObject(3) %></a></td>
<td align="center"><%=rs.getObject(6) %></td>
</tr>
<%
}
}
if(i==0)
{
out.print("<script language='javaScript'> alert('没有查询到有关信息'); window.history.back(-1); </script>");
}
} 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>
Agent_SearchHouse_all.jsp
<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"标签:preparedStatement,String,房产信息,rs,--,util,房产,信息管理系统 From: https://www.cnblogs.com/mendianyu/p/16874849.html
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)))
{
%>
<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>
<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='Agent_Menu.jsp'" /> <br>
</p>
</body>
</html>
关于顾客和系统管理员的查询功能代码就不放了,和房产经纪人的代码几乎一样