logo资料库

汽车租赁系统论文.doc

第1页 / 共42页
第2页 / 共42页
第3页 / 共42页
第4页 / 共42页
第5页 / 共42页
第6页 / 共42页
第7页 / 共42页
第8页 / 共42页
资料共42页,剩余部分请下载后查看
1.需求分析
1.1任务概述
1.2开发环境和使用技术
1.3数据库设计
2.登陆模块
2.1登陆页面的代码是:
2.2登录类login.java的代码如下:
2.3LoginServlet.java的代码如下:
}else {
// Put your code here
3.公共模块
3.1数据库连接
3.2中文乱码过滤器
4.主页面模块
4.1mainpage.jsp页面的代码是:
<%@ page import="java.util.Date,java.text.*" %>
String basePath = request.getScheme() + "://"
My JSP 'frontpage.jsp' starting page</title</span></div><div class='bookmark-item'><span class='bookmark-indent-1' data-page='12'>4.2menu.html</span></div><div class='bookmark-item'><span class='bookmark-indent-0' data-page='12'><html></span></div><div class='bookmark-item'><span class='bookmark-indent-0' data-page='12'> <title>menu.html
汽车租赁管理系统

客户管理

业务管理

5.用户管理模块
5.1添加用户
5.2显示全部用户
5.3修改用户
序号身份证性别用户类型
5.4删除用户信息
5.5显示单个用户的详细信息
6.汽车管理模块
6.1新增汽车
6.2查看全部汽车信息
6.3查看单个汽车详细信息
6.4修改汽车信息
6.5删除单个汽车信息
7.客户管理模块
7.1添加客户信息
7.2查看全部客户信息
7.3修改客户信息
7.4删除客户信息
8.业务管理模块
8.1汽车出租
8.2出租单管理
8.3检查单管理
9.心得体会
汽车租赁系统 1.需求分析..........................................................................................................................- 2 - 1.1 任务概述 ................................................................................................................. - 2 - 1.2 开发环境和使用技术 ............................................................................................. - 2 - 1.3 数据库设计 ............................................................................................................. - 2 - 2.登陆模块..........................................................................................................................- 5 - 2.1 登陆页面的代码是: ............................................................................................. - 5 - 2.2 登录类 login.java 的代码如下:........................................................................... - 6 - 2.3LoginServlet.java 的代码如下: .............................................................................- 7 - 3.公共模块..........................................................................................................................- 8 - 3.1 数据库连接 ............................................................................................................. - 8 - 3.2 中文乱码过滤器 ................................................................................................... - 10 - 4.主页面模块 ................................................................................................................... - 10 - 4.1mainpage.jsp 页面的代码是:.............................................................................. - 11 - 4.2menu.html............................................................................................................. - 12 - 5.用户管理模块............................................................................................................... - 13 - 5.1 添加用户 ............................................................................................................... - 14 - 5.2 显示全部用户 ....................................................................................................... - 19 - 5.3 修改用户 ............................................................................................................... - 24 - 5.4 删除用户信息 ....................................................................................................... - 30 - 5.5 显示单个用户的详细信息 ................................................................................... - 32 - 6.汽车管理模块............................................................................................................... - 34 - 6.1 新增汽车 ............................................................................................................... - 34 - 6.2 查看全部汽车信息 ............................................................................................... - 35 - 6.3 查看单个汽车详细信息 ....................................................................................... - 35 - 6.4 修改汽车信息 ....................................................................................................... - 36 - 6.5 删除单个汽车信息 ............................................................................................... - 37 - 7.客户管理模块............................................................................................................... - 37 - 7.1 添加客户信息 ....................................................................................................... - 38 - 7.2 查看全部客户信息 ............................................................................................... - 39 - 7.3 修改客户信息 ....................................................................................................... - 39 - 7.4 删除客户信息 ....................................................................................................... - 40 - 8.业务管理模块............................................................................................................... - 40 - 8.1 汽车出租 ............................................................................................................... - 40 - 8.2 出租单管理 ........................................................................................................... - 41 - 8.3 检查单管理 ........................................................................................................... - 41 - 9.心得体会........................................................................................................................- 42 - 10.小组分工………………………………………………………………………………….42 11.小组打分………………………………………………………………………………….42
1.需求分析 1.1 任务概述 该系统能对汽车信息进行入库录入、租赁登记、租赁状态查询、过期提示、入库检查等操作。 该系统定位为在主流计算机操作系统中能直接运行的 B/S 结构的汽车租赁信息管理系统。 1.2 开发环境和使用技术 使用的操作系统是 Windows 系列,开发工具是 Myeclipse8.5,开发过程使用的服务器是 Tomcat 服务器,数据库是 MySQL。 页面使用 JSP 技术,取值采用 JSTL 标签和 EL 表达式结合,控制层采用 Servlet,数据持久 层采用 JDBC 技术。同时,采用了过滤器对一些操作或者数据进行过滤。 1.3 数据库设计 用户表 users 的信息如下: 创建数据库表 users 的代码如下: Use car; create table users( varchar(32) default null, password varchar(64) not null, userlevel varchar(22) not null, position phone varchar(64) default null, address varchar(512) default null, sex decimal(2,0) default null, fullname varchar(32) default null, dentity varchar(128) not null, username varchar(64) not null, id int not null, primary key (id) ) 汽车信息表 cars 的信息如下: - 2 -
创建数据库表 cars 的代码如下: Use car; create table cars( description varchar(512) default null, isrenting int default null, deposit decimal(10,0) default null, rentprice decimal(10,0) default null, price decimal(10,0) default null, color varchar(12) default null, cartype varchar(32) not null, carnumber varchar(32) not null, id int not null, primary key (id) ) 客户信息表 customers 的信息如下: 创建数据库表 customers 的代码如下: Use car; create table customers( password varchar(32) default null, career varchar(32) default null, phone varchar(64) default null, address varchar(512) not null, custname varchar(64) not null, - 3 -
sex int default null, dentity varchar(64) not null, id int not null, primary key(id) ) 出租单信息表 renttable 的信息如下: 创建数据库表 renttable 的代码如下: Use car; create table renttable( rerumdate date default null, cusrid int not null, carsid int not null, userid int not null, rentflag int default null, begindate date default null, shouldretumdate date default null, price decimal(10,0) not null, ahouldpayprice decimal(10,0) not null, imprest decimal(10,0) not null, tableid varchar(64) not null, id int not null , primary key (id), key userid (userid), key carsid (carsid), key cusfid (cusrid) ) 检查单信息表 checktable 的信息如下: - 4 -
int not null, 创建数据库表 checktable 的代码如下: Use car; create table checktable( rentid checkuserid int not null, paying decimal(10,0) default null, problem varchar(50) default null, field varchar(12) default null, checkdate date default null, checkid int not null, id int not null , primary key(id), key checkduserid (checkuserid), key rentid (rentid) ) 2.登陆模块 登陆模块需要判断用户类型,同时为了防止未登陆而直接进入系统,采取了防止未登录 操作的过滤器。其中,登陆的访问路径为 http://localhost:8080/Car/login.jsp。 登录模块的步骤是在 login.jsp 页面登陆,然后把数据传递到 LoginServlet,由 Servlet 调 用 login.java 中的 变量 进行判 断, 输入正 确则 跳转到 mainpage.jsp,输 入错 误则跳 转到 loginError.jsp 页面。 ● Login.jsp:用户登录的页面。 ● Login.java:用户登录的实现类。 ● LoginServlet.java:用户登录的 Servlet。 2.1 登陆页面的代码是:
序号身份证性别用户类型
id="password"> - 5 -

用户名:
密码:
管理员: 服务员: name="userlevel">   

2.2 登录类 login.java 的代码如下: package com.cn.login; import com.cn.jdbc.JDBC_Connection; import com.cn.users.UsersVo; public class Login { public UsersVo check(String username){ ResultSet rs = null; PreparedStatement pstmt =null; Connection conn = null; UsersVo usersVo = new UsersVo(); - 6 -
try { conn = JDBC_Connection.getConnection(); String sql = "select * from users where username=?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1, username); rs = pstmt.executeQuery(); while(rs.next()){ usersVo.setId(rs.getInt("id")); usersVo.setUsername(rs.getString("username")); usersVo.setDentity(rs.getString("identity")); usersVo.setFullname(rs.getString("fullname")); usersVo.setSex(rs.getInt("sex")); usersVo.setAddress(rs.getString("address")); usersVo.setPhone(rs.getString("phone")); usersVo.setPosition(rs.getString("position")); usersVo.setUserlevel(rs.getString("userlevel")); usersVo.setPassword(rs.getString("password")); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ JDBC_Connection.free(rs, conn, pstmt); } return usersVo; } } 2.3LoginServlet.java 的代码如下: package com.cn.login; import com.cn.users.UsersVo; public class LoginServlet extends HttpServlet { public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.flush(); out.close(); } public void doPost(HttpServletRequest request, HttpServletResponse response) - 7 -
throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String username = request.getParameter("username"); String password =request.getParameter("password"); List list = new ArrayList(); Login login = new Login(); UsersVo usersVo = new UsersVo(); if(username.length()!=0&&password.length()!=0){ usersVo = login.check(username); if(usersVo!=null){ if(username.equals(usersVo.getUsername())&&password.equals(usersVo.getPassword())){ response.sendRedirect("/car/mainpage.jsp"); }else { response.sendRedirect("login/loginError.jsp"); } }else{ } }else{ } out.flush(); out.close(); } public void init() throws ServletException { // Put your code here } } 3.公共模块 在本项目中有一些代码是所有模块都要用到的类,为了方便开发,把这些都会用到的类独立 出来,便于调用和节省代码量。在编写公共模块之前,要把项目搭建好。在 Myeclipse 中新 建 一 个 Web Project , 名 称 为 Car , 把 连 接 MySQL 数 据 库 的 jar 包 mysql-connector-java-5.0.8.tar 复制到该工程的 WEbRoot/WEB-INF/Lib 目录下。然后把 JSTL 标签用到的 jar 包复制到 WEbRoot/WEB-INF/Lib 目录下。 3.1 数据库连接 在连接数据库的类中,需要创建数据库驱动和连接到数据库模式,然后编写一个关闭连接的 方法。数据库连接类 JDBC-Connection 的源代码如下: package com.cn.jdbc; import java.sql.*; public class JDBC_Connection { static String drivername="com.mysql.jdbc.Driver"; static String url="jdbc:mysql://localhost:3306/car"; - 8 -
分享到:
收藏