宾馆管理系统(Jdbc+javaSwing)

宾馆管理系统(Jdbc+javaSwing)


一、需求分析

1.酒店管理系统需要满足酒店工作人员和管理人员的需求。
2.管理员可以通过各自的密码登入系统进行各自的管理。
3.酒店管理人员和工作人员可以为酒店房间加入入住和退房记录信息,并生成相应的报表,用于数据的浏览,统计。工作人员可以浏览、统计、添加酒店房间的入住和退房信息。
4.客户入住酒店时,酒店工作人员需要对客户的姓名、性别、身份证号、房间号、入住时间、联系方式等信息进行记录,退房时进行退房记录。
5.管理员和员工可以通过姓名、入住日期、身份证号、联系方式等信息查询客户入住和离开的信息。
6. 管理人员可以查询房间信息、查询人工信息、更改退房信息、更改员工信息等。

二、功能分析

  1. 登入系统:
    酒店管理员可以通过各自的编号和密码登入系统。
  2. 入住办理:
    客户需要办理会员卡(享受折扣,普通会员不打折)、工作人员需要记录客人的信息。若房间已满或选择的房间不为空闲则不能办理入住。
  3. 入住信息查询:
    工作人员和管理员可以对已入住的客户进行信息查询。支持模糊查询和精准查询。
  4. 房间查询:
    管理员可以查询房间信息:如房间类型、房间价格、房间是否为空、若已经被入住,则额外显示入住人的信息。
  5. 退房办理:
    当客户要退房时,工作人员需要记录退房的时间。
  6. 员工查询:
    管理员可以查询员工的信息:如姓名、性别、编号、联系方式等。
  7. 更改房间信息:
    管理员可以更改房间信息:如房间类型、房间价格、增删房间。
  8. 更改员工信息:
    管理员可以更改员工信息:如更姓名、性别、职位、增删员工等。

三、数据字典

1.房间信息表:RoomInfo
列名 数据类型 约束 含义
RoomID Int Primary Key 房间号
RoomType Varchar(10) Not null 房间类型
RoomPrice Double Not null’ 房间价格
RoomStatus Varchar(3) Not null 房间状态(未入住、已入住、待维修、未清理)
2.客户信息表:CustomerInfo
列名 数据类型 约束 含义
CustomerID Int Primary Key 客户编号
CustomerName Varchar(10) Not null 客户姓名
CustomerGender Enum Not null 客户性别(先生、女士)
VIPName Enum Not null 会员卡名称 (贵宾卡、钻石卡、至尊卡、绅士卡)
CustomerIDNumber Varchar(18) Not null 客户身份证号
CustomerPhone Varchar(11) Not null 客户联系方式
CustomerCreateDate TimeStamp Not null 客户办卡日期
3.员工信息表:WorkerInfo
列名 数据类型 约束 含义
WorkerID Int Primary Key 员工编号
WorkerName Varchar(10) Not null 员工姓名
WorkerGender Enum Not null 员工性别
WorkerIDName Varchar(18) Not null 员工身份证号
WorkerPosition Varchar(10) Not null 员工职位
WorkerWage Double Not null 员工工资
WorkerPhone Varchar(11) Not null 员工联系方式
4.管理员信息表:ManagerInfo
列名 数据类型 约束 含义
ManagerID Int Primary Key 管理员编号
ManageName Varchar(10) Not null 管理员姓名
ManagePassword Varchar(20) Not null 管理员密码
ManagePhone Varchar(11) Not null 管理员联系方式
5.会员类别表:VIPTypeInfo
列名 数据类型 约束 含义
VipName Enum Not null 会员卡名称
Discount Double Not null 折扣
6.入住记录表:InInfo
列名 数据类型 约束 含义
InID Int Primary Key 入住编号
CustomerID Int Not null 客户编号
CustomerInDate TimeStamp Not null 入住时间
CustomerOutDate TimeStamp Not null 应退房时间
RoomID Varchar(4) Not null 房间号
WorkerName Varchar(10) Not null 员工姓名
Payment Double Not null 付款金额
7.退房记录表:OutInfo
列名 数据类型 约束 含义
InID Int Not null 入住编号
CustomerOutDate TimeStamp Not null 退房时间
WorkerName Varchar(10) Not null 员工姓名
ContinuePrice Double Not null 续住金额
SumPayment Double Not null 总付款金额

四、主要效果图

1.登录界面效果图

登录界面

2.管理员效果图

在这里插入图片描述

3.客户登记效果图

在这里插入图片描述

4.入住登记效果图

在这里插入图片描述

5.主界面效果图

在这里插入图片描述

6 .生成盈利额折线图

在这里插入图片描述

7.每日结算效果图

在这里插入图片描述

五、宾馆管理系统源码

由于源码较多,因此用分隔符分开了每个文件类的内容


//登录界面
package View;

import MyWindowListener.MyWindowListener;
import View.checkIn.CheckInRegisterView;
import View.mainView.ManagerMainView;
import View.mainView.WorkerMainView;

import javax.swing.;
import javax.swing.border.MatteBorder;
import java.awt.
;
import java.awt.event.;
import java.sql.
;

public class LoginView extends JFrame {
//控件
private JLabel userIDLabel = new JLabel(“用户ID”);
private JTextField userIDField = new JTextField();
private JLabel passwordLabel = new JLabel(“密码”);
private JTextField passwordField = new JPasswordField();
private JButton resetButton = new JButton(“重置”);
private JButton loginButton = new JButton(“登陆”);
private JLabel font = new JLabel();
private JLabel font1 = new JLabel();
private JLabel background = new JLabel(new ImageIcon(“src/images/2.png”));//设置背景
//主界面构造函数
public LoginView() {
//设置界面
setTitle(“登录界面”);
setSize(600, 400);
setLocationRelativeTo(null);
setResizable(false);
setLayout(null);
//边框参数
MatteBorder border = new MatteBorder(0, 0, 1, 0, new Color(0x000000));
MatteBorder border1 = new MatteBorder(0, 0, 0, 0, new Color(192, 192, 192));
//编辑字体
font.setFont(new Font(“宋体”, Font.PLAIN, 50));
font1.setFont(new Font(“宋体”, Font.PLAIN, 30));
font.setText(“欢迎登录”);
font1.setText(“神州明珠大酒店管理系统”);
//控件位置
font.setBounds(190, 30, 200, 50);
font1.setBounds(130, 100, 350, 40);
userIDLabel.setBounds(180, 190, 50, 20);
userIDField.setBounds(230, 190, 150, 20);
passwordLabel.setBounds(180, 220, 50, 20);
passwordField.setBounds(230, 220, 150, 20);
resetButton.setBounds(150, 320, 80, 20);
loginButton.setBounds(350, 320, 80, 20);
background.setBounds(0, 0, 600, 400);
//透明文本框
userIDField.setOpaque(false);
passwordField.setOpaque(false);
//添加图片
//userIDLabel.setIcon(new ImageIcon(“src/images/id.jpg”));
//passwordLabel.setIcon(new ImageIcon(“src/images/pw.jpg”));
//resetButton.setIcon(new ImageIcon(“src/images/reset.jpg”));
// loginButton.setIcon(new ImageIcon(“src/images/login.jpg”));
//按钮颜色
//loginButton.setBackground(Color.gray);
loginButton.setForeground(Color.black);
//resetButton.setBackground(Color.gray);
resetButton.setForeground(Color.black);
//字体颜色
font.setForeground(new Color(0, 0, 0));
font1.setForeground(new Color(0, 0, 0));
//调用边框对象
userIDField.setBorder(border);
passwordField.setBorder(border);
resetButton.setBorder(border1);
loginButton.setBorder(border1);
//添加对象
add(userIDLabel);
add(userIDField);
add(passwordLabel);
add(passwordField);
add(resetButton);
add(loginButton);
add(font);
add(font1);
add(background);
//设置关闭事件
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new MyWindowListener());
//监听事件
resetButton.addActionListener((e) -> {//重置按钮
userIDField.setText("");
passwordField.setText("");
});
loginButton.addActionListener((e) -> {//登录按钮
//将用户写的内容转为String
String ID = userIDField.getText();
String password = passwordField.getText();
//用来区分管理员和员工登录,并判断是否账号密码错误
int n = 0;
//管理员登录
Connection connection = null;
try {
Class.forName(“com.mysql.jdbc.Driver”);
connection = DriverManager.getConnection(“jdbc:mysql://127.0.0.1:3306/hotel_managersystem”, “root”, “root”);
String sql = “select ManagerID,ManagerName,ManagerPassword,ManagerRole from managerinfo where ManagerID = ? and ManagerPassword = ?”;
PreparedStatement ps = connection.prepareStatement(sql);
ps.setObject(1, ID);
ps.setObject(2, password);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
String managerName = rs.getString(2);
//如果登入成功,关闭登入界面
LoginView.this.dispose();
if (rs.getInt(4) == 0) {
//进入主界面
ManagerMainView managerMainView = new ManagerMainView(managerName);
//开启多线程
Thread thread = new Thread(managerMainView);
thread.start();
n = n + 1;
}
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
connection.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
if (n == 0) {
//将用户写的内容转为String
String ID2 = userIDField.getText();
String password2 = passwordField.getText();
//员工登录
Connection connection2 = null;
try {
Class.forName(“com.mysql.jdbc.Driver”);
connection2 = DriverManager.getConnection(“jdbc:mysql://127.0.0.1:3306/hotel_managersystem”, “root”, “root”);
String sql2 = “select WorkerID,WorkerName,WorkerPassword,WorkerRole from workerinfo where WorkerID = ? and WorkerPassword = ?”;
PreparedStatement ps2 = connection2.prepareStatement(sql2);
ps2.setObject(1, ID2);
ps2.setObject(2, password2);
ResultSet rs2 = ps2.executeQuery();
if (rs2.next()) {
String workerName = rs2.getString(2);
//如果登入成功,关闭登入界面,进入主界面
LoginView.this.dispose();
if (rs2.getInt(4) == 1) {
WorkerMainView workerMainView= new WorkerMainView(workerName);
//开启多线程
Thread thread = new Thread(workerMainView);
thread.start();
}
} else {
n = n - 1;
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
connection.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
//如果管理员和员工都未登录则账号密码出错
if (n == -1) {
JOptionPane.showMessageDialog(null, “用户ID或密码错误,请重新填写!”);
}
});
//文本框提示 居中
userIDField.setHorizontalAlignment(JTextField.CENTER);
passwordField.setHorizontalAlignment(JTextField.CENTER);
userIDField.addFocusListener(new JTextFieldHintListener(userIDField,“请输入用户名”));
passwordField.addFocusListener(new JPasswordFieldHintListener((JPasswordField) passwordField,“请输入密码”));
//按键监听事件(enter)
KeyListener keyListener = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
//判断enter是否触发
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
//将用户写的内容转为String
String ID = userIDField.getText();
String password = passwordField.getText();
//用来区分管理员和员工登录,并判断是否账号密码错误
int n = 0;
//管理员登录
Connection connection = null;
try {
Class.forName(“com.mysql.jdbc.Driver”);
connection = DriverManager.getConnection(“jdbc:mysql://127.0.0.1:3306/hotel_managersystem”, “root”, “root”);
String sql = “select ManagerID,ManagerName,ManagerPassword,ManagerRole from managerinfo where ManagerID = ? and ManagerPassword = ?”;
PreparedStatement ps = connection.prepareStatement(sql);
ps.setObject(1, ID);
ps.setObject(2, password);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
String managerName = rs.getString(2);
//如果登入成功,关闭登入界面
LoginView.this.dispose();
if (rs.getInt(4) == 0) {
//进入主界面
ManagerMainView managerMainView = new ManagerMainView(managerName);
//开启多线程
Thread thread = new Thread(managerMainView);
thread.start();
n = n + 1;
}
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
connection.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
if (n == 0) {
//将用户写的内容转为String
String ID2 = userIDField.getText();
String password2 = passwordField.getText();
//员工登录
Connection connection2 = null;
try {
Class.forName(“com.mysql.jdbc.Driver”);
connection2 = DriverManager.getConnection(“jdbc:mysql://127.0.0.1:3306/hotel_managersystem”, “root”, “root”);
String sql2 = “select WorkerID,WorkerName,WorkerPassword,WorkerRole from workerinfo where WorkerID = ? and WorkerPassword = ?”;
PreparedStatement ps2 = connection2.prepareStatement(sql2);
ps2.setObject(1, ID2);
ps2.setObject(2, password2);
ResultSet rs2 = ps2.executeQuery();
if (rs2.next()) {
String workerName = rs2.getString(2);
//如果登入成功,关闭登入界面,进入主界面
LoginView.this.dispose();
if (rs2.getInt(4) == 1) {
WorkerMainView workerMainView= new WorkerMainView(workerName);
//开启多线程
Thread thread = new Thread(workerMainView);
thread.start();
}
} else {
n = n - 1;
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
connection.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
//如果管理员和员工都未登录则账号密码出错
if (n == -1) {
JOptionPane.showMessageDialog(null, “用户ID或密码错误,请重新填写!”);
}
}
}
};
//调用监听键盘对象
userIDField.addKeyListener(keyListener);
passwordField.addKeyListener(keyListener);
//设置窗口可见
setVisible(true);
}
public static void main(String[] args) {
//调用美化包
try {
javax.swing.UIManager.setLookAndFeel(“com.jtattoo.plaf.mint.MintLookAndFeel”);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
//创建登录窗体
new LoginView();

}

}


//焦点事件
package View;

import javax.swing.;
import java.awt.
;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

public class JTextFieldHintListener implements FocusListener {
private String hintText;
private JTextField jTextField;
public JTextFieldHintListener(JTextField jTextField, String hintText) {
this.jTextField = jTextField;
this.hintText = hintText;
jTextField.setText(hintText);
}
@Override
public void focusGained(FocusEvent e) {
String temp = jTextField.getText();
if (temp.equals(hintText)) {
jTextField.setText("");
jTextField.setForeground(Color.black);
}
}
@Override
public void focusLost(FocusEvent e) {
String temp = jTextField.getText();
if (temp.equals("")) {
jTextField.setText(hintText);
jTextField.setForeground(Color.gray);
}
}

}

// 密码 焦点事件
package View;

import javax.swing.;
import java.awt.
;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

public class JPasswordFieldHintListener implements FocusListener {
private String hintText;
private JPasswordField jPasswordField;
public JPasswordFieldHintListener(JPasswordField jPasswordField, String hintText) {
this.jPasswordField = jPasswordField;
this.hintText = hintText;
jPasswordField.setEchoChar(’\0’);
jPasswordField.setText(hintText);
jPasswordField.setForeground(Color.gray);
}
@Override
public void focusGained(FocusEvent e) {
String pswd = new String(jPasswordField.getPassword()).trim();
if (pswd.equals(hintText)) {
jPasswordField.setText("");
jPasswordField.setEchoChar(’*’);
jPasswordField.setForeground(Color.black);
}
}
@Override
public void focusLost(FocusEvent e) {
String pswd = new String(jPasswordField.getPassword()).trim();
if (pswd.equals("")) {
jPasswordField.setEchoChar(’\0’);
jPasswordField.setText(hintText);
jPasswordField.setForeground(Color.gray);
}
}
}

各位码友不好意思 因为文章字数有限制 所以就暂时发的登录界面。如果有需要可以在评论下放留言,也可以加我qq或者微信。

谢谢各位的阅读!如有需要后续请添加qq 1302593650 或vx:AprilThirty_CP

  • 14
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 11
    评论
校园宿舍管理系统是一个非常典型的信息管理系统,主要用于管理学生宿舍信息、学生信息以及宿舍设备等。下面是一个简单的实现思路: 1. 数据库设计 首先需要设计数据库,包括宿舍表、学生表、设备表等。其中,宿舍表包括宿舍编号、宿舍类型、宿舍楼号、宿舍电话等信息;学生表包括学生编号、学生姓名、学生性别、学生电话、所属宿舍等信息;设备表包括设备编号、设备名称、设备型号、设备数量、所属宿舍等信息。 2. 界面设计 使用JavaSwing框架进行界面设计,主要包括登录界面、主界面、宿舍信息界面、学生信息界面、设备信息界面等。可以使用JFrame、JPanel等组件进行布局。 3. 数据库连接 使用JDBC连接数据库,将数据库中的宿舍信息、学生信息、设备信息读取到程序中,显示在对应的界面中。同时,可以在程序中对数据库进行增、删、改、查等操作。 4. 功能实现 根据需求,实现对宿舍信息、学生信息、设备信息的增加、删除、修改、查询等功能。同时,还可以实现一些其他的功能,比如统计宿舍设备数量、查询某个学生所在的宿舍等。 5. 安全性设计 在程序中添加一些安全性措施,比如登录时进行身份验证、对数据库进行加密等。 以上是一个简单的校园宿舍管理系统的实现思路,具体实现细节需要根据需求进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值