资源描述
Java语言程序设计课程设计
题 目 酒店管理系统
学 院 南湖学院
专 业 计算机科学和技术
班 级 计科N112
学 号 45209133
学生姓名 吴威宗
指导老师 李永刚
编写日期 /6/26
目录
一、需求分析 5
二、系统运行环境 5
三、功效需求描述 5
四、模块结构图 6
五、数据库设计 6
5.1数据库分析 6
5.2数据库概念设计 6
5.3 数据库逻辑结构设计 7
六、程序模块设计 8
七、总结 36
一、需求分析
伴随餐饮行业快速发展,现有人工管理方法已经不能呢个满足管理者需求,广大餐饮业经营者已经意识到使用计算机应用软件关键性,决定在餐饮企业经营管理上引入计算机应用软件管理系统。
酒店管理系统大致功效:
1. 开台点餐
2. 菜品管理
3. 自动结账
4. 后台菜系菜品管理
5. 日月年结账报表
6. 用户设置
依据需求分析,本系统采取语言:
(1)本系统采取Java语言,Java是现在使用最为广泛计算机语言之一。它含有简单,面向对象,稳定,和平台无关等特点。说她简单,并不是说这门语言很干瘪,而是一个清楚更轻易了解方法实现程序。面向对象是基于对象变成更符合人思维方法,使大家更轻易编写程序。
(2)本系统还采取SQL语言,SQL Server含有很多显著优点:易用性、适合分布组织可伸缩性、用于决议支持数据仓库功效、和很多其它服务器软件紧密关联集成性、良好性价比等。
(3) 本系统有效利用Java和SQL优点。
二、系统运行环境
操作系统为Windows 7、windows XP或windows 使用集成开发工具Eclipse 数据库采取SQL Server,项目运行环境为JDK 7。
三、功效需求描述
1.开台签单工作区功效:关键功效有开台、点菜、加菜、签单、查看开台信息和签单信息。
2.自动结账工作区功效:一个功效是自动计算目前选中餐台消费金额;另一个功效是在结账时自动计算找零金额。
3.结账报表工作区功效:日结帐报表,月结账报表,年结账报表。
4.后天管理工作区功效:管理添加信息
四、模块结构图
模块结构图
五、数据库设计
5.1数据库分析
酒店管理系统需求包含开台点菜功效、智能化获取菜品功效、自动结账功效、营业额报表功效等。在这些功效总关键包含数据表包含台号表、菜品表、消费单表;为了使系统愈加完善,还需要为菜品分类,即需要用到菜系表;为了实现菜品日销售情况统计,还要建立一个消费项目表,用来统计消费单消费菜品。
5.2数据库概念设计
数据库设计是系统设计过程中关键组成部分,它是经过管理系统整天需求而制订,数据库设计好坏直接影响到系统后期开发。
5.3 数据库逻辑结构设计
台号表
菜品表
菜系表
消费单表
消费项目表
管理员表
六、程序模块设计
功效模块整体设计:
用户功效界面:
代码:package com.mwq.frame;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import .URL;
import java.util.Vector;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import com.mwq.dao.Dao;
import com.mwq.mwing.MPanel;
public class LandFrame extends JFrame {
private JPasswordField passwordField;// 密码框
private JComboBox usernameComboBox;// 用户名下拉菜单
public static void main(String args[]) {
try {
LandFrame frame = new LandFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public LandFrame() {
// 首先设置窗口相关信息
super();// 调用父类结构方法
setTitle(" 小组:吴威宗 周志远");// 设置窗口标题
setResizable(false);// 设置窗口不能够改变大小
setAlwaysOnTop(true);// 设置窗口总在最前方
setBounds(100, 100, 428, 292);// 设置窗口大小
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 设置当关闭窗口时实施动作
// 下面将创建一个面板对象并添加到窗口容器中
final MPanel panel = new MPanel(this.getClass().getResource(
"land_background.jpg"));// 创建一个面板对象
panel.setLayout(new GridBagLayout());// 设置面板布局管理器为网格组布局
getContentPane().add(panel, BorderLayout.CENTER);// 将面板添加到窗体中
final JLabel topLabel = new JLabel();
topLabel.setPreferredSize(new Dimension(0, 126));
final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints();
gridBagConstraints_5.gridx = 0;
gridBagConstraints_5.gridy = 0;
panel.add(topLabel, gridBagConstraints_5);
final JLabel leftLabel = new JLabel();
leftLabel.setPreferredSize(new Dimension(140, 0));
final GridBagConstraints gridBagConstraints_3 = new GridBagConstraints();
gridBagConstraints_3.gridy = 1;
gridBagConstraints_3.gridx = 0;
panel.add(leftLabel, gridBagConstraints_3);
final JLabel rightLabel = new JLabel();
rightLabel.setPreferredSize(new Dimension(55, 0));
final GridBagConstraints gridBagConstraints_2 = new GridBagConstraints();
gridBagConstraints_2.gridy = 1;
gridBagConstraints_2.gridx = 1;
panel.add(rightLabel, gridBagConstraints_2);
// 创建并设置用户名下拉菜单
usernameComboBox = new JComboBox();// 创建用户名下拉菜单组件对象
usernameComboBox.setMaximumRowCount(5);// 设置下拉菜单最多可显示选项数
usernameComboBox.addItem("请选择");// 为下拉菜单添加提醒项
usernameComboBox
.addActionListener(new UsernameComboBoxActionListener());// 为下拉菜单添加事件监听器
final GridBagConstraints gridBagConstraints = new GridBagConstraints();// 创建网格组布局管理器对象
gridBagConstraints.anchor = GridBagConstraints.WEST;// 设置为靠左侧显示
gridBagConstraints.gridy = 1;// 设置行索引为1
gridBagConstraints.gridx = 2;// 设置列索引为2
panel.add(usernameComboBox, gridBagConstraints);// 将组件按指定布局管理器添加到面板中
// 创建并设置密码框
passwordField = new JPasswordField();// 创建密码框组件对象
passwordField.setColumns(20);// 设置密码框可显示字符数
passwordField.setText(" ");// 设置密码框默认显示6个空格
passwordField.addFocusListener(new PasswordFieldFocusListener());// 为密码框添加焦点监听器
final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints();// 创建网格组布局管理器对象
gridBagConstraints_1.insets = new Insets(5, 0, 0, 0);// 设置组件外部上方填充量为5像素
gridBagConstraints_1.anchor = GridBagConstraints.WEST;// 设置为靠左侧显示
gridBagConstraints_1.gridy = 2;// 设置行索引为2
gridBagConstraints_1.gridx = 2;// 设置列索引为2
panel.add(passwordField, gridBagConstraints_1);// 将组件按指定布局管理器添加到面板中
// 创建并设置一个用来添加三个按钮面板
final JPanel buttonPanel = new JPanel();// 创建一个用来添加按钮面板
buttonPanel.setOpaque(false);// 设置面板背景为透明
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));// 设置面板采取水平箱布局
final GridBagConstraints gridBagConstraints_4 = new GridBagConstraints();// 创建网格组布局管理器对象
gridBagConstraints_4.insets = new Insets(10, 0, 0, 0);// 设置组件外部上方填充量为10像素
gridBagConstraints_4.gridwidth = 2;// 设置其占两列
gridBagConstraints_4.gridy = 3;// 设置行索引为3
gridBagConstraints_4.gridx = 1;// 设置列索引为1
panel.add(buttonPanel, gridBagConstraints_4);// 将组件按指定布局管理器添加到面板中
// 创建并设置一个登录按钮,并将其添加到用来添加按钮面板中
final JButton landButton = new JButton();// 创建登录按钮组件对象
landButton.setMargin(new Insets(0, 0, 0, 0));// 设置按钮边框和标签之间间隔
landButton.setContentAreaFilled(false);// 设置不绘制按钮内容区域
landButton.setBorderPainted(false);// 设置不绘制按钮边框
URL landUrl = this.getClass().getResource("land_submit.png");// 取得默认情况下登录按钮显示图片URL
landButton.setIcon(new ImageIcon(landUrl));// 设置默认情况下登录按钮显示图片
URL landOverUrl = this.getClass().getResource(
"land_submit_over.png");// 取适当鼠标经过登录按钮时显示图片URL
landButton.setRolloverIcon(new ImageIcon("land_submit_over.png"));// 设置当鼠标经过登录按钮时显示图片
URL landPressedUrl = this.getClass().getResource(
"land_submit_pressed.png");// 取适当登录按钮被按下时显示图片URL
landButton.setPressedIcon(new ImageIcon("land_submit_pressed.png"));// 设置当登录按钮被按下时显示图片
landButton.addActionListener(new LandButtonActionListener());// 为登录按钮添加事件监听器
buttonPanel.add(landButton);// 将登录按钮添加到用来添加按钮面板中
final JButton resetButton = new JButton();
resetButton.setMargin(new Insets(0, 0, 0, 0));
resetButton.setContentAreaFilled(false);
resetButton.setBorderPainted(false);
URL resetUrl = this.getClass().getResource("land_reset.png");
resetButton.setIcon(new ImageIcon(resetUrl));
URL resetOverUrl = this.getClass().getResource(
"land_reset_over.png");
resetButton.setRolloverIcon(new ImageIcon("land_reset_over.png"));
URL resetPressedUrl = this.getClass().getResource(
"land_reset_pressed.png");
resetButton.setPressedIcon(new ImageIcon(resetPressedUrl));
resetButton.addActionListener(new ResetButtonActionListener());
buttonPanel.add(resetButton);
final JButton exitButton = new JButton();
exitButton.setMargin(new Insets(0, 0, 0, 0));
exitButton.setContentAreaFilled(false);
exitButton.setBorderPainted(false);
URL exitUrl = this.getClass().getResource("land_exit.png");
exitButton.setIcon(new ImageIcon(exitUrl));
URL exitOverUrl = this.getClass()
.getResource("land_exit_over.png");
exitButton.setRolloverIcon(new ImageIcon(exitOverUrl));
URL exitPressedUrl = this.getClass().getResource(
"land_exit_pressed.png");
exitButton.setPressedIcon(new ImageIcon(exitPressedUrl));
exitButton.addActionListener(new ExitButtonActionListener());
buttonPanel.add(exitButton);
//
// 初始化用户名下拉菜单
Vector userNameV = Dao.getInstance().sUserNameOfNotFreeze();
if (userNameV.size() == 0) {
usernameComboBox.addItem("TSoft");
} else {
for (int i = 0; i < userNameV.size(); i++) {
usernameComboBox.addItem(userNameV.get(i));
}
}
}
class UsernameComboBoxActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String userName = (String) usernameComboBox.getSelectedItem();
if (userName.equals("TSoft"))
passwordField.setText("111");
}
}
class PasswordFieldFocusListener implements FocusListener {
public void focusGained(FocusEvent e) {
passwordField.setText("");
}
public void focusLost(FocusEvent e) {
char[] passwords = passwordField.getPassword();
String password = turnCharsToString(passwords);
if (password.length() == 0) {
passwordField.setText(" ");
}
}
}
class ExitButtonActionListener implements ActionListener {
public void actionPerformed(ActionEvent arg0) {
System.exit(0);
}
}
class ResetButtonActionListener implements ActionListener {
public void actionPerformed(ActionEvent arg0) {
usernameComboBox.setSelectedIndex(0);
passwordField.setText(" ");
}
}
class LandButtonActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String username = usernameComboBox.getSelectedItem().toString();// 取得登录用户名称
if (username.equals("请选择")) {// 查看是否选择了登录用户
JOptionPane.showMessageDialog(null, "请选择登录用户!", "友谊提醒",
JOptionPane.INFORMATION_MESSAGE);// 弹出提醒
resetUsernameAndPassword();// 恢复登录用户和登录密码
}
char[] passwords = passwordField.getPassword();// 取得登录用户密码
String inputPassword = turnCharsToString(passwords);// 将密码从char型数组转换成字符串
if (username.equals("JAVA")) {// 查看是否为默认用户登录
if (inputPassword.equals("123456")) {// 查看密码是否为默认密码
land(null);// 登录成功
String infos[] = { "请立即单击“用户管理”按钮添加用户!",
"添加用户后需要重新登录,本系统才能正常使用!" };// 组织提醒信息
JOptionPane.showMessageDialog(null, infos, "友谊提醒",
JOptionPane.INFORMATION_MESSAGE);// 弹出提醒
} else {// 密码错误
JOptionPane.showMessageDialog(null,
"默认用户“TSoft”登录密码为“111”!", "友谊提醒",
JOptionPane.INFORMATION_MESSAGE);// 弹出提醒
passwordField.setText("111");// 将密码设置为默认密码
}
} else {
if (inputPassword.length() == 0) {// 用户未输入登录密码
JOptionPane.showMessageDialog(null, "请输入登录密码!", "友谊提醒",
JOptionPane.INFORMATION_MESSAGE);// 弹出提醒
resetUsernameAndPassword();// 恢复登录用户和登录密码
}
Vector user = Dao.getInstance().sUserByName(username);// 查询登录用户
String password = user.get(5).toString();// 取得登录用户密码
if (inputPassword.equals(password)) {// 查看登录密码是否正确
land(user);// 登录成功
} else {// 登录密码错误
JOptionPane.showMessageDialog(null, "登录密码错误,请确定后重新登录!",
"友谊提醒", JOptionPane.INFORMATION_MESSAGE);// 弹出提醒
resetUsernameAndPassword();// 恢复登录用户和登录密码
}
}
}
private void resetUsernameAndPassword() {// 恢复登录用户和登录密码
usernameComboBox.setSelectedIndex(0);// 恢复选中登录用户为“请选择”项
passwordField.setText(" ");// 恢复密码框默认值为6个空格
return;// 直接返回
}
private void land(Vector user) {// 登录成功
TipWizardFrame tipWizard = new TipWizardFrame(user);// 创建主窗体对象
tipWizard.setVisible(true);// 设置主窗体可见
setVisible(false);// 设置登录窗口不可见
}
}
private String turnCharsToString(char[] chars) {
StringBuffer strBuf = new StringBuffer();
for (int i = 0; i < chars.length; i++) {
strBuf.append(chars[i]);
}
return strBuf.toString().trim();
}
}
数据库连接代码:
package com.mwq.dao;
import java.sql.Connection;
import java.sql.DriverManager;
public class JDBC {
private String JDBC="jdbc:mysql://localhost:3306/drinkhome";
private String dbUserName="root";
private String dbPassword="123456";
private String jdbcName="com.mysql.jdbc.Driver";
/**
获取数据库连接
**/
public Connection getCon() throws Exception{
Class.forName(jdbcName);
Connection con=DriverManager.getConnection(JDBC, dbUserName,dbPassword);
return con;
}
/*
* 关闭数据库连接
*
* */
public void closeCon(Connection con) throws Exception{
if(con!=null){
con.close();
}
}
public static void main(String[]args){
JDBC JDBC =new JDBC() ;
try {
JDBC.getCon();
System.out.println("数据库连接成功");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("数据库连接失败");
}
}
public static Connection getConnection() {
// TODO Auto-generated method stub
return null;
}
}
日期类代码:
package com.mwq.tool;
import java.util.Calendar;
public class Today {
private static final Calendar NOW = Calendar.getInstance();
private static final int YEAR = NOW.get(Calendar.YEAR);
private static final int MONTH = NOW.get(Calendar.MONTH) + 1;
private static final int DAY = NOW.get(Calendar.DAY_OF_MONTH);
private static final int WEEK = NOW.get(Calendar.DAY_OF_WEEK);
private static final int HOUR = NOW.get(Calendar.HOUR_OF_DAY);
private static final int MINUTE = NOW.get(Calendar.MINUTE);
private static final int SECOND = NOW.get(Calendar.SECOND);
//
public static String getDate() {
return YEAR + "-" + MONTH + "-" + DAY;
}
public static String getDateOfNum() {
String y = YEAR + "";
String m = MONTH + "";
String d = DAY + "";
if (MONTH < 10)
m = "0" + MONTH;
if (DAY < 10)
d = "0" + DAY;
return y + m + d;
}
public static String getDateOfShow() {
return YEAR + "年" + MONTH + "月" + DAY + "日";
}
public static String getDayOfWeek() {
String dayOfWeek = "";
switch (WEEK) {
case 1:
dayOfWeek = "星期日";
break;
case 2:
dayOfWeek = "星期一";
break;
case 3:
dayOfWeek = "星期二";
break;
case 4:
dayOfWeek = "星期三";
break;
case 5:
dayOfWeek = "星期四";
break;
case 6:
dayOfWeek = "星期五";
case 7:
dayOfWeek = "星期六";
break;
}
return dayOfWeek;
}
public static String getTime() {
return HOUR + ":" + MINUTE + ":" + SECOND;
}
public static void main(String[] args) {
System.out.println(Today.getDayOfWeek());
}
public static int getYEAR() {
return YEAR;
}
public static int getDAY() {
return DAY;
}
public static int getMONTH() {
return MONTH;
}
}
利用正则表示式验证数据正当性方法代码:
package com.mwq.tool;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Validate {
public static boolean execute(String rule, String content) {
Pattern pattern = Ppile(rule);// 利用验证规则创建Pattern对象
Matcher matcher = pattern.matcher(content);// 利用验证内容取得Matcher对象
return matcher.matches();// 返回验证结果
}
}
按钮类:
package com.mwq.mwing;
import java.awt.Insets;
impo
展开阅读全文