1.酒店管理系统需要满足酒店工作人员和管理人员的需求。
2.管理员可以通过各自的密码登入系统进行各自的管理。
3.酒店管理人员和工作人员可以为酒店房间加入入住和退房记录信息,并生成相应的报表,用于数据的浏览,统计。工作人员可以浏览、统计、添加酒店房间的入住和退房信息。
4.客户入住酒店时,酒店工作人员需要对客户的姓名、性别、身份证号、房间号、入住时间、联系方式等信息进行记录,退房时进行退房记录。
5.管理员和员工可以通过姓名、入住日期、身份证号、联系方式等信息查询客户入住和离开的信息。
6. 管理人员可以查询房间信息、查询人工信息、更改退房信息、更改员工信息等。
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 总付款金额
由于源码较多,因此用分隔符分开了每个文件类的内容
//登录界面
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或者微信。