基于spring boot实现的宾馆管理信息系统

一,系统开发平台 题目:宾馆管理信息系统 宾馆管理信息系统是现代商业社会宾馆酒店单位不可缺少的部分,在“互联网+”的影响下,这套网站的使用对于宾馆的决策者和管理者来说都至关重要

本文包含相关资料包-----> 点击直达获取<-------

一、系统开发平台

题目:宾馆管理信息系统

宾馆管理信息系统是现代商业社会宾馆酒店单位不可缺少的部分,在“互联网+”的影响下,这套网站的使用对于宾馆的决策者和管理者来说都至关重要,所以宾馆管理信息系统应该能够为用户提供充足的信息和快捷的登记结账手段。但一直以来人们使用传统人工的方式管理宾馆入住情况,这种管理方式存在着许多缺点,如效率低、保密性差,另外时间一长,将产生大量的账本数据,这对于查找、更新和维护以及后期的计算报表都带来了不少的困难。本系统采用MyEclipse Professional 2014 JDK 1.8 以及Tomcat 8.0作为开发工具,JSP+Servlet+JavaBean为开发语言,采用MySQL 最新版5.7.13建立数据库,先在MySQL中设计并制作各部分需要调用的数据库,并进行初始房间数据的输入,再进行网页界面的设计和事物逻辑的编写,在指导老师的帮助下,已经基本上成功地实现了设计要求。其中数据库设计和程序逻辑设计是系统的核心部分。通过对数据库的概念设计、逻辑设计、物理设计和系统的模块设计,使得系统界面简洁美观,功能明确,方便了宾馆管理人员的操作。

  • 开发语言:JSP+Servlet+JavaBean、HTML、CSS、JavaScript、Jquery3.1.0、BootStrap框架

  • 用JavWeb做网站设计流程清晰、结构合理,有良好的可扩充性和耦合性。

  • 开发工具:MyEclipse Professional 2014 、JDK 1.8、

  • Tomcat 8.0

  • 数据库:mysql 5.7.13

MySQL数据库简称MySQL,是一款由瑞典MySQLAB公司开发并且广泛应用在于小型企业或者组织中的小型数据管理系统,MySQL数据库体积小、速度快、总体拥有成本低,开发简便快捷,性能还是不错的。

操作系统:Microsoft Windows 10

二、数据库规划

2.1 任务陈述

一套功能强大而又使用简便的客房管理软件,适用于宾馆管理、酒店管理、招待所管理。主要功能:团体,散客入住客人的信息登记,换房,正常退房,挂账退房,挂单补款结账,预定管理,贵宾卡管理,押金管理,各种强大的宾馆统计报表,异常处理。

本宾馆管理信息系统包括VIP信息管理、房间信息管理、客户信息管理、账单信息管理四大模块。管理员拥有完全的权限管理系统,给客户登记住宿信息,修改客户信息、查看当前住宿情况,查看剩余房间及当前入住房间状况,增加房间信息,修改房间信息,办理用户结账、挂账,办理挂账补款,查看历史账单等等一系列功能。

2.2 任务目标

本系统主要可以实现以下任务目标:

  • 系统可以准确地记录和查询住户信息,包括住户的订单号、姓名、性别、身份证号、所住房间号、联系方式、是否是VIP、入住时间等。

  • 系统可以对宾馆的房间情况进行管理,包括添加修改删除房间信息、添加修改删除某房间容量大小信息等。

  • 系统可以准确地对VIP信息进行管理,包括VIP的账号、姓名、性别、身份证号、联系方式、VIP等级、办理时间等。

  • 系统可以对用户订单结账信息进行管理,包括根据订单信息以及是否是VIP进行账单的计算、对账单的查询。

  • 系统可以对挂账结算的用户账单进行挂账记录,以及对挂账补款进行挂账的删除。

  • 系统可以对结账的账单信息以及挂单补款的账单信息进行记录,添加到历史纪录表中,可以对历史纪录进行查询,不可以注销

  • 异常处理。

三、系统定义

3.1 系统边界

本宾馆管理信息系统包括VIP信息管理、房间信息管理、客户信息管理、账单信息管理四大模块。该管理信息系统的其他部分包括管理员的登录。(管理员是写死的)

数据库系统的内部构成元素与外部其他部分之间的信息关系如下图所示:

3.2 用户视图

管理员用户视图

房间管理:

查询、添加、修改、删除房间信息。

客户管理

查询、添加、修改、删除客户信息。

VIP管理:

查询、添加、修改、删除VIP信息。

账单管理:

查询缴费信息,添加挂单信息,删除挂单信息,添加历史账单,查询历史账单

四、需求分析

此宾馆管理信息系统的主要功能如下图所示:

4.1 用户需求说明

4.1.1 数据需求

其中需求数据为:

顾客基本信息记录:

订单号、姓名、性别、身份证、房间号、联系方式、是否是VIP、入住时间

VIP基本信息记录:

账号、姓名、性别、身份证号、联系方式、VIP等级、办理时间

房间基本信息记录:

房间号、房间大小、房间价格、剩余容量、押金

账单历史纪录基本信息记录:

订单号、价格、支付时间

挂单信息基本信息记录:

订单号、价格、挂单时间

  • 管理员信息记录

管理员编号、管理员姓名、管理员密码

4.1.2 事务需求

数据录入:

录入顾客的基本信息:

  • 订单号、姓名、性别、身份证、房间号、联系方式、是否是VIP、入住时间

录入房间的信息

房间号、房间大小、房间价格、剩余容量、押金

录入VIP的基本信息:

账号、姓名、性别、身份证号、联系方式、VIP等级、办理时间

录入历史记录账单的信息:

订单号、价格、支付时间

录入挂单的信息:

订单号、价格、挂单时间

数据更新/删除:

  • 顾客住房等一系列信息的更新/删除

  • 房间大小等信息的更新

  • VIP信息的更新/删除

  • 挂单信息的删除

数据查看:

  • 列出顾客详细信息

  • 按照身份证号列出顾客基本信息

  • 列出订单详细信息

  • 按照订单号列出账单的详细信息

  • 列出VIP用户详细信息

  • 按照VIP帐号列出VIP成员的详细信

  • 列出所有房间的详细信息

  • 根据房间号列出房间的基本信息

4.2 系统需求说明

  • 该宾馆管理信息系统需要较强的数据处理功能,在搜索查询账单方面理应具有较快的响应速度,能够处理多方面的数据请求。系统能够有效的处理各种异常,具有较好的健壮性。

  • 初始数据库

  • 大约有50个房间,每个房间或者能容纳两人,或者容纳三人,每个房间有自己的押金表名订这间房间需要缴纳的押金费用。

  • 有一张空闲的VIP信息表,历史订单表,待付账单表

  • 有一个预先设置好的管理员编号、姓名和密码表,用来核对管理员登录时输入信息是否正确

  • 安全性

  • 登录管理员必须有账号密码

  • 必须验证VIP账号才能进行VIP用户的登记

  • 3 网站界面

  • 前端语言,运用BootStrap框架,大大简化了编写CSS的过程

五、数据库逻辑设计

5.1 ER图:

本系统的ER图如下:

该ER图包括Customer、Room、VIPCard、haspayed、leavewithoutpay五个实体和登记、付款、核对、挂单补齐四个联系。

5.2 数据字典

从数据字典中抽取出来的系统实体描述:

Customer:

vipCard:

Room:

Leavewithoutpay:

Haspayed:

从数据字典中抽取出来的联系的描述:

实体 多样性 联系 多样性 实体
customer m 登记 n Room
customer n 核对 1 vipcard
customer m 付款 1 Haspayed
customer m 挂单 1 Leavewithoutpay
leavewithoutpay 1 补款 1 Haspayed

六、数据库物理设计

6.1 索引

由于本系统数据不多,查询量相对较小,故没有建立索引

6.2 安全机制

提供了充足的异常处理机制,能够捕获由各种错误引发的异常。

系统登录时要凭用户名和密码进入,输入正确时才可以进入系统。用户需要选择自己的身份(普通用户或者VIP用户),若VIP账号输入正确,系统可以为其计算价格时打折。其他普通用户没有优惠。

七、应用程序设计

7.1 功能模块

该学生管理信息系统共有四个模块:登记模块、结账模块、VIP信息管理模块、房间信息管理模块,各个模块实现的功能如下:

  • 登记模块

  • 种登记选择:普通个人、VIP个人、普通团体、VIP团体。

  • 按身份证查找并更新客户信息,包括换房功能

  • 查看当前住户详细信息

  • 结账模块

  • 结账退房,从当前住客中删除此订单信息,将此订单加入到历史账单

  • 挂单退房,从当前住客中删除此订单信息,将此账单加入待付账单

  • 挂单补款,从待付账单中删除此订单,加入到历史账单

  • 查看所有待付账单,根据订单号查看待付账单

  • 查看所有的历史账单

  • VIP信息管理模块

  • 办理VIP,添加信息到vipcard表

  • 注销VIP,根据VIP账号删除此VIP信息

  • VIP信息修改,根据VIP账号修改

  • 显示所有VIP用户的详细信息

  • 房间信息管理模块

  • 添加房间,添加信息到room表

  • 房间信息修改,根据房间号修改房间的基本信息

  • 房间信息的详细显示

7.2 界面设计

管理员登记界面

用户登记界面

普通用户登记页面

VIP用户登记界面

普通团体用户登记界面

VIP团体登记

登记完成后提示需要缴纳押金数目

修改用户信息

当前住户情况

结账退房,自动根据订单号计算用户需要缴纳的价格

挂单退房,根据订单号

挂单补齐

历史账单

办理VIP页面

根据VIP账号注销VIP账户

VIP信息显示

根据VIP账号修改VIP信息

添加房间

根据房间号修改房间基本信息

房间信息显示

7.3 事务设计

数据库连接事物设计

c++ package com.hotel.dao; import java.sql.*; import java.util.ArrayList; import java.util.Collection; public class Connect{ @SuppressWarnings("finally") public static Connection getCon(){ Connection con=null; //驱动程序名 String driver = "com.mysql.jdbc.Driver"; //URL指定要访问的数据库名test String url="jdbc:mysql://localhost:3306/hotel_manage"; //Mysql配置时的用户名 String user = "root"; //Mysql配置时的密码 String passwd="liujianjy"; try{ Class.forName(driver); con = DriverManager.getConnection(url, user, passwd); }catch(ClassNotFoundException e){ System.out.println("Sorry,can`t find the Driver!"); printStackTrace(); }catch(Exception e){ System.out.println("出错!!!"); printStackTrace(); }finally{ return con; } } public static void close2(Connection con , Statement stat){ try { stat.close(); } catch (SQLException e) { printStackTrace(); } try { con.close(); } catch (SQLException e) { printStackTrace(); } } public static void close3(ResultSet rs,Connection con , Statement stat){ try { rs.close(); } catch (SQLException e) { printStackTrace(); } try { stat.close(); } catch (SQLException e) { printStackTrace(); } try { con.close(); } catch (SQLException e) { printStackTrace(); } } public static void close3p(ResultSet rs,Connection con , PreparedStatement pstat){ try { rs.close(); } catch (SQLException e) { printStackTrace(); } try { pstat.close(); } catch (SQLException e) { printStackTrace(); } try { con.close(); } catch (SQLException e) { printStackTrace(); } } }

房间事物设计

  • RoomBean.java

c++ package com.hotel.bean; public class RoomBean { private int RoomId; private int RoomSize; private int RoomPrice; private int IsEmp; private int Deposit; public int getRoomId() { return RoomId; } public void setRoomId(int roomId) { RoomId = roomId; } public int getRoomSize() { return RoomSize; } public void setRoomSize(int roomSize) { RoomSize = roomSize; } public int getRoomPrice() { return RoomPrice; } public void setRoomPrice(int roomPrice) { RoomPrice = roomPrice; } public int getIsEmp() { return IsEmp; } public void setIsEmp(int isEmp) { IsEmp = isEmp; } public int getDeposit() { return Deposit; } public void setDeposit(int deposit) { Deposit = deposit; } }

  • RoomManage.java

```java package com.hotel.dao; import com.hotel.bean.RoomBean; import com.hotel.bean.VipcardBean;

import java.sql.*; import java.util.ArrayList; import java.util.Collection;

public class RoomManage {

public static boolean insert(int RoomId, int RoomSize,float RoomPrice,int IsEmp,int Deposit){
    boolean issuc=false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("insert into room values("+RoomId
                +","+RoomSize+","+RoomPrice+","+IsEmp+","+Deposit+")");
        if(count>0)
            issuc=true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("添加数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static boolean delete(int RoomId){
    boolean issuc = false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("delete from room where id="+RoomId);
        if(count>0)
            issuc = true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("删除数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static boolean update(int RoomId, int RoomSize,float RoomPrice,int IsEmp,int Deposit){
    boolean issuc = false;

// Collection list = new ArrayList(); Connection con = Connect.getCon(); Statement stat =null;

    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("update room set RoomSize="
                +RoomSize+",RoomPrice="+RoomPrice+",IsEmp="+IsEmp+",Deposit="+Deposit+" where RoomId="+RoomId);
        if(count>0)
            issuc = true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("更新数据出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static boolean updateIsEmp(int RoomId,int IsEmp){
    boolean issuc = false;

// Collection list = new ArrayList(); Connection con = Connect.getCon(); Statement stat =null;

    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("update room set IsEmp = "+ IsEmp+" where RoomId="+RoomId);
        if(count>0)
            issuc = true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("更新数据出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static Collection selectRoom(){
    Collection list = new ArrayList();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from room";
        rs = stat.executeQuery(sql);
        while(rs.next()){
            RoomBean room = new RoomBean();
            room.setRoomId(rs.getInt("RoomId"));
            room.setRoomSize(rs.getInt("RoomSize"));
            room.setRoomPrice(rs.getInt("RoomPrice"));
            room.setIsEmp(rs.getInt("IsEmp"));
            room.setDeposit(rs.getInt("Deposit"));
            list.add(room);
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return list;
}

public static Collection selectByRoomSize(int RoomSize){
    Collection list = new ArrayList();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from room where RoomSize = "+RoomSize+" and IsEmp != 0";
        rs = stat.executeQuery(sql);
        while(rs.next()){

// RoomBean room = new RoomBean(); // room.setRoomId(rs.getInt("RoomId")); // room.setRoomSize(rs.getInt("RoomSize")); // room.setRoomPrice(rs.getInt("RoomPrice")); // room.setIsEmp(rs.getInt("IsEmp")); // room.setDeposit(rs.getInt("Deposit")); list.add(rs.getInt("RoomId")); } }catch(SQLException e){ e.printStackTrace(); System.out.println("查询信息出错!!!"); }catch(Exception e){ e.printStackTrace(); } finally{ System.out.println("数据库成功获取!!"); Connect.close3(rs, con, stat); } return list; }

public static RoomBean selectByRoomId(int RoomId){
    RoomBean room = new RoomBean();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from room where RoomId = "+RoomId;
        rs = stat.executeQuery(sql);
        while(rs.next()){

            room.setRoomId(rs.getInt("RoomId"));
            room.setRoomSize(rs.getInt("RoomSize"));
            room.setRoomPrice(rs.getInt("RoomPrice"));
            room.setIsEmp(rs.getInt("IsEmp"));
            room.setDeposit(rs.getInt("Deposit"));              
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return room;
}

} ```

VIP事物管理

  • VipcardBean.java

```c++ package com.hotel.bean;

import java.sql.Timestamp;

public class VipcardBean {

private String VIPId;
private String VIPName;
private String VIPSex;
private String VIPIDCard;
private String VIPPhone;
private int VIPLevel;
private Timestamp HandTime;
public Timestamp getHandTime() {
    return HandTime;
}
public void setHandTime(Timestamp handTime) {
    HandTime = handTime;
}
public String getVIPId() {
    return VIPId;
}
public void setVIPId(String vIPId) {
    VIPId = vIPId;
}
public String getVIPName() {
    return VIPName;
}
public void setVIPName(String vIPName) {
    VIPName = vIPName;
}
public String getVIPSex() {
    return VIPSex;
}
public void setVIPSex(String vIPSex) {
    VIPSex = vIPSex;
}
public String getVIPIDCard() {
    return VIPIDCard;
}
public void setVIPIDCard(String vIPIDCard) {
    VIPIDCard = vIPIDCard;
}
public String getVIPPhone() {
    return VIPPhone;
}
public void setVIPPhone(String vIPPhone) {
    VIPPhone = vIPPhone;
}
public int getVIPLevel() {
    return VIPLevel;
}
public void setVIPLevel(int vIPLevel) {
    VIPLevel = vIPLevel;
}

} VipcardManage.java package com.hotel.dao; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Collection;

import com.hotel.bean.VipcardBean;

public class VipcardManage {

@SuppressWarnings("null")
public static boolean insert(String VIPId, String VIPName,String VIPSex,String VIPIDCard,String VIPPhone,int VIPLevel){
    boolean issuc=false;
    Connection con = Connect.getCon();
    Statement stat =null;
    int count=0;
    try{
        stat = con.createStatement();

        String sql="insert into vipcard values('"+VIPId
                +"','"+VIPName+"','"+VIPSex+"','"+VIPIDCard+"','"+VIPPhone+"',"+VIPLevel+", null "+")";
        count=stat.executeUpdate(sql);
        if(count>0)
            issuc=true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("添加数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static Collection select(){
    Collection list = new ArrayList();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from vipcard";
        rs = stat.executeQuery(sql);
        while(rs.next()){
            VipcardBean vipcard = new VipcardBean();
            vipcard.setVIPId(rs.getString("VIPId"));
            vipcard.setVIPName(rs.getString("VIPName"));
            vipcard.setVIPSex(rs.getString("VIPSex"));
            vipcard.setVIPIDCard(rs.getString("VIPIDCard"));
            vipcard.setVIPPhone(rs.getString("VIPPhone"));
            vipcard.setVIPLevel(rs.getInt("VIPLevel"));
            vipcard.setHandTime(rs.getTimestamp("HandTime"));
            list.add(vipcard);
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return list;
}

public static VipcardBean selectByVIPId(int VIPId){
    VipcardBean vipcard = new VipcardBean();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from vipcard where VIPId= '"+VIPId+"'";
        rs = stat.executeQuery(sql);
        while(rs.next()){
            vipcard.setVIPId(rs.getString("VIPId"));
            vipcard.setVIPName(rs.getString("VIPName"));
            vipcard.setVIPSex(rs.getString("VIPSex"));
            vipcard.setVIPIDCard(rs.getString("VIPIDCard"));
            vipcard.setVIPPhone(rs.getString("VIPPhone"));
            vipcard.setVIPLevel(rs.getInt("VIPLevel"));
            vipcard.setHandTime(rs.getTimestamp("HandTime"));
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return vipcard;
}

public static int selectVIPLevel(String VIPId){
    int VIPLevel = 0;
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select VIPLevel from vipcard where VIPId = "+VIPId;
        rs = stat.executeQuery(sql);
        while(rs.next()){
            VIPLevel = rs.getInt("VIPLevel"); 
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return VIPLevel;
}


public static boolean delete(int VIPId){
    boolean issuc = false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    int count=0;
    try{
        stat = con.createStatement();   
        count=stat.executeUpdate("delete from vipcard where VIPId ='"+VIPId+"'");
        if(count>0)
            issuc = true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("删除数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static boolean update(String VIPName,String VIPSex,String VIPIDCard,String VIPPhone,int VIPLevel,String VIPId){
    boolean issuc = false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    int count=0;
    try{
        stat = con.createStatement();   
        count=stat.executeUpdate("update vipcard set VIPName='"
                +VIPName+"',VIPSex='"+VIPSex+"',VIPIDCard='"+VIPIDCard+"',VIPPhone='"+VIPPhone+"',VIPLevel="+VIPLevel+" where VIPId ='"+VIPId+"'");
        System.out.println(count);
        if(count>0)
            issuc = true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("数据库修改失败!!!");
    }catch(Exception e){
        System.out.println("数据库修改失败!!!");
        e.printStackTrace();
    }
    finally{
        Connect.close2(con, stat);
    }

    return issuc;
}

} ```

客户事物管理

  • CustomerBean.java

```c++ package com.hotel.bean;

public class CustomerBean {

private int OrderNum;
private String CName;
private String CSex;
private String CIDCard;
private int RoomId;
private String CPhone;
private int IsVip;
private String StartTime;
public CustomerBean(){}
public int getOrderNum() {
    return OrderNum;
}
public void setOrderNum(int orderNum) {
    OrderNum = orderNum;
}
public String getCName() {
    return CName;
}
public void setCName(String cName) {
    CName = cName;
}
public String getCSex() {
    return CSex;
}
public void setCSex(String cSex) {
    CSex = cSex;
}
public String getCIDCard() {
    return CIDCard;
}
public void setCIDCard(String cIDCard) {
    CIDCard = cIDCard;
}
public int getRoomId() {
    return RoomId;
}
public void setRoomId(int roomId) {
    RoomId = roomId;
}
public String getCPhone() {
    return CPhone;
}
public void setCPhone(String cPhone) {
    CPhone = cPhone;
}
public int getIsVip() {
    return IsVip;
}
public void setIsVip(int isVip) {
    IsVip = isVip;
}
public String getStartTime() {
    return StartTime;
}
public void setStartTime(String startTime) {
    StartTime = startTime;
}

} CustomerManage.java package com.hotel.dao; import com.hotel.bean.RoomBean; import com.hotel.bean.CustomerBean;

import java.sql. ; import java.util.ArrayList; import java.util.Collection; / * private int OrderNum; private String CName; private String CSex; private int CIDCard; private int RoomId; private int CPhone; private int IsVip; private String StartTime; */ public class CustomerManage {

public static boolean insert(int OrderNum, String CName,String CSex, 
            String CIDCard,int RoomId,String CPhone,int IsVip,String StartTime){
    boolean issuc=false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("insert into customer values("+OrderNum
                +",'"+CName+"','"+CSex+"','"+CIDCard+"',"+RoomId+",'"+CPhone+"',"+IsVip+",'"+StartTime+"')");
        if(count>0)
            issuc=true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("添加顾客错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static boolean delete(int OrderNum){
    boolean issuc = false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("delete from customer where OrderNum = "+OrderNum);
        if(count>0)
            issuc = true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("根据订单号删除顾客数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static boolean update(String CName,String CSex,String CIDCard ,int RoomId,String CPhone){
    boolean issuc = false;
    Connection con =  Connect.getCon();
    Statement stat =null;

    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("update customer set CName='"
                +CName+"',CSex='"+CSex+"',RoomId="+RoomId+",CPhone='"+CPhone
                +"' where CIDCard='"+CIDCard+"'");
        if(count>0)
            issuc = true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("换房更新数据出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static Collection selectCustomer(){
    Collection list = new ArrayList();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from customer ORDER BY OrderNum";
        rs = stat.executeQuery(sql);
        while(rs.next()){
            CustomerBean customer = new CustomerBean();
            customer.setOrderNum(rs.getInt("OrderNum"));
            customer.setCName(rs.getString("CName"));
            customer.setCSex(rs.getString("CSex"));
            customer.setCIDCard(rs.getString("CIDCard"));
            customer.setRoomId(rs.getInt("RoomId"));
            customer.setCPhone(rs.getString("CPhone"));
            customer.setIsVip(rs.getInt("IsVip"));
            customer.setStartTime(rs.getString("StartTime"));
            list.add(customer);
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return list;
}

public static Collection selectByRoomId(int RoomId){
    Collection list = new ArrayList();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from customer where RoomId = "+RoomId;
        rs = stat.executeQuery(sql);
        while(rs.next()){
            CustomerBean customer = new CustomerBean();
            customer.setOrderNum(rs.getInt("OrderNum"));
            customer.setCName(rs.getString("CName"));
            customer.setCSex(rs.getString("CSex"));
            customer.setCIDCard(rs.getString("CIDCard"));
            customer.setRoomId(rs.getInt("RoomId"));
            customer.setCPhone(rs.getString("CPhone"));
            customer.setIsVip(rs.getInt("IsVip"));
            customer.setStartTime(rs.getString("StartTime"));
            list.add(customer);
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return list;
}

public static CustomerBean selectByCIDCard(String CIDCard){
    CustomerBean customer = new CustomerBean();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from customer where CIDCard = '"+CIDCard+"'";
        rs = stat.executeQuery(sql);
        while(rs.next()){

            customer.setOrderNum(rs.getInt("OrderNum"));
            customer.setCName(rs.getString("CName"));
            customer.setCSex(rs.getString("CSex"));
            customer.setCIDCard(rs.getString("CIDCard"));
            customer.setRoomId(rs.getInt("RoomId"));
            customer.setCPhone(rs.getString("CPhone"));
            customer.setIsVip(rs.getInt("IsVip"));
            customer.setStartTime(rs.getString("StartTime"));
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return customer;
}

public static int selectIsVIP(int OrderNum){
    int IsVIP =0;
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select distinct IsVIP from customer where OrderNum = "+OrderNum;
        rs = stat.executeQuery(sql);
        while(rs.next()){
            IsVIP = rs.getInt("IsVIP");
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return IsVIP;
}

public static Collection selectRoom(int OrderNum){
    Collection list = new ArrayList();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select distinct RoomId from customer where OrderNum = "+OrderNum;
        rs = stat.executeQuery(sql);
        while(rs.next()){
            list.add(rs.getInt("RoomId"));
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return list;
}

} ```

挂单事物处理

GuaDanBean.java

```c++ package com.hotel.bean;

import java.sql.Timestamp;

public class GuaDanBean {

private int OrderNum;
private float price;
private Timestamp LeaveTime;
public Timestamp getLeaveTime() {
    return LeaveTime;
}
public void setLeaveTime(Timestamp timestamp) {
    LeaveTime = timestamp;
}
public int getOrderNum() {
    return OrderNum;
}
public void setOrderNum(int orderNum) {
    OrderNum = orderNum;
}
public float getPrice() {
    return price;
}
public void setPrice(float price) {
    this.price = price;
}

} ```

GuaDanManage.java

```java package com.hotel.dao;

import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Collection;

import com.hotel.bean.GuaDanBean; import com.hotel.bean.HasPayedBean;

public class GuaDanManage {

public static boolean insert(int OrderNum, float price){
    boolean issuc=false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("insert into leavewithoutpay values("+OrderNum
                +","+price+",null )");
        if(count>0)
            issuc=true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("添加数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static boolean delete(int OrderNum){
    boolean issuc = false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("delete from leavewithoutpay where OrderNum="+OrderNum);
        if(count>0)
            issuc = true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("删除数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}


public static Collection select(){
    Collection list = new ArrayList();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from leavewithoutpay";
        rs = stat.executeQuery(sql);
        while(rs.next()){
            GuaDanBean room = new GuaDanBean();
            room.setOrderNum(rs.getInt("OrderNum"));
            room.setPrice(rs.getFloat("Price"));
            room.setLeaveTime(rs.getTimestamp("LeaveTime"));
            list.add(room);
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return list;
}

public static GuaDanBean selectByOrderNum(int OrderNum){
    GuaDanBean haspayed = new GuaDanBean();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from leavewithoutpay where OrderNum = "+OrderNum;
        rs = stat.executeQuery(sql);
        while(rs.next()){
            haspayed.setOrderNum(rs.getInt("OrderNum"));
            haspayed.setPrice(rs.getFloat("Price"));
            haspayed.setLeaveTime(rs.getTimestamp("LeaveTime"));
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return haspayed;
}

} ```

历史账单事物处理

  • HasPayedBean.java

```c++ package com.hotel.bean;

import java.sql.Timestamp;

public class HasPayedBean {

private int OrderNum;
private float price;
private Timestamp PayedTime;
public Timestamp getLeaveTime() {
    return PayedTime;
}
public void setLeaveTime(Timestamp payedTime) {
    PayedTime = payedTime;
}
public int getOrderNum() {
    return OrderNum;
}
public void setOrderNum(int orderNum) {
    OrderNum = orderNum;
}
public float getPrice() {
    return price;
}
public void setPrice(float price) {
    this.price = price;
}

} ```

HasPayedManage.java

```java package com.hotel.dao;

import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Collection;

import com.hotel.bean.HasPayedBean;

public class HasPayedManage {

public static boolean insert(int OrderNum, float price){
    boolean issuc=false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("insert into haspayed values("+OrderNum
                +","+price+",null )");
        if(count>0)
            issuc=true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("添加数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}

public static boolean delete(int OrderNum){
    boolean issuc = false;
    Connection con =  Connect.getCon();
    Statement stat =null;
    try{
        stat = con.createStatement();   
        int count=stat.executeUpdate("delete from haspayed where OrderNum="+OrderNum);
        if(count>0)
            issuc = true;

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("删除数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close2(con, stat);
    }

    return issuc;
}


public static Collection select(){
    Collection list = new ArrayList();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "SELECT * FROM haspayed";
        rs = stat.executeQuery(sql);
        while(rs.next()){
            HasPayedBean room = new HasPayedBean();
            room.setOrderNum(rs.getInt("OrderNum"));
            room.setPrice(rs.getFloat("Price"));
            room.setLeaveTime(rs.getTimestamp("PayedTime"));
            list.add(room);
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return list;
}

public static HasPayedBean selectByOrderNum(int OrderNum){
    HasPayedBean haspayed = new HasPayedBean();
    Connection con =  Connect.getCon();
    Statement stat =null;
    ResultSet rs = null;
    try{
        stat = con.createStatement();   
        String sql = "select * from haspayed where OrderNum = "+OrderNum;
        rs = stat.executeQuery(sql);
        while(rs.next()){
            haspayed.setOrderNum(rs.getInt("OrderNum"));
            haspayed.setPrice(rs.getFloat("Price"));
            haspayed.setPrice(rs.getFloat("PayedTime"));
        }
    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("查询信息出错!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3(rs, con, stat);
    }
    return haspayed;
}

} ```

VIP后台与前端事物处理

```c++ package com.Vip.registration;

import java.io.IOException; import java.io.PrintWriter; import java.sql.SQLException;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.dao.Connect; import com.hotel.dao.VipcardManage;

@WebServlet(name="VipChange",urlPatterns={"/VipChange"}) public class VipChange extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();

        //1.获取html页面中的input
        String VIPId = req.getParameter("VIPId");

// System.out.println(VIPId); String VIPName = req.getParameter("VIPName"); // System.out.println(VIPName); String VIPSex = req.getParameter("VIPSex"); String VIPIDCard = req.getParameter("VIPIDCard"); String VIPPhone = req.getParameter("VIPPhone"); int VIPLevel = Integer.parseInt(req.getParameter("VIPLevel")); // System.out.println(username); // System.out.println(password);

        if(VipcardManage.update(VIPName, VIPSex, VIPIDCard, VIPPhone, VIPLevel,VIPId) == true){
            resp.sendRedirect("/HotelManagement/VIPInfo.jsp");
        }else{
            out.print("sorry ! Your VIP update is not successful!");
        }


    }

}

package com.Vip.registration;

import java.io.IOException; import java.io.PrintWriter; import java.sql.SQLException;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.dao.Connect; import com.hotel.dao.VipcardManage;

@WebServlet(name="VipRegistration",urlPatterns={"/VipRegistration"}) public class VipRegistration extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();

        //1.获取html页面中的input
        String VIPId = req.getParameter("VIPId");
        String VIPName = req.getParameter("VIPName");
        String VIPSex = req.getParameter("VIPSex");
        String VIPIDCard = req.getParameter("VIPIDCard");
        String VIPPhone = req.getParameter("VIPPhone");
        int VIPLevel = Integer.parseInt(req.getParameter("VIPLevel"));

// System.out.println(username); // System.out.println(password);

        if(VipcardManage.insert(VIPId, VIPName, VIPSex, VIPIDCard, VIPPhone, VIPLevel) == true){
            resp.sendRedirect("/HotelManagement/VIPInfo.jsp");
        }else{
            out.print("sorry ! Your VIP registration is not successful!");
        }


    }

}

```

管理员登录事物处理

```c++ package com.login.check; import com.hotel.dao.*;

import java.sql.*; import java.io.IOException; import java.io.PrintWriter;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

@WebServlet(name="LoginCheck",urlPatterns={"/LoginCheck"}) public class LoginCheck extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    doPost(request,response);
}

public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    //1.获取html页面中的username、password
    String username = req.getParameter("Name");
    String password = req.getParameter("password");

// System.out.println(username); // System.out.println(password); //2.获取数据库中的username、password //声明Connection对象 Connection con = Connect.getCon(); PreparedStatement pstat =null; ResultSet result =null; try{ resp.setContentType("text/html"); PrintWriter out = resp.getWriter();

            //建表

// pstat = con.prepareStatement("create table user (" // + "id int not null primary key auto_increment," // + "username varchar(20) not null," // + "password varchar(20) not null)"); // pstat.execute();

            //插入记录

// pstat = con.prepareStatement("insert into user values(?,?,?)"); // pstat.setInt(1, 1); // pstat.setString(2, "david"); // pstat.setString(3,"liujianjy"); // pstat.executeUpdate();

            //获取记录
        pstat = con.prepareStatement("select count(*) from Manager where Name=? and Password=?");
        pstat.setString(1, username);
        pstat.setString(2, password);
        result = pstat.executeQuery();

        //3.对比,返回结果
        if(result.next()){
            int i = result.getInt(1);
            if(i>0){

// out.print("hello ,"+ username); resp.sendRedirect("/HotelManagement/Manage.html"); }else{ out.print("sorry ,"+username+"! Your name or password is incorrect!"); } }

    }catch(SQLException e){
        e.printStackTrace();
        System.out.println("添加数据错误!!!");
    }catch(Exception e){
        e.printStackTrace();
    }
    finally{
        System.out.println("数据库成功获取!!");
        Connect.close3p(result,con, pstat);
    }

}

}

换房事物处理 package com.hotel.roomchange;

import java.io.IOException; import java.io.PrintWriter;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.dao.RoomManage;

@WebServlet(name="RoomChange",urlPatterns={"/RoomChange"}) public class RoomChange extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();

        //1.获取html页面中的input
        int RoomId = Integer.parseInt(req.getParameter("RoomId"));

// System.out.println(VIPId); int RoomSize = Integer.parseInt(req.getParameter("RoomSize")); // System.out.println(VIPName); String RoomPrices = req.getParameter("RoomPrice"); float RoomPrice = Float.parseFloat(RoomPrices); int IsEmp = Integer.parseInt(req.getParameter("IsEmp")); int Deposit = Integer.parseInt(req.getParameter("Deposit")); // System.out.println(username); // System.out.println(password);

        if(RoomManage.update(RoomId, RoomSize, RoomPrice, IsEmp, Deposit) == true){
            resp.sendRedirect("/HotelManagement/RoomInfo.jsp");
        }else{
            out.print("sorry ! Your Room update is not successful!");
        }


    }

}

```

换房事物处理

```c++ package com.hotel.registration;

import java.io.IOException;

import java.io.PrintWriter; import java.util.ArrayList;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage;

@WebServlet(name="ChangeRoom",urlPatterns={"/ChangeRoom"})
public class ChangeRoom extends HttpServlet{

        public void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            doPost(request,response);
        }

        public void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {
            req.setCharacterEncoding("UTF-8");
            resp.setContentType("text/html;charset=utf-8");
            PrintWriter out = resp.getWriter();

            //1.获取html页面中的input
            String CName = req.getParameter("CName");

// System.out.println(VIPId);

            String CSex = req.getParameter("CSex");
            String CIDCard = req.getParameter("CIDCard");
            int RoomId = Integer.parseInt(req.getParameter("RoomId"));
            int nRoomId = Integer.parseInt(req.getParameter("nRoomId"));
            String CPhone = req.getParameter("CPhone");


            if(CustomerManage.update(CName, CSex, CIDCard, nRoomId,CPhone) == true){
                ArrayList list = (ArrayList)CustomerManage.selectByRoomId(RoomId);
                if(list.size()==0){
                    RoomManage.updateIsEmp(RoomId, RoomManage.selectByRoomId(RoomId).getRoomSize());
                }
                RoomManage.updateIsEmp(nRoomId, 0);
                resp.sendRedirect("/HotelManagement/CustomerInfo.jsp");
            }else{
                out.print("sorry ! Your VIP update is not successful!");
            }


        }

    }

package com.hotel.registration;

import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Random;

public class CreateRan {

/** 
 * 生成随机订单号:当前年月日时分秒+五位随机数 
 *  
 * @return 
 */  
public static int CreateOrderNum(){

        SimpleDateFormat simpleDateFormat;

        simpleDateFormat = new SimpleDateFormat("MMdd");

        Date date = new Date();

        String str = simpleDateFormat.format(date);

        Random random = new Random();

        int rannum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000;// 获取5位随机数

        return Integer.parseInt(rannum + str);// 当前时间

}

public  static String CreateDate(){
    SimpleDateFormat simpleDateFormat;

    simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    Date date = new Date();

    String str = simpleDateFormat.format(date);  
    return str;
}

}

package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage;

@WebServlet(name="GroupFinish",urlPatterns={"/GroupFinish"}) public class GroupFinish extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    doPost(request,response);
}

public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    req.setCharacterEncoding("UTF-8");
    resp.setContentType("text/html;charset=UTF-8");
    PrintWriter out = resp.getWriter();

    int OrderNum =Integer.parseInt(req.getParameter("GId"));
    String name = req.getParameter("name");
//  String Cname = new String(name.getBytes(), "utf-8");
//  System.out.println(name);
    String sex = req.getParameter("sex");
    String IDCard = req.getParameter("IDCard");
    int roomnum = Integer.parseInt(req.getParameter("roomnum"));
    String phone = req.getParameter("phone");

    String StartTime = CreateRan.CreateDate();
    RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum);
    int IsEmp = room.getIsEmp();
    if(IsEmp>0){
        //插入住户信息
        CustomerManage.insert(OrderNum, name, sex, IDCard, roomnum, phone, 0, StartTime);
        //设置IsEmp-1
        RoomManage.updateIsEmp(roomnum,0);
    }else{
        resp.sendRedirect("/HotelManagement/errors/error.html");
        return ;
    }

    int dep=0;
    ArrayList list = (ArrayList)CustomerManage.selectRoom(OrderNum);
    Iterator it = list.iterator();
    while(it.hasNext()){
        int Room =(Integer) it.next();


        dep += RoomManage.selectByRoomId(Room).getDeposit();
    }
    out.print("<h3>您一共需要缴纳"+dep+"元押金!!</h3>");

// resp.sendRedirect("/HotelManagement/Group.jsp");

}

}

package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage;

@WebServlet(name="GroupHandle",urlPatterns={"/GroupHandle"}) public class GroupHandle extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    doPost(request,response);
}

public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    req.setCharacterEncoding("UTF-8");
    resp.setContentType("text/html;charset=UTF-8");
    PrintWriter out = resp.getWriter();

    int OrderNum =Integer.parseInt(req.getParameter("GId"));
    String name = req.getParameter("name");
//  String Cname = new String(name.getBytes(), "utf-8");
//  System.out.println(name);
    String sex = req.getParameter("sex");
    String IDCard = req.getParameter("IDCard");
    int roomnum = Integer.parseInt(req.getParameter("roomnum"));
    String phone = req.getParameter("phone");

    String StartTime = CreateRan.CreateDate();
    RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum);
    int IsEmp = room.getIsEmp();
    if(IsEmp>0){
        //插入住户信息
        CustomerManage.insert(OrderNum, name, sex, IDCard, roomnum, phone, 0, StartTime);
        //设置IsEmp-1
        RoomManage.updateIsEmp(roomnum,IsEmp-1);
    }else{
        resp.sendRedirect("/HotelManagement/errors/error.html");
        return ;
    }


    resp.sendRedirect("/HotelManagement/Group.jsp");

}

}

package com.hotel.registration;

import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; @WebServlet(name="individualFinish",urlPatterns={"/individualFinish"}) public class individualFinish extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    doPost(request,response);
}

public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    //1.添加customer数据库,更改room数据库的IsEmp=0
    req.setCharacterEncoding("UTF-8");
    resp.setContentType("text/html;charset=UTF-8");
    PrintWriter out = resp.getWriter();

    String name = req.getParameter("name");
//  String Cname = new String(name.getBytes(), "utf-8");
//  System.out.println(name);
    String sex = req.getParameter("sex");
    String IDCard = req.getParameter("IDCard");
    int roomnum = Integer.parseInt(req.getParameter("roomnum"));
    String phone = req.getParameter("phone");
    int OrderNum = 0;
    ArrayList list = (ArrayList)CustomerManage.selectByRoomId(roomnum);
    if(list.size()==0){
        OrderNum = CreateRan.CreateOrderNum();
        System.out.println(OrderNum);
    }else{
        CustomerBean customer = (CustomerBean) list.get(0);
        OrderNum = customer.getOrderNum();
    }
    String StartTime = CreateRan.CreateDate();
    RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum);
    int IsEmp = room.getIsEmp();
    if(IsEmp>0){
        //插入住户信息
        CustomerManage.insert(OrderNum, name, sex, IDCard, roomnum, phone, 0, StartTime);
        //设置IsEmp=0
        RoomManage.updateIsEmp(roomnum,0);
    }else{
        resp.sendRedirect("/HotelManagement/errors/error.html");
        return ;
    }


    int dep=0;
    ArrayList list1 = (ArrayList)CustomerManage.selectRoom(OrderNum);
    Iterator it = list1.iterator();
    while(it.hasNext()){
        int Room =(Integer) it.next();


        dep += RoomManage.selectByRoomId(Room).getDeposit();
    }
    out.print("<h3>您一共需要缴纳"+dep+"元押金!!</h3>");



}

}

package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage;

@WebServlet(name="individualHandle",urlPatterns={"/individualHandle"}) public class individualHandle extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    doPost(request,response);
}

public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    req.setCharacterEncoding("UTF-8");
    resp.setContentType("text/html;charset=UTF-8");
    PrintWriter out = resp.getWriter();
    //1.获取html页面中的username、password
    String name = req.getParameter("name");
//  String Cname = new String(name.getBytes(), "utf-8");
    System.out.println(name);
    String sex = req.getParameter("sex");
    String IDCard = req.getParameter("IDCard");
    int roomnum = Integer.parseInt(req.getParameter("roomnum"));
    String phone = req.getParameter("phone");
    int OrderNum = 0;
    ArrayList list = (ArrayList)CustomerManage.selectByRoomId(roomnum);
    if(list.size()==0){
        OrderNum = CreateRan.CreateOrderNum();
        System.out.println(OrderNum);
    }else{
        CustomerBean customer = (CustomerBean) list.get(0);
        OrderNum = customer.getOrderNum();
    }
    String StartTime = CreateRan.CreateDate();
    RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum);
    int IsEmp = room.getIsEmp();
    if(IsEmp>0){
        //插入住户信息
        CustomerManage.insert(OrderNum, name, sex, IDCard, roomnum, phone, 0, StartTime);
        //设置IsEmp-1
        RoomManage.updateIsEmp(roomnum,IsEmp-1);
    }else{
        resp.sendRedirect("/HotelManagement/errors/error.html");
        return ;
    }


    resp.sendRedirect("/HotelManagement/Individual.jsp");

}

}

package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; import com.hotel.dao.VipcardManage;

@WebServlet(name="SGroupFinish",urlPatterns={"/SGroupFinish"}) public class SGroupFinish extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter out = resp.getWriter();
        //1.获取html页面中的input
        int OrderNum =Integer.parseInt(req.getParameter("SGId"));
        String name = req.getParameter("name");

        String sex = req.getParameter("sex");
        String IdCard = req.getParameter("IdCard"); //身份证号
        String IDCard = req.getParameter("VIPId");  //会员号
        int ok = VipcardManage.selectVIPLevel(IDCard);
        int roomnum = Integer.parseInt(req.getParameter("roomnum"));
        String phone = req.getParameter("phone");

        if( ok==2){

            String StartTime = CreateRan.CreateDate();
            RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum);
            int IsEmp = room.getIsEmp();
            if(IsEmp>0){
                //插入住户信息
                CustomerManage.insert(OrderNum, name, sex, IdCard, roomnum, phone, 1, StartTime);
                //设置IsEmp=0
                RoomManage.updateIsEmp(roomnum,0);
            }else{
                resp.sendRedirect("/HotelManagement/errors/error.html");
                return ;
            }

            int dep=0;
            ArrayList list2 = (ArrayList)CustomerManage.selectRoom(OrderNum);
            Iterator it = list2.iterator();
            while(it.hasNext()){
                int Room =(Integer) it.next();


                dep += RoomManage.selectByRoomId(Room).getDeposit();
            }
            out.print("<h3>您一共需要缴纳"+dep+"元押金!!</h3>");
        }else{
            System.out.println("IDCard为空!!!!!!!!!!!!!!!!!!");
            resp.sendRedirect("/HotelManagement/errors/errorVIP.html");
        }



    }

}

package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; import com.hotel.dao.VipcardManage;

@WebServlet(name="SGroupHandle",urlPatterns={"/SGroupHandle"}) public class SGroupHandle extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter out = resp.getWriter();
        //1.获取html页面中的input
        int OrderNum =Integer.parseInt(req.getParameter("SGId"));
        String name = req.getParameter("name");

        String sex = req.getParameter("sex");
        String IdCard = req.getParameter("IdCard"); //身份证号
        String IDCard = req.getParameter("VIPId");  //会员号
        int ok = VipcardManage.selectVIPLevel(IDCard);
        int roomnum = Integer.parseInt(req.getParameter("roomnum"));
        String phone = req.getParameter("phone");

        if( ok==2){

            String StartTime = CreateRan.CreateDate();
            RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum);
            int IsEmp = room.getIsEmp();
            if(IsEmp>0){
                //插入住户信息
                CustomerManage.insert(OrderNum, name, sex, IdCard, roomnum, phone, 1, StartTime);
                //设置IsEmp-1
                RoomManage.updateIsEmp(roomnum,IsEmp-1);
            }else{
                resp.sendRedirect("/HotelManagement/errors/error.html");
                return ;
            }

            resp.sendRedirect("/HotelManagement/SuperGroup.jsp");
        }else{
            System.out.println("IDCard为空!!!!!!!!!!!!!!!!!!");
            resp.sendRedirect("/HotelManagement/errors/errorVIP.html");
        }



    }

}

package com.hotel.registration;

import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; import com.hotel.dao.VipcardManage;

@WebServlet(name="SIndividualFinish",urlPatterns={"/SIndividualFinish"}) public class SIndividualFinish extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter out = resp.getWriter();
        //1.获取html页面中的input
        String name = req.getParameter("name");

        String sex = req.getParameter("sex");
        String VIPIDCard = req.getParameter("vipidcard");
        String IDCard = req.getParameter("VIPId");
        int ok = VipcardManage.selectVIPLevel(IDCard);
        int roomnum = Integer.parseInt(req.getParameter("roomnum"));
        String phone = req.getParameter("phone");
        int OrderNum = 0;
        if(ok ==1 ||ok==2){

            ArrayList list = (ArrayList)CustomerManage.selectByRoomId(roomnum);
            if(list.size()==0){
                OrderNum = CreateRan.CreateOrderNum();
                System.out.println(OrderNum);
            }else{
                CustomerBean customer = (CustomerBean) list.get(0);
                OrderNum = customer.getOrderNum();
            }
            String StartTime = CreateRan.CreateDate();
            RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum);
            int IsEmp = room.getIsEmp();
            if(IsEmp>0){
                //插入住户信息
                CustomerManage.insert(OrderNum, name, sex, VIPIDCard, roomnum, phone, 1, StartTime);
                //设置IsEmp-1
                RoomManage.updateIsEmp(roomnum,0);
            }else{
                resp.sendRedirect("/HotelManagement/errors/error.html");
                return ;
            }

            int dep=0;
            ArrayList list3 = (ArrayList)CustomerManage.selectRoom(OrderNum);
            Iterator it = list3.iterator();
            while(it.hasNext()){
                int Room =(Integer) it.next();


                dep += RoomManage.selectByRoomId(Room).getDeposit();
            }
            out.print("<h3>您一共需要缴纳"+dep+"元押金!!</h3>");
        }else{
            System.out.println("IDCard为空!!!!!!!!!!!!!!!!!!");
            resp.sendRedirect("/HotelManagement/errors/errorVIP.html");
        }

    }

}

package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; import com.hotel.dao.VipcardManage;

@WebServlet(name="SIndividualHandle",urlPatterns={"/SIndividualHandle"}) public class SIndividualHandle extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter out = resp.getWriter();
        //1.获取html页面中的input
        String name = req.getParameter("name");

        String sex = req.getParameter("sex");
        String VIPIDCard = req.getParameter("vipidcard");
        String IDCard = req.getParameter("VIPId");
        int ok = VipcardManage.selectVIPLevel(IDCard);
        int roomnum = Integer.parseInt(req.getParameter("roomnum"));
        String phone = req.getParameter("phone");
        int OrderNum = 0;
        if(ok == 1 ||  ok==2){

            ArrayList list = (ArrayList)CustomerManage.selectByRoomId(roomnum);
            if(list.size()==0){
                OrderNum = CreateRan.CreateOrderNum();
                System.out.println(OrderNum);
            }else{
                CustomerBean customer = (CustomerBean) list.get(0);
                OrderNum = customer.getOrderNum();
            }
            String StartTime = CreateRan.CreateDate();
            RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum);
            int IsEmp = room.getIsEmp();
            if(IsEmp>0){
                //插入住户信息
                CustomerManage.insert(OrderNum, name, sex, VIPIDCard, roomnum, phone, 1, StartTime);
                //设置IsEmp-1
                RoomManage.updateIsEmp(roomnum,IsEmp-1);
            }else{
                resp.sendRedirect("/HotelManagement/errors/error.html");
                return ;
            }

            resp.sendRedirect("/HotelManagement/SuperIndividual.jsp");
        }else{
            System.out.println("IDCard为空!!!!!!!!!!!!!!!!!!");
            resp.sendRedirect("/HotelManagement/errors/errorVIP.html");
        }



    }

}

付款以及挂单前后端事物处理 package com.hotel.pay;

import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator;

import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.dao.CustomerManage; import com.hotel.dao.HasPayedManage; import com.hotel.dao.RoomManage;

@WebServlet(name="CheckOut",urlPatterns={"/CheckOut"}) public class CheckOut extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();

        String RoomIDs = req.getParameter("Room");

// System.out.println(RoomIDs); String p =req.getParameter("price"); String RoomID[] = RoomIDs.split(" "); System.out.println(p); for(int i =0;i<RoomID.length;i++){

            RoomManage.updateIsEmp(Integer.parseInt(RoomID[i]), RoomManage.selectByRoomId(Integer.parseInt(RoomID[i])).getRoomSize());
        }
        int OrderNum = Integer.parseInt(req.getParameter("OrderNum"));
        float price = Float.parseFloat(p);
        //从customer中删除此订单
        CustomerManage.delete(OrderNum);
        //在haspayed中添加此订单
        HasPayedManage.insert(OrderNum, price);

        resp.sendRedirect("/HotelManagement/CustomerInfo.jsp");
    }

}

package com.hotel.pay;

import java.io.IOException; import java.io.PrintWriter;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.dao.CustomerManage; import com.hotel.dao.GuaDanManage; import com.hotel.dao.RoomManage;

@WebServlet(name="GuaDanOut",urlPatterns={"/GuaDanOut"}) public class GuaDanOut extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();

        String RoomIDs = req.getParameter("Room");

// System.out.println(RoomIDs); String p =req.getParameter("price"); String RoomID[] = RoomIDs.split(" "); System.out.println(p); for(int i =0;i<RoomID.length;i++){

            RoomManage.updateIsEmp(Integer.parseInt(RoomID[i]), RoomManage.selectByRoomId(Integer.parseInt(RoomID[i])).getRoomSize());
        }


        int OrderNum = Integer.parseInt(req.getParameter("OrderNum"));
        float price = Float.parseFloat(p);
        //从customer中删除此订单
        CustomerManage.delete(OrderNum);
        //在leavewithoutpay中添加此订单
        GuaDanManage.insert(OrderNum, price);

        resp.sendRedirect("/HotelManagement/CustomerInfo.jsp");
    }

}

package com.hotel.pay;

import java.io.IOException; import java.io.PrintWriter;

import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

import com.hotel.dao.GuaDanManage; import com.hotel.dao.HasPayedManage;

@WebServlet(name="GuaDanPay",urlPatterns={"/GuaDanPay"}) public class GuaDanPay extends HttpServlet{

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();

        String p =req.getParameter("price");
        System.out.println(p);
        int OrderNum = Integer.parseInt(req.getParameter("OrderNum"));
        float price = Float.parseFloat(p);
        //从leavewithoutpay中删除此账单
        GuaDanManage.delete(OrderNum);
        //在haspayed中添加此账单
        HasPayedManage.insert(OrderNum,price);


        resp.sendRedirect("/HotelManagement/GuaDanPay.jsp");
    }

}

```

用户登记事物处理

c++ package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; @WebServlet(name="ChangeRoom",urlPatterns={"/ChangeRoom"}) public class ChangeRoom extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); resp.setContentType("text/html;charset=utf-8"); PrintWriter out = resp.getWriter(); //1.获取html页面中的input String CName = req.getParameter("CName"); // System.out.println(VIPId); String CSex = req.getParameter("CSex"); String CIDCard = req.getParameter("CIDCard"); int RoomId = Integer.parseInt(req.getParameter("RoomId")); int nRoomId = Integer.parseInt(req.getParameter("nRoomId")); String CPhone = req.getParameter("CPhone"); if(CustomerManage.update(CName, CSex, CIDCard, nRoomId,CPhone) == true){ ArrayList list = (ArrayList)CustomerManage.selectByRoomId(RoomId); if(list.size()==0){ RoomManage.updateIsEmp(RoomId, RoomManage.selectByRoomId(RoomId).getRoomSize()); } RoomManage.updateIsEmp(nRoomId, 0); resp.sendRedirect("/HotelManagement/CustomerInfo.jsp"); }else{ out.print("sorry ! Your VIP update is not successful!"); } } } package com.hotel.registration; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Random; public class CreateRan { /**

  • 生成随机订单号:当前年月日时分秒+五位随机数

c++ * * @return */ public static int CreateOrderNum(){ SimpleDateFormat simpleDateFormat; simpleDateFormat = new SimpleDateFormat("MMdd"); Date date = new Date(); String str = simpleDateFormat.format(date); Random random = new Random(); int rannum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000;// 获取5位随机数 return Integer.parseInt(rannum + str);// 当前时间 } public static String CreateDate(){ SimpleDateFormat simpleDateFormat; simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date date = new Date(); String str = simpleDateFormat.format(date); return str; } } package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; @WebServlet(name="GroupFinish",urlPatterns={"/GroupFinish"}) public class GroupFinish extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); resp.setContentType("text/html;charset=UTF-8"); PrintWriter out = resp.getWriter(); int OrderNum =Integer.parseInt(req.getParameter("GId")); String name = req.getParameter("name"); // String Cname = new String(name.getBytes(), "utf-8"); // System.out.println(name); String sex = req.getParameter("sex"); String IDCard = req.getParameter("IDCard"); int roomnum = Integer.parseInt(req.getParameter("roomnum")); String phone = req.getParameter("phone"); String StartTime = CreateRan.CreateDate(); RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum); int IsEmp = room.getIsEmp(); if(IsEmp>0){ //插入住户信息 CustomerManage.insert(OrderNum, name, sex, IDCard, roomnum, phone, 0, StartTime); //设置IsEmp-1 RoomManage.updateIsEmp(roomnum,0); }else{ resp.sendRedirect("/HotelManagement/errors/error.html"); return ; } int dep=0; ArrayList list = (ArrayList)CustomerManage.selectRoom(OrderNum); Iterator it = list.iterator(); while(it.hasNext()){ int Room =(Integer) it.next(); dep += RoomManage.selectByRoomId(Room).getDeposit(); } out.print("<h3>您一共需要缴纳"+dep+"元押金!!</h3>"); // resp.sendRedirect("/HotelManagement/Group.jsp"); } } package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; @WebServlet(name="GroupHandle",urlPatterns={"/GroupHandle"}) public class GroupHandle extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); resp.setContentType("text/html;charset=UTF-8"); PrintWriter out = resp.getWriter(); int OrderNum =Integer.parseInt(req.getParameter("GId")); String name = req.getParameter("name"); // String Cname = new String(name.getBytes(), "utf-8"); // System.out.println(name); String sex = req.getParameter("sex"); String IDCard = req.getParameter("IDCard"); int roomnum = Integer.parseInt(req.getParameter("roomnum")); String phone = req.getParameter("phone"); String StartTime = CreateRan.CreateDate(); RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum); int IsEmp = room.getIsEmp(); if(IsEmp>0){ //插入住户信息 CustomerManage.insert(OrderNum, name, sex, IDCard, roomnum, phone, 0, StartTime); //设置IsEmp-1 RoomManage.updateIsEmp(roomnum,IsEmp-1); }else{ resp.sendRedirect("/HotelManagement/errors/error.html"); return ; } resp.sendRedirect("/HotelManagement/Group.jsp"); } } package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; @WebServlet(name="individualFinish",urlPatterns={"/individualFinish"}) public class individualFinish extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //1.添加customer数据库,更改room数据库的IsEmp=0 req.setCharacterEncoding("UTF-8"); resp.setContentType("text/html;charset=UTF-8"); PrintWriter out = resp.getWriter(); String name = req.getParameter("name"); // String Cname = new String(name.getBytes(), "utf-8"); // System.out.println(name); String sex = req.getParameter("sex"); String IDCard = req.getParameter("IDCard"); int roomnum = Integer.parseInt(req.getParameter("roomnum")); String phone = req.getParameter("phone"); int OrderNum = 0; ArrayList list = (ArrayList)CustomerManage.selectByRoomId(roomnum); if(list.size()==0){ OrderNum = CreateRan.CreateOrderNum(); System.out.println(OrderNum); }else{ CustomerBean customer = (CustomerBean) list.get(0); OrderNum = customer.getOrderNum(); } String StartTime = CreateRan.CreateDate(); RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum); int IsEmp = room.getIsEmp(); if(IsEmp>0){ //插入住户信息 CustomerManage.insert(OrderNum, name, sex, IDCard, roomnum, phone, 0, StartTime); //设置IsEmp=0 RoomManage.updateIsEmp(roomnum,0); }else{ resp.sendRedirect("/HotelManagement/errors/error.html"); return ; } int dep=0; ArrayList list1 = (ArrayList)CustomerManage.selectRoom(OrderNum); Iterator it = list1.iterator(); while(it.hasNext()){ int Room =(Integer) it.next(); dep += RoomManage.selectByRoomId(Room).getDeposit(); } out.print("<h3>您一共需要缴纳"+dep+"元押金!!</h3>"); } } package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.hotel.bean.CustomerBean; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; @WebServlet(name="individualHandle",urlPatterns={"/individualHandle"}) public class individualHandle extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); resp.setContentType("text/html;charset=UTF-8"); PrintWriter out = resp.getWriter(); //1.获取html页面中的username、password String name = req.getParameter("name"); // String Cname = new String(name.getBytes(), "utf-8"); System.out.println(name); String sex = req.getParameter("sex"); String IDCard = req.getParameter("IDCard"); int roomnum = Integer.parseInt(req.getParameter("roomnum")); String phone = req.getParameter("phone"); int OrderNum = 0; ArrayList list = (ArrayList)CustomerManage.selectByRoomId(roomnum); if(list.size()==0){ OrderNum = CreateRan.CreateOrderNum(); System.out.println(OrderNum); }else{ CustomerBean customer = (CustomerBean) list.get(0); OrderNum = customer.getOrderNum(); } String StartTime = CreateRan.CreateDate(); RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum); int IsEmp = room.getIsEmp(); if(IsEmp>0){ //插入住户信息 CustomerManage.insert(OrderNum, name, sex, IDCard, roomnum, phone, 0, StartTime); //设置IsEmp-1 RoomManage.updateIsEmp(roomnum,IsEmp-1); }else{ resp.sendRedirect("/HotelManagement/errors/error.html"); return ; } resp.sendRedirect("/HotelManagement/Individual.jsp"); } } package com.hotel.registration; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.hotel.bean.RoomBean; import com.hotel.dao.CustomerManage; import com.hotel.dao.RoomManage; import com.hotel.dao.VipcardManage; @WebServlet(name="SGroupFinish",urlPatterns={"/SGroupFinish"}) public class SGroupFinish extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); resp.setContentType("text/html;charset=UTF-8"); PrintWriter out = resp.getWriter(); //1.获取html页面中的input int OrderNum =Integer.parseInt(req.getParameter("SGId")); String name = req.getParameter("name"); String sex = req.getParameter("sex"); String IdCard = req.getParameter("IdCard"); //身份证号 String IDCard = req.getParameter("VIPId"); //会员号 int ok = VipcardManage.selectVIPLevel(IDCard); int roomnum = Integer.parseInt(req.getParameter("roomnum")); String phone = req.getParameter("phone"); if( ok==2){ String StartTime = CreateRan.CreateDate(); RoomBean room = (RoomBean)RoomManage.selectByRoomId(roomnum); int IsEmp = room.getIsEmp(); if(IsEmp>0){ //插入住户信息 CustomerManage.insert(OrderNum, name, sex, IdCard, roomnum, phone, 1, StartTime); //设置IsEmp=0 RoomManage.updateIsEmp(roomnum,0); }else{ resp.sendRedirect("/HotelManagement/errors/error.html"); return ; } int dep=0; ArrayList list2 = (ArrayList)CustomerManage.selectRoom(OrderNum); Iterator it = list2.iterator(); while(it.hasNext()){ int Room =(Integer) it.next(); dep += RoomManage.selectByRoomId(Room).getDeposit(); } out.print("<h3>您一共需要缴纳"+dep+"元押金!!</h3>"); }else{ System.out.println("IDCard为空!!!!!!!!!!!!!!!!!!"); resp.sendRedirect("/HotelManagement/errors/errorVIP.html"); } } }

八、测试和运行

  • 会员账号查找不到时:

  • 管理员登录时出错

  • 房间已满时入住:

九、总结

9.1 系统优点

  • 本系统功能齐全,在有限时间内将需求的功能完全实现。前后端事务处理逻辑设计合理,能够很好的满足实际操作需求。

  • 界面简捷美观,说明清晰,操作简单,容易上手。

  • 数据库设计内容具体详细,条理清晰,关系明确,能够遵循数据库设计的准则来描述信息关系,可以稳定地为系统提供服务。

  • 信息提示系统细致完善,对于用户可能发生的错误操作,给予错误信息提示。

9.2 系统不足

历史账单会逐渐增加,随着时间会让系统运行逐渐减慢速度,需要手动删除历史账单数据

数据库的设计上仍然不尽如人意,某些信息的处理不够实际化。

9.3 经验与收获

通过这次数据库课程设计,进一步了解了数据库内部的操作机制,熟练了自己在数据库编程方面的能力。

调试时可以用System.out.println输出变量的值以检验错误发生在什么地方,或者在某个语句下放入System.out.println(“············”)来检验程序是否执行到该语句。

写程序的时候不要只注重结果,更要注重过程,一个习惯早期容易形成,而要是到了后期就很难去改正,所以现在起就要有好习惯,要注重每一个小的细节。

个系统不是一两天就能完成的,在此系统开发期间,每天都要开发一点,中间尽量不要间断,会影响之前的开发思路,尽量一口气开发完。

参考文献

  • 基于Spring Boot的学生信息管理系统的设计与实现(武汉轻工大学·杨东)
  • 基于ASP.NET的酒店管理系统的设计与实现(电子科技大学·李艳)
  • 中小型宾馆客房管理系统的设计与实现(华中科技大学·向辉)
  • 基于BS架构大连棒棰岛宾馆管理系统的设计与实现(电子科技大学·赵晓宁)
  • 基于Struts的酒店客房管理系统设计与实现(厦门大学·郭珠锁)
  • 学生综合信息管理平台的设计与实现(吉林大学·刘铁刚)
  • 基于WEB的中小型商务酒店信息管理系统设计与实现(北京工业大学·宋伟威)
  • 温都水城信息系统的设计与实现(北京邮电大学·汪洋)
  • 基于BS架构大连棒棰岛宾馆管理系统的设计与实现(电子科技大学·赵晓宁)
  • 基于SSH框架的人力资源管理系统的设计与开发(电子科技大学·唐伟)
  • 基于ASP.NET的酒店信息管理系统的设计与实现(电子科技大学·方亮)
  • 宾馆管理信息系统设计与开发(中国海洋大学·苗娟)
  • 基于Spring Boot的学生信息管理系统的设计与实现(武汉轻工大学·杨东)
  • 基于SSH资源管理系统的设计及实现(西安电子科技大学·杨静涛)
  • 基于SSH资源管理系统的设计及实现(西安电子科技大学·杨静涛)

本文内容包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主题。发布者:毕设向导 ,原文地址:https://m.bishedaima.com/yuanma/35685.html

相关推荐

发表回复

登录后才能评论