📄 hotelframe.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.redingsoft.mainframe;import com.redingsoft.about.About;import com.redingsoft.about.help;import com.redingsoft.checkout.Checkout;import com.redingsoft.checkout.money;import com.redingsoft.customerinfo.memberJDialog;import com.redingsoft.locationutil.LocationUtil;import com.redingsoft.openroom.ChangeFrame;import com.redingsoft.openroom.SingleopenFrame;import com.redingsoft.setcrtypeframe.CrTypeFrame;import com.redingsoft.setroomframe.ManaDiglog;import com.redingsoft.setroomframe.RoominfoFrame;import com.redingsoft.setsysdialog.SetAdmin;import com.redingsoft.setsysdialog.SetSysDialog;import com.redingsoft.sql.SetSQL;import java.sql.SQLException;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.*;import java.awt.*;import java.awt.event.*;import com.redingsoft.sunsdk.swing.*; //加入公共类库import com.redingsoft.timeutil.Util;import java.sql.ResultSet;import java.text.SimpleDateFormat;import java.util.GregorianCalendar;/** * * @author Administrator */public class HotelFrame extends JFrame implements ActionListener,Runnable{//声明菜单类 private JMenuBar mb; private JMenu m1,m2,m3,m4; private JMenuItem mi11,mi12,mi13,mi14,mi15, mi21,mi22,mi23, mi31,mi32, mi41,mi42; //工具栏 private JToolBar toolb; private JButton bt1,bt2,bt3,bt4,bt5,bt6,bt7; //分割面板// private JSplitPane spanemian,spaneLeft,spaneRigth; //模板接口 private JPanel panelMain, bott, jp2, jp3, jp4,jp1; // private LeftTopPanel jp1; private JSplitPane spaneMain; Thread go; //构造函数 public HotelFrame (){ panelMain=new JPanel(new BorderLayout()); //主面板 //制作菜单 buildMenuBar(); //制作工具栏 buildToolBar(); //制作分割面板 buildSpane(); //加入组件到主面板 panelMain.add("North",toolb); //加入工具栏 // panelMain.add("South",bott); //加入低端信息 panelMain.add("Center",spaneMain); //加入中间分割面板 //加入菜单栏 this.add(panelMain); this.setJMenuBar(mb); //加事件侦听 addListener(); this.addWindowListener(new WindowAdapter () { @Override public void windowClosing (WindowEvent we) { quit (); }//End windowClosing }); // this.setBounds (2, 2, 1020, 740); this.setDefaultCloseOperation (JFrame.DO_NOTHING_ON_CLOSE); this.setTitle("正红旅社管理系统——RedingdingSoft"); // this.setBounds(2, 2, 900, 700); this.setMinimumSize (new Dimension (900, 700)); //设置窗口最小尺寸 LocationUtil.setLocation(this); this.pack(); go=new Thread(this); go.start(); this.setVisible (true); //启动时间线程 this.toFront(); //显示在最前端 //(new Thread(this)).start(); //启动房间状态检查线程 } private void buildSpane() { jp1 = new LeftTopPanel(); //这四个面板为功能接口////////////// // jp2 = new LeftBottPanel(); //左下面板 快速通道 jp2 = new RightTopPanel(); ///////////////////////////////// jp4 = new RightBottPanel(); //右下面板 消费信息表 spaneMain = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jp1, jp2); //设置面板最小尺寸 jp1.setMinimumSize(new Dimension (157, 600));// jp2.setMinimumSize(new Dimension (157, 94)); jp2.setMinimumSize(new Dimension (600, 600));// jp4.setMinimumSize(new Dimension (875, 94)); // spaneRight.setMinimumSize(new Dimension (875, 565)); //设置分割条是否有伸缩键 spaneMain.setOneTouchExpandable (true); // spaneRight.setOneTouchExpandable(true); //设置各面板的初起尺寸 spaneMain.setDividerLocation (160); // spaneLeft.setDividerLocation (450); // spaneRight.setDividerLocation(450); //设置分隔条宽度 spaneMain.setDividerSize (10); //spaneLeft.setDividerSize (23); //spaneRight.setDividerSize(23); }//制作工具栏 private void buildToolBar() { toolb=new JToolBar(); //制作按键 bt1=new TJButton("com/redingsoft/pic/ToolBar/m01.gif","散客开单","零散客入住登记",true); // bt2=new TJButton("pic/ToolBar/m02.gif","团体开单","团体客人入住登记",true); // bt3=new TJButton("pic/ToolBar/m03.gif","客房预订","预定客人登记",true); bt4=new TJButton("com/redingsoft/pic/ToolBar/m04.gif","宾客结账","客人离开时结账",true); bt5=new TJButton("com/redingsoft/pic/ToolBar/m08.gif","宾客换房","客人临时调换房间",true); bt6=new TJButton("com/redingsoft/pic/ToolBar/m06.gif","营业额查询","可以查询各个时间的营业额",true); bt7=new TJButton("com/redingsoft/pic/ToolBar/m10.gif","退出系统","可以关闭系统",true); //添加到工具栏 toolb.addSeparator(); toolb.add(bt1); // toolb.add(bt2); // toolb.add(bt3); toolb.addSeparator(); toolb.add(bt4); toolb.add(bt5); toolb.addSeparator(); toolb.add(bt6); toolb.addSeparator(); toolb.add(bt7); //设置工具栏不可浮动 toolb.setFloatable(false); } //制作菜单栏 private void buildMenuBar(){ //实例菜单栏 mb=new JMenuBar(); //实例菜单 m1=new JMenu("房间开设"); m2=new JMenu("信息查询"); m3=new JMenu("系统设置"); m4=new JMenu("关于"); //实例菜单项 mi11=new JMenuItem("散客开单"); // mi12=new JMenuItem("团体开单"); // mi13=new JMenuItem("预定房间"); mi14=new JMenuItem("房间管理"); /////////////////////////////////// mi21=new JMenuItem("基本客人信息"); mi22=new JMenuItem("房间信息"); mi23=new JMenuItem("VIP管理"); ////////////////////////////////// mi31=new JMenuItem("选择数据库连接方式"); mi32=new JMenuItem("管理员设置"); /*###########################################*/ mi41=new JMenuItem("软件帮助"); mi42=new JMenuItem("关于我们"); /////////////////////// mi32.setEnabled(true); //功能未开发 //////////////// //组织菜单 m1.add(mi11); //房间信息 // m1.add(mi12); // m1.add(mi13); m1.addSeparator(); m1.add(mi14); m2.add(mi21); //客人信息 m2.add(mi22); m2.addSeparator(); m2.add(mi23); m3.add(mi31); //系统设置 m3.add(mi32); m4.add(mi41); //关于 m4.add(mi42); mb.add(m1); //加入菜单栏 mb.add(m2); mb.add(m3); mb.add(m4); } //添加事件侦听 private void addListener(){ mi11.addActionListener(this); //开设房间// mi12.addActionListener(this);// mi13.addActionListener(this); mi14.addActionListener(this); mi21.addActionListener(this); //信息查询 mi22.addActionListener(this); mi23.addActionListener(this); mi31.addActionListener(this); //系统设置 mi32.addActionListener(this); mi41.addActionListener(this); //关于 mi42.addActionListener(this); bt1.addActionListener(this); //给工具栏按钮添加侦听// bt2.addActionListener(this); // bt3.addActionListener(this); bt4.addActionListener(this); bt5.addActionListener(this); bt6.addActionListener(this); bt7.addActionListener(this); }/////////////// /**=======================================================================** * [## private void quit () {} ]: 系统退出 * 参数 :无 * 返回值 :无 * 修饰符 :private * 功能 :关闭系统函数,仅类内使用 **=======================================================================** */ private void quit () { int flag = 0; String msg = "您 现 在 要 关 闭 系 统 吗 ?"; flag = JOptionPane.showConfirmDialog (null, msg, "提示", JOptionPane.YES_NO_OPTION); if(flag == JOptionPane.YES_OPTION) { this.setVisible (false); System.exit (0); }//End if(flag == JOptionPane.YES_OPTION) return; } public void actionPerformed(ActionEvent e) { Object o=e.getSource(); if(o==bt7){ //退出 quit(); }//endif(o==bt7) if(o==mi14){ //房间管理 JDialog manroom= new ManaDiglog(); manroom.setModalityType(Dialog.DEFAULT_MODALITY_TYPE); manroom.setVisible(true); }// end if(o==mil4) if(o==mi31){ //系统设置 new SetSysDialog(); } if(o==mi22){ //房间信息 JDialog roominfo=new RoominfoFrame(); roominfo.setModalityType(Dialog.DEFAULT_MODALITY_TYPE); roominfo.setTitle("房间信息"); roominfo.setVisible(true); }//end if(o==mi22) if(o==mi23){ JDialog member=new memberJDialog(); LocationUtil.setLocation(member); //居中显示 member.setModalityType(Dialog.DEFAULT_MODALITY_TYPE); member.setVisible(true); } if(o==mi21){ //客人信息 CrTypeFrame roomerinfo=new CrTypeFrame(); roomerinfo.setModalityType( CrTypeFrame.DEFAULT_MODALITY_TYPE); LocationUtil.setLocation(roomerinfo); roomerinfo.setVisible(true); } if(o==mi11){ //散客开单 SingleopenFrame open=new SingleopenFrame(); open.setModalityType(SingleopenFrame.DEFAULT_MODALITY_TYPE); open.setVisible(true); } if(o==mi32){ SetAdmin sys=new SetAdmin(); sys.setModalityType(SetAdmin.DEFAULT_MODALITY_TYPE); sys.setVisible(true); } if(o==bt1){ //散客开单按钮 SingleopenFrame open=new SingleopenFrame(); open.setModalityType(SingleopenFrame.DEFAULT_MODALITY_TYPE); open.setVisible(true); } if(o==bt4){//宾客结账 Checkout checkout=new Checkout(); LocationUtil.setLocation(checkout); checkout.setTitle("客人结账"); checkout.setVisible(true); }if(o==bt5){ //宾客结账 ChangeFrame change=new ChangeFrame(); LocationUtil.setLocation(change); change.setModalityType(ChangeFrame.DEFAULT_MODALITY_TYPE); change.setVisible(true); }if(o==mi41){ //帮助 help h=new help(); h.setModalityType(help.DEFAULT_MODALITY_TYPE); h.setResizable(false); h.setVisible(true); }if(o==mi42){ About about=new About(); about.setModalityType(About.DEFAULT_MODALITY_TYPE); about.setResizable(false); about.setVisible(true); }if(o==bt6){ //营业额查询 money checkm=new money(); checkm.setModalityType(money.DEFAULT_MODALITY_TYPE); checkm.setVisible(true); } } /********************* public static void main(String args[]){ new HotelFrame(); }*********************************/ public void run() { while( true ) { GregorianCalendar gc = new GregorianCalendar(); SimpleDateFormat dateformat=new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss EEE"); LeftTopPanel.tf1.setText( dateformat.format(gc.getTime())); setcount(); try { Thread.sleep(500); } catch (Exception ex) { }//End try }//End while } public void setcount(){ try { String sql="select id from roominfo where state='"+"可供"+"'"; ResultSet rs=SetSQL.executeQuery(sql); rs.last(); int count = rs.getRow(); LeftTopPanel.zjl11.setText(""+count); } catch (SQLException ex) { // Logger.getLogger(HotelFrame.class.getName()).log(Level.SEVERE, null, ex); System.out.print("asfsdfsd"); } try{ String sql2="select id from roominfo where state ='"+"不可供"+"'"; ResultSet rs2=SetSQL.executeQuery(sql2); rs2.last(); int count2 = rs2.getRow(); LeftTopPanel.zjl12.setText(""+count2); }catch(SQLException ex2){ } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -