房产信息管理系统-新增房产信息/新增房产经纪人信息/用户注册
这三个功能比较简单,就是基础的增
直接上代码
添加房产信息:房产编号(唯一性)(编码规则:年月日(登记入库时间)+四位顺序号,例如:202012200001)、户型(单选项:选项内容包括以下六项:四室两厅、四室一厅、三室两厅、三室一厅、两室两厅、两室一厅),房产地址(地址格式:XX省XX市XX区(县)XX街道XX小区XX号楼XX单元XXX门牌),建造年份,建造面积,销售报价,销售状态(在售,待售,意向,售出,停售,缺省为“在售”)。(5分)
Admin_AddHouse.jsp
<%--
Created by IntelliJ IDEA.
User: mendianyu
Date: 2022/11/4
Time: 15:25
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_AddHouse_back.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
添加房产信息
<br>
房产编号
<input type="text" name="HouseID" >
<br>
户型
<input type="radio" name="HouseType" value="四室两厅">四室两厅
<input type="radio" name="HouseType" value="四室一厅">四室一厅
<input type="radio" name="HouseType" value="三室两厅">三室两厅
<input type="radio" name="HouseType" value="三室一厅">三室一厅
<input type="radio" name="HouseType" value="两室两厅">两室两厅
<input type="radio" name="HouseType" value="两室一厅">两室一厅
<br>
房产地址
<input type="text" name="Address" >
<br>
建造年份
<input type="text" name="Year" >
<br>
建造面积
<input type="text" name="Area" >
<br>
销售报价
<input type="text" name="Sales" >
<br>
销售状态
<input type="radio" name="Status" value="在售"checked>在售
<input type="radio" name="Status" value="待售">待售
<input type="radio" name="Status" value="意向">意向
<input type="radio" name="Status" value="售出">售出
<input type="radio" name="Status" value="停售">停售
<br>
<input type="submit" value="添加" >
</p>
</form>
</body>
</html>
Admin_AddHouse_back.jsp
<%@ page import="com.Bean.bean" %>
<%@ page import="com.Dao.dao" %>
<%@ page language= "java" import="java.util.*" contentType= "text/html; charset=UTF-8"
pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta charset="UTF-8">
<%
String HouseID=request.getParameter("HouseID");
String HouseType=request.getParameter("HouseType");
String Address=request.getParameter("Address");
String Year=request.getParameter("Year");
String Area=request.getParameter("Area");
String Sales=request.getParameter("Sales");
String Status=request.getParameter("Status");
if(HouseID==""||HouseType==""||Address==""||Year==""||Area==""||Sales==""||Status=="")
{
out.print("<script language='javaScript'> alert('某项输入为空'); window.history.back(); </script>");
}
else
{
bean bean = new bean();
bean.setHouseID(HouseID);
bean.setHouseType(HouseType);
bean.setAddress(Address);
bean.setYear(Year);
bean.setArea(Area);
bean.setSales(Sales);
bean.setStatus(Status);
dao dao = new dao();
dao.AddHouse(bean);
out.print("<script language='javaScript'> alert('添加成功');</script>");
response.setHeader("refresh", "0;url=Admin_Menu.jsp");
}
%>
</html>
Dao层方法
public void AddHouse(bean bean)
{
Connection connection= util.getConnection();
PreparedStatement preparedStatement=null;
try
{
String sql="insert into 房产基本信息表(房产编号,户型,房产地址,建造年份,建造面积,销售报价,销售状态) values(?,?,?,?,?,?,?)";
preparedStatement =connection.prepareStatement(sql);
preparedStatement.setString(1,bean.getHouseID());
preparedStatement.setString(2,bean.getHouseType());
preparedStatement.setString(3,bean.getAddress());
preparedStatement.setString(4,bean.getYear());
preparedStatement.setString(5,bean.getArea());
preparedStatement.setString(6,bean.getSales());
preparedStatement.setString(7,bean.getStatus());
preparedStatement.executeUpdate();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
util.close(preparedStatement);
util.close(connection);
}
}
添加房产经纪人信息:房产经纪人基本信息包括:工号(八位数字:年份+四位序号),姓名,家庭住址,手机。(2分)
Admin_AddAgent.jsp
<%--
Created by IntelliJ IDEA.
User: mendianyu
Date: 2022/11/4
Time: 15:25
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_AddAgent_back.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
添加房产经纪人
<br>
房产经纪人ID
<input type="text" name="AgentID" >
<br>
登录密码
<input type="text" name="Apassword" >
<br>
姓名
<input type="text" name="AgentName" >
<br>
手机号码
<input type="text" name="AgentPhone" >
<br>
家庭住址
<input type="text" name="AgentAddress" >
<br>
<input type="submit" value="添加" >
</p>
</form>
</body>
</html>
Admin_AddAgent_back.jsp
<%@ page import="java.sql.SQLException" %>
<%@ page import="com.Bean.bean" %>
<%@ page import="com.Dao.dao" %>
<%@ page language= "java" import="java.util.*" contentType= "text/html; charset=UTF-8"
pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta charset="UTF-8">
<%
String AgentID = request.getParameter("AgentID");
String Apassword = request.getParameter("Apassword");
String AgentName = request.getParameter("AgentName");
String AgentPhone = request.getParameter("AgentPhone");
String AgentAddress = request.getParameter("AgentAddress");
if(AgentID==""||Apassword==""||AgentName==""||AgentPhone==""||AgentAddress=="")
{
out.print("<script language='javaScript'> alert('某项输入为空'); window.history.back(); </script>");
}
else
{
bean bean = new bean();
bean.setAgentID(AgentID);
bean.setApassword(Apassword);
bean.setAgentName(AgentName);
bean.setAgentPhone(AgentPhone);
bean.setAgentAddress(AgentAddress);
dao dao = new dao();
dao.AddAgent(bean);
out.print("<script language='javaScript'> alert('添加成功');</script>");
response.setHeader("refresh", "0;url=Agent_Login.jsp");
}
%>
</html>
Dao方法
public void AddAgent(bean bean)
{
Connection connection= util.getConnection();
PreparedStatement preparedStatement=null;
try
{
String sql="insert into 房产经纪人基本信息表(房产经纪人ID,登录密码,房产经纪人姓名,家庭住址,手机号码) values(?,?,?,?,?)";
preparedStatement =connection.prepareStatement(sql);
preparedStatement.setString(1,bean.getAgentID());
preparedStatement.setString(2,bean.getApassword());
preparedStatement.setString(3,bean.getAgentName());
preparedStatement.setString(4,bean.getAgentAddress());
preparedStatement.setString(5,bean.getAgentPhone());
preparedStatement.executeUpdate();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
util.close(preparedStatement);
util.close(connection);
}
}
用户注册:点击用户登录页面的“注册”按钮,顾客进入用户注册页面,注册信息包括身份证号(判断条件18位,最后一位可以是字母“X”)、姓名、性别(男或女单选)、手机号码(11位数字)、家庭住址(地址格式:XX省XX市XX区(县)XX街道XX小区XX号楼XX单元XXX门牌)。(4分)
User_Register.jsp
<%--
Created by IntelliJ IDEA.
User: mendianyu
Date: 2022/11/4
Time: 15:25
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="User_Register_back.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
用户ID
<input type="text" name="UserID" >
<br>
密码
<input type="text" name="Upassword" >
<br>
身份证号
<input type="text" name="IdNumber" >
<br>
姓名
<input type="text" name="UserName" >
<br>
性别
<input type="text" name="Sex" >
<br>
手机号码
<input type="text" name="UserPhone" >
<br>
家庭住址
<input type="text" name="UserAddress" >
<br>
<input type="submit" value="注册" >
</p>
</form>
</body>
</html>
User_Register_back.jsp
<%@ page import="java.sql.SQLException" %>
<%@ page import="com.Bean.bean" %>
<%@ page import="com.Dao.dao" %>
<%@ page language= "java" import="java.util.*" contentType= "text/html; charset=UTF-8"
pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta charset="UTF-8">
<%
String UserID = request.getParameter("UserID");
String Upassword = request.getParameter("Upassword");
String IdNumber = request.getParameter("IdNumber");
String UserName = request.getParameter("UserName");
String Sex = request.getParameter("Sex");
String UserPhone = request.getParameter("UserPhone");
String UserAddress = request.getParameter("UserAddress");
if(UserID=="")
{
out.print("<script language='javaScript'> alert('用户ID输入为空'); window.history.back(); </script>");
}
else if(Upassword=="")
{
out.print("<script language='javaScript'> alert('活动目的输入为空'); window.history.back(); </script>");
}
else if(IdNumber=="")
{
out.print("<script language='javaScript'> alert('活动类型输入为空'); window.history.back(); </script>");
}
else if(UserName=="")
{
out.print("<script language='javaScript'> alert('活动时间输入为空'); window.history.back(); </script>");
}
else if(Sex=="")
{
out.print("<script language='javaScript'> alert('活动地点输入为空'); window.history.back(); </script>");
}
else if(UserPhone=="")
{
out.print("<script language='javaScript'> alert('活动对象输入为空'); window.history.back(); </script>");
}
else if(UserAddress=="")
{
out.print("<script language='javaScript'> alert('活动内容输入为空'); window.history.back(); </script>");
}
else
{
bean bean = new bean();
bean.setUserID(UserID);
bean.setUpassword(Upassword);
bean.setIdNumber(IdNumber);
bean.setUserName(UserName);
bean.setSex(Sex);
bean.setUserPhone(UserPhone);
bean.setUserAddress(UserAddress);
dao dao = new dao();
dao.AddUser(bean);
out.print("<script language='javaScript'> alert('注册成功');</script>");
response.setHeader("refresh", "0;url=User_Login.jsp");
}
%>
</html>
Dao方法
public void AddUser(bean bean)
{
Connection connection= util.getConnection();
PreparedStatement preparedStatement=null;
try
{
String sql="insert into 顾客基本信息表(顾客ID,密码,身份证号,姓名,性别,手机,家庭住址) values(?,?,?,?,?,?,?)";
preparedStatement =connection.prepareStatement(sql);
preparedStatement.setString(1,bean.getUserID());
preparedStatement.setString(2,bean.getUpassword());
preparedStatement.setString(3,bean.getIdNumber());
preparedStatement.setString(4,bean.getUserName());
preparedStatement.setString(5,bean.getSex());
preparedStatement.setString(6,bean.getUserPhone());
preparedStatement.setString(7,bean.getUserAddress());
preparedStatement.executeUpdate();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
util.close(preparedStatement);
util.close(connection);
}
}