宾馆客房管理系统报告.docx
《宾馆客房管理系统报告.docx》由会员分享,可在线阅读,更多相关《宾馆客房管理系统报告.docx(34页珍藏版)》请在冰豆网上搜索。
宾馆客房管理系统报告
1)研究内容
本系统根据宾馆的业务情况该系统可分客房信息管理、客房经营管理、客户信息查询、员工信息管理4个功能模块。
2)实验方案
根据课题的具体要求,可以将宾馆客房管理系统大体结构图示为如下:
整个系统分4个模块:
1.客房信息管理:
录入房间信息、修改房间信息、查询房间信息,删除房间信息.
2.客房经营管理:
客房使用情况、宾馆订房、客房预订、宾馆退房.
3.客户信息查询:
客户信息查询.
4.员工信息管理:
员工查询、员工添加、员工删除。
四、数据库设计
1.E-R图的分析:
E-R图的分析工作通常采用自底向下的设计方法,首先对局部视图进行分析设计,然后再实现视图集成。
宾馆客房管理系统一般包括如下几个表:
用户信息(UsersInfo)、客户信息(CustomersInfo)、客房类型(RoomCategory)、客房信息(RoomsInfo)、客房状态(RoomStatus)、客房业务(RoomOperation)、业务记录(History)。
他们之间关系如图1所示。
图1宾馆客房管理系统E-R图
2.创建表
(1)用户信息表
表1用户信息表(UsersInfo)
编号
字段名称
数据结构
说明
1
UserId
Int
服务员编号
2
Name
nchar(6)
服务员姓名
3
Password
Varchar(50)
密码
4
Gender
Int
性别(0-男,1-女)
5
Email
Varchar(50)
Email地址
6
Address
Varchar(50)
通讯地址
7
Telephone
nchar(11)
联系电话
8
Department
Varchar(30)
所在部门
9
Type
Int
用户类型(1-酒店管理员,2-前台服务员
(2)客户信息表
表2客户信息表(CustomersInfo)
编号
字段名称
数据结构
说明
1
CIdentityId
nVarchar(18)
身份证号
2
CName
nchar(6)
客户姓名
3
CPhone
nchar(11)
联系电话
4
VIPDegree
nchar
(1)
会员级别
(3)客房信息表
表3客房类型表(RoomInfo)
编号
字段名称
数据结构
说明
1
RoomId
nVarchar(4)
客房号
2
Name
nVarchar(50)
类型名称
3
Price
Money
客房价格
4
Status
Int
状态(1-空房,2-入住)
5
Description
nVarchar(50)
描述
(4)客户订单表
表4客房业务表(CustomersBook)
编号
字段名称
数据结构
说明
1
RoomId
Int
客房号
2
CName
Nchar(6)
客户姓名
3
CPhone
Nchar(11)
客户电话
4
BeginTime
DateTime
入住时间
5
EndTime
DateTime
退房时间
6
CIdentityId
nVarchar(50)
客户身份证号
7
Money
Money
付款金额
8
UserId
Int
服务员编号
9
Remarks
nVarchar(50)
备注
(5)VIP折扣表
表5VIP折扣表(VIPDiscount)
编号
字段名称
数据结构
说明
1
CPhone
Nchar(11)
用户电话
2
VIPDegree
Nchar
(1)
会员等级
3
VIPDiscount
Int
会员折扣
五.页面设计及相关代码分析
宾馆客房管理系统的页面由五部分组成:
●宾馆客房管理系统登陆界面的设计
●客房管理管理页面的设计
●客房经营管理页面的设计
●客户信息查询页面的设计
●员工信息管理页面的设计
1.宾馆客房管理系统登陆界面的设计
系统共分两类用户:
酒店管理员和前台服务员
当用户进入宾馆客房管理系统登陆界面后,首先需要进行身份验证,系统在验证通过后,将使用UserType变量记录其用户类型,并根据用户类型确定用户的使用权限。
宾馆客房管理系统登陆界面如下2所示。
现在给出登陆界面的主要代码如下:
import.URL.*;
importjavax.swing.*;
importjava.sql.*;
importjava.awt.Container;
importjava.awt.GridLayout;
importjava.awt.FlowLayout;
importjava.awt.Image;
importjavax.swing.ImageIcon;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JTextField;
importjavax.swing.JPasswordField;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.awt.*;
publicclassHoteLandextendsJFrameimplementsActionListener{
privatebooleanboo1=false,boo2=false;
intType=0;
publicJTextField[]t={newJTextField("用户名:
",6),newJTextField(20),
newJTextField("密码:
",6),newJPasswordField(20)};
publicJButton[]b={newJButton("登陆"),newJButton("退出")};
ImageIconic=newImageIcon(HoteLand.class.getResource("/hotel.jpg"));
JFrameapp;
Statementstatement;
//构造方法
publicHoteLand(){
app=newJFrame("宾馆客房管理系统登陆界面");
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
app.setSize(350,345);
app.setLocation(500,100);
app.setResizable(false);
Containerc=app.getContentPane();
c.setLayout(newFlowLayout());
JLabelLabel=newJLabel(ic,JLabel.LEFT);
t[0].setFont(newFont("TimesRoman",Font.BOLD,13));
t[0].setForeground(Color.red);
t[0].setEditable(false);
t[2].setFont(newFont("TimesRoman",Font.BOLD,13));
t[2].setForeground(Color.red);
t[2].setEditable(false);
for(inti=0;i<4;i++)
c.add(t[i]);
c.add(b[0]);
c.add(b[1]);
for(intj=4;j<4;j++){
c.add(t[j]);
t[j].setFont(newFont("TimesRoman",Font.BOLD,13));
t[j].setForeground(Color.blue);
t[j].setEditable(false);
}
c.add(Label);
t[0].addActionListener(this);
t[2].addActionListener(this);
b[0].addActionListener(this);
b[1].addActionListener(this);
app.setVisible(true);
}
privateImagegetImage(Stringstring){
//TODOAuto-generatedmethodstub
returnnull;
}
//消息响应方法
publicvoidactionPerformed(ActionEvente){
JButtonsource=(JButton)e.getSource();
if(source==b[0]){
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connectionconn=DriverManager.getConnection(
"jdbc:
sqlserver:
//127.0.0.1:
1433;DatabaseName=宾馆客户数据库",
"root","root");
System.out.println("数据库驱动程序注册成功!
");
System.out.println("数据库连接成功!
");
statement=conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
Strings1=t[1].getText();
Strings2=t[3].getText();
ResultSetresultset=statement
.executeQuery("select*fromUsersInfowhereName='"
+s1+"'andPassword='"+s2+"'");
resultset.next();
Type=resultset.getInt("Type");
if(resultset!
=null){
boo1=boo2=true;
resultset.close();
}
}
catch(Exceptione1){
JOptionPane.showMessageDialog(this,"用户名和密码不正确!
","警告",
JOptionPane.WARNING_MESSAGE);
//e1.printStackTrace();
}
if(boo1&&boo2&&Type==1){
Type=0;
boo1=boo2=true;
newHoteMen(statement,"普通员工--"+t[1].getText());
//newStudentManager();
app.setVisible(false);
}
if(boo1&&boo2&&Type==2){
Type=0;
boo1=boo2=true;
newHotelManagerMen(statement,"管理员--"+t[1].getText());
//newStudentManager();
app.setVisible(false);
}
}
//如果单击"退出"按键,则退出登陆界面
if(source==b[1]){
System.exit(0);
}
}
publicstaticvoidmain(Stringargs[]){
newHoteLand();
}
}
2.客房管理管理页面的设计
客房管理管理页面主要是负责所有客房信息的维护。
其中功能主要包括:
录入客房信息,修改客房信息,查询客房信息,删除客房信息。
他们的界面如3图所示。
图3客房管理管理页面
现在给出客房管理界面的主要代码如下:
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.io.*;
importjava.util.*;
importjava.sql.*;
publicclassAddRoomsextendsJPanelimplementsActionListener
{
Hashtable基本信息表=null;
JTextField房间号,房间位置;
JTextArea描述;
JButton录入,重置;
Choice房间类型;
Statementstatement=null;
JLabel添加客房信息=null;
publicAddRooms(Statementstatement)
{
this.statement=statement;
房间号=newJTextField(10);
房间位置=newJTextField(10);
描述=newJTextArea(7,10);
录入=newJButton("录入");
重置=newJButton("重置");
录入.addActionListener(this);
重置.addActionListener(this);
Boxbox0=Box.createHorizontalBox();
添加客房信息=newJLabel("--添加客房信息--",JLabel.CENTER);
添加客房信息.setFont(newFont("TimesRoman",Font.BOLD,25));
添加客房信息.setForeground(Color.red);
box0.add(添加客房信息);
Boxbox1=Box.createHorizontalBox();
box1.add(newJLabel("房间号:
",JLabel.CENTER));
box1.add(房间号);
房间类型=newChoice();
房间类型.add("普通单人间");
房间类型.add("普通双人间");
房间类型.add("vip单人间");
房间类型.add("vip双人间");
房间类型.add("豪华贵宾间");
房间类型.add("总统套间");
Boxbox2=Box.createHorizontalBox();
box2.add(newJLabel("房间类型:
",JLabel.CENTER));
box2.add(房间类型);
Boxbox3=Box.createHorizontalBox();
box3.add(newJLabel("房间位置:
",JLabel.CENTER));
box3.add(房间位置);
Boxbox4=Box.createHorizontalBox();
box4.add(newJLabel("单价:
",JLabel.CENTER));
box4.add(newJScrollPane(描述),BorderLayout.CENTER);
BoxboxH=Box.createVerticalBox();
boxH.add(box0);
boxH.add(box1);
boxH.add(box2);
boxH.add(box3);
boxH.add(box4);
boxH.add(Box.createVerticalGlue());
JPanelpCenter=newJPanel();
pCenter.add(boxH);
setLayout(newBorderLayout());
add(pCenter,BorderLayout.CENTER);
JPanelpSouth=newJPanel();
pSouth.add(录入);
pSouth.add(重置);
add(pSouth,BorderLayout.SOUTH);
validate();
}
publicvoidactionPerformed(ActionEvente)
{
ResultSetresultset=null;
booleanboo=false;
if(e.getSource()==录入)
{
intnumber=0;
try{
number=Integer.parseInt(房间号.getText().toString());
boo=true;
}
catch(Exceptione1){
boo=false;
}
if(boo&&(number>0))
{
try{
resultset=statement.executeQuery("use宾馆客户数据库;select*fromRoomsInfowhereRoomId='"+number+"'");
try{
resultset.next();
resultset.getInt("RoomId");
Stringwarning="该客房信息已存在,请到修改页面修改!
";
JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);
}
catch(Exceptione1){
intRoomId=Integer.parseInt(房间号.getText().toString());
StringRCategory=房间类型.getSelectedItem().toString();
StringRPostion=房间位置.getText().toString();
StringDescription=描述.getText().toString();
Stringstr="use宾馆客户数据库;insertintoRoomsInfovalues("+RoomId+",'"+RCategory+"','"+RPostion+"','"+Description+"')";
try{
statement.executeUpdate(str);
statement.executeUpdate("use宾馆客户数据库;insertintoRoomStatusvalues("+RoomId+","+1+")");
JOptionPane.showMessageDialog(this,"成功录入客房信息!
","提示",JOptionPane.WARNING_MESSAGE);
}
catch(Exceptione2){
Stringwarning="输入格式有误,请重新输入!
";
JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);
e2.printStackTrace();
}
房间号.setText(null);
房间类型.select("普通单人间");
房间位置.setText(null);
描述.setText(null);
}
}
catch(Exceptione1){
Stringwarning="输入格式有误,请重新输入!
";
JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);
}
}
else{
Stringwarning="必须要输入房间号!
";
JOptionPane.showMessageDialog(this,warning,"警告",JOptionPane.WARNING_MESSAGE);
}
}
if(e.getSource()==重置)
{
房间号.setText(null);
房间类型.select("普通单人间");
房间位置.setText(null);
描述.setText(null);
}
}
}
3.客房经营管理页面的设计
该页面主要是实现如下三个功能:
客房使用情况,宾馆订房,宾馆退房。
其的界面如图4所示。
图4客房经营管理页面
现在给出客房经营管理页面的主要代码:
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.io.*;
importjava.util.*;
importjava.sql.*;
publicclassUseOfRoomsextendsJPanelimplementsActionListener
{
JButton查询;
Choice房间类型,状态;
Statementstatement=null;
JTextArea房间使用情况;
JLabel客房使用情况=null;
publicUseOfRooms(Statementstatement)
{
this.statement=statement;
查询=newJButton("查询");
查询.addActionListener(this);
房间类型=newChoice();
房间类型.add("普通单人间");
房间类型.add("普通双人间");
房间类型.add("vip单人间");
房间类型.add("vip双人间");
房间类型.add("豪华贵宾间");
房间类型.add("总统套间");
状态=newChoice();
状态.add("有");
状态.add("否");
Boxbox0=Box.createHorizontalBox();
客房使用情况=newJLabel("--客房使用情况--",JLabe