java课程设计:基于swing + mysql的酒店管理系统_基于java swing的酒店管理系统-爱代码爱编程
一、项目介绍
项目功能
1、散客开单:完成散客的开单,可一次最多开5间相同类型的房间。
2、团体开单:完成团体的开单,开放数量没有限制,可同时开不同类型的房间。
3、宾客结帐:自动统计每个登记客人在店时所发生的消费额和应付款额,并完成结帐收银操作。
4、客房预订:完成增加预订、修改预订、删除预订,预订情况的查询等功能。
5、营业查询:完成结帐单、全部宾客消费、在店宾客消费、离店宾客消费的查询
6、客户管理:完成会员基本信息的维护和来宾一览。
7、网络设置:完成系统与数据库的连接设置和系统风格的设置。
8、系统设置:完成房间项目、客户类型、操作员、计费设置。
二、项目展示
登录页面
主页面
系统设计
客户管理
客户预定
收银结账
团体开单
散客开单
三、源码展示
登录
public Login() {
super("系 统 登 录");
top = new JLabel (new ImageIcon("pic/login_top.gif"));
bott = new JLabel();
panelMain = new JPanel(new BorderLayout(10, 10));
bott.setBorder(new LineBorder (new Color(184, 173, 151)));
buildCenter();
panelMain.add("North", top);
panelMain.add("South", bott);
panelMain.add(panelInfo);
//加事件监听
bt1.addActionListener(this);
bt2.addActionListener(this);
bt1.addFocusListener (this);
bt2.addFocusListener (this);
bt1.addKeyListener (this);
bt2.addKeyListener (this);
cb.addItemListener (this);
cb.addFocusListener(this);
pf.addFocusListener(this);
cb.addKeyListener (this);
pf.addKeyListener (this);
//加窗口监听 new WindowAdapter适配器类
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
quit();
}//End windowClosing
});
this.setContentPane(panelMain); //设置窗口面板
this.setSize(350, 235);
this.setResizable (false); //设置窗口不可放大缩小
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
sunswing.setWindowCenter(this);
this.setVisible(true);
pf.requestFocus(true); //设置焦点给密码框
}
构造函数
//构造函数
public CheckOut(JFrame frame) {
super (frame, "收银结账", true);
panelMain = new JPanel(new GridLayout(2, 1, 0, 0)); //主面板为(2,1)表格布局
p1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));//上半部分为(4,1)表格布局
p2 = new JPanel(new BorderLayout(15, 0)); //下半部分为边界布局
buildP1();//构造上半面板
buildP2();//构造下半面板
panelMain.add(p1);
panelMain.add(p2);
addListener();
this.setContentPane(panelMain);
this.setPreferredSize (new Dimension(640, 450));
this.setMinimumSize (new Dimension(640, 450));
this.setResizable(false); //不允许改变窗口大小
pack();
sunswing.setWindowCenter(this); //窗口屏幕居中
}
//加事件监听
private void addListener() {
tf1.addActionListener(this);
tf2.addActionListener(this);
tf3.addActionListener(this);
bt1.addActionListener(this);
bt2.addActionListener(this);
bt1.addMouseListener(this);
bt2.addMouseListener(this);
}
//构造上半面板
private void buildP1() {
JPanel p11,p111,p112,p113,
p12,p121,p122,p123,p124,
p13,p131,p132,p133,
p14,p141,p142,p15;
JLabel lb1,lb2,lb3,lb4,lb5,lb6,lb7,lb8,lb9,lb10,lb11;
p11 = new JPanel(new FlowLayout(FlowLayout.LEFT,5,3)); //放置结账单号...一行
p111 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置结账单号
p112 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置结账房间
p113 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置宾客姓名
p12 = new JPanel(new FlowLayout(FlowLayout.LEFT,10,3));//放置应收金额...一行
p121 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置应收金额
p122 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置已收押金
p123 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置优惠金额
p124 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置消费金额
p13 = new JPanel(new FlowLayout(FlowLayout.LEFT,10,3));//放置实收金额...一行
p131 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置实收金额
p132 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置宾客支付
p133 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置找零
p14 = new JPanel(new FlowLayout(FlowLayout.LEFT,10,3));//放置结账备注...一行
p141 = new JPanel(new FlowLayout(FlowLayout.LEFT,0,3)); //放置结账备注
p142 = new JPanel(new FlowLayout(FlowLayout.LEFT,33,3)); //放置按钮
p15 = new JPanel(new GridLayout(3,1,0,5));
lb1 = new JLabel("结账单号:");
lb2 = new JLabel(" 结账房间:");
lb3 = new JLabel(" 宾客姓名:");
lb4 = new JLabel("消费金额:");
lb5 = new JLabel(" 应收金额:");
lb6 = new JLabel(" 已收押金:");
lb7 = new JLabel(" 优惠金额:");
lb8 = new JLabel("实收金额:");
lb9 = new JLabel(" 宾客支付:");
lb10 = new JLabel(" 找 零:");
lb11 = new JLabel("结账备注:");
lb1.setFont(new Font("宋体",Font.BOLD,15));
lb2.setFont(new Font("宋体",Font.BOLD,15));
lb3.setFont(new Font("宋体",Font.BOLD,15));
lb4.setFont(new Font("宋体",Font.BOLD,15));
lb5.setFont(new Font("宋体",Font.BOLD,15));
lb6.setFont(new Font("宋体",Font.BOLD,15));
lb7.setFont(new Font("宋体",Font.BOLD,15));
lb10.setFont(new Font("宋体",Font.BOLD,15));
lb4.setForeground(Color.blue);
lb5.setForeground(Color.blue);
lb6.setForeground(Color.blue);
lb7.setForeground(Color.blue);
lb10.setForeground(Color.blue);
lbA = new JLabel("ZD200604210001");
lbB = new JLabel("BD001");
lbC = new JLabel("你好吗");
lbD = new JLabel("500.00");
lbE = new JLabel("450.00");
lbF = new JLabel("300.00");
lbG = new JLabel("50.00");
lbH = new JLabel("¥0.00");
lbA.setFont(new Font("宋体",Font.BOLD,15));
lbB.setFont(new Font("宋体",Font.BOLD,15));
lbC.setFont(new Font("宋体",Font.BOLD,15));
lbD.setFont(new Font("宋体",Font.BOLD,15));
lbE.setFont(new Font("宋体",Font.BOLD,15));
lbF.setFont(new Font("宋体",Font.BOLD,15));
lbG.setFont(new Font("宋体",Font.BOLD,15));
lbH.setFont(new Font("宋体",Font.BOLD,15));
lbA.setForeground(Color.blue);
lbB.setForeground(Color.blue);
lbC.setForeground(Color.blue);
lbD.setForeground(Color.blue);
lbE.setForeground(Color.red);
lbF.setForeground(Color.red);
lbG.setForeground(Color.red);
lbH.setForeground(Color.red);
tf1 = new TJMoneyField("0.00",10);
tf2 = new TJMoneyField("0.00",10);
tf3 = new TJTextField(20);
bt1 = new TJButton("pic/u04.gif", " 结 账 ", "结算房费");
bt2 = new TJButton("pic/cancel.gif", " 取 消 ", "取消结账");
//第一行
p111.add(lb1);
p111.add(lbA);
p112.add(lb2);
p112.add(lbB);
p113.add(lb3);
p113.add(lbC);
p11.add(p111);
p11.add(p112);
p11.add(p113);
p11.setBorder(BorderFactory.createTitledBorder(""));
//第二行
p121.add(lb4);
p121.add(lbD);
p122.add(lb5);
p122.add(lbE);
p123.add(lb6);
p123.add(lbF);
p124.add(lb7);
p124.add(lbG);
p12.add(p121);
p12.add(p122);
p12.add(p123);
p12.add(p124);
//第三行
p131.add(lb8);
p131.add(tf1);
p132.add(lb9);
p132.add(tf2);
p133.add(lb10);
p133.add(lbH);
p13.add(p131);
p13.add(p132);
p13.add(p133);
//第四行
p141.add(lb11);
p141.add(tf3);
p142.add(bt1);
p142.add(bt2);
p14.add(p141);
p14.add(p142);
p15.add(p12);
p15.add(p13);
p15.add(p14);
p15.setBorder(BorderFactory.createTitledBorder(""));
p1.add(p11);
p1.add(p15);
}
添加会员
public AddHuiYuan (JDialog dialog) {
super(dialog, "添加会员",true);
panelMain = new JPanel(new BorderLayout(0,0));
buildPanel();
addListener();
this.setContentPane(panelMain);
this.setPreferredSize (new Dimension (300,300));
this.setMinimumSize (new Dimension (300,300));
this.setResizable(false); //不允许改变窗口大小
pack();
sunswing.setWindowCenter(this); //窗口屏幕居中
}
预定修改
public ModiEngage (JDialog dialog) {
super(dialog, "客房预订修改",true);
panelMain = new JPanel(new BorderLayout ());
ps = new JPanel(new FlowLayout(FlowLayout.CENTER,20,10));//放按钮
pc = new JPanel(new BorderLayout());//除去按钮其他部分放在一个面板里
buildPane();
panelMain.add(pc);
panelMain.add("South",ps);
addListener();
this.setContentPane(panelMain);
this.setPreferredSize (new Dimension (280,415));
this.setMinimumSize (new Dimension (280,415));
this.setResizable(false); //不允许改变窗口大小
pack();
sunswing.setWindowCenter(this); //窗口屏幕居中
}
创建面板
private void buildPane() {
pcs = new JPanel(new FlowLayout(FlowLayout.CENTER,5,5));//放置JCheckBox
pcc = new JPanel(new BorderLayout());//放置备注以上,tf以下的控件
pccs = new JPanel(new FlowLayout(FlowLayout.CENTER,5,5));//放置备注
pccw = new JPanel(new BorderLayout());//放置列表左边的控件
pccwc = new JPanel(new FlowLayout(FlowLayout.CENTER,5,10));//放置填写项目
pccwc1 = new JPanel(new GridLayout(6,1,0,14));//放置标签
pccwc2 = new JPanel(new GridLayout(6,1,0,5));//放置文本框和下拉列表框
JLabel lb1,lb2,lb3,lb4,lb5,lb6,lb7,lb8;
lb1 = new JLabel("宾客姓名:");
lb2 = new JLabel("联系电话:");
lb3 = new JLabel("预定规格:");
lb4 = new JLabel("房间编号:");
lb5 = new JLabel("预抵时间:");
lb6 = new JLabel("保留时间:");
pccwc1.add(lb1);
pccwc1.add(lb2);
pccwc1.add(lb3);
pccwc1.add(lb4);
pccwc1.add(lb5);
pccwc1.add(lb6);
tf1 = new JTextField(12);
tf2 = new JTextField(12);
tf3 = new TJTextField(12);
tf4 = new TJTextField(12);
tf1.setEditable(false);
tf2.setEditable(false);
cb1 = new JComboBox();//公共类刷新
sunsql.initJComboBox(cb1,"select r_type from roomtype where delmark = 0");
cb2 = new JComboBox();
String s = cb1.getSelectedItem()+"";
sunsql.initJComboBox(cb2,"select a.id from roominfo as a,roomtype as b where b.r_type = '"+s+"' and a.r_type_id = b.id and a.state = '可供' and a.delmark = 0 and b.delmark = 0");
pccwc2.add(tf1);
pccwc2.add(tf2);
pccwc2.add(cb1);
pccwc2.add(cb2);
pccwc2.add(tf3);
pccwc2.add(tf4);
pccwc.add(pccwc1);
pccwc.add(pccwc2);
pccw.add(pccwc);
dtm1 = new DefaultTableModel();
tb1 = new JTable(dtm1);
sp1 = new JScrollPane(tb1);
String sqlCode1 = "select a.r_type 预定规格,b.r_no 房间 from roomtype as a,engage1 as b where a.id = b.r_type_id";
sunsql.initDTM(dtm1,sqlCode1);
lb8 = new JLabel("备 注:");
ta = new TJTextArea(3,12);
sp2 = new JScrollPane(ta);
pccs.add(lb8);
pccs.add(sp2);
pcc.add("South",pccs);
pcc.add(pccw);
chk = new JCheckBox(" 到达保留时间是否自动取消预定");
pcs.add(chk);
bt1 = new TJButton ("pic/save.gif", "保 存", "保存预定信息");
bt2 = new TJButton ("pic/cancel.gif", "取 消", "取消操作");
ps.add(bt1);
ps.add(bt2);
tf = new JTextField("基本预定信息");
tf.setHorizontalAlignment (JTextField.CENTER);
tf.setBackground(new Color(199,183,143));
tf.setBorder(new LineBorder(new Color(87,87,47)));
tf.setEditable(false);
pc.add("North",tf);
pc.add(pcc);
pc.add("South",pcs);
pc.setBorder(BorderFactory.createTitledBorder(""));
}
散客开单
public Individual(JFrame frame) {
super (frame, "散客开单", true);
panelMain = new JPanel(new BorderLayout()); //主面板为边界布局,确定取消按钮放South
buildPanel();
addListener();
this.setContentPane(panelMain);
this.setPreferredSize (new Dimension (530,510));
this.setMinimumSize (new Dimension (530, 510));
this.setResizable(false); //不允许改变窗口大小
pack();
sunswing.setWindowCenter(this); //窗口屏幕居中
}
四、源码获取
因为页面与源码太多了,所以页面与源码只展示了一部分,完整源码已经打包了,点击下面蓝色链接获取!