⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 singleopenframe.java

📁 酒店管理系统·可用于一般旅社的营业操作。方便你的酒店管理
💻 JAVA
字号:
/* * 文件名:SingleopenFrame.java * 说明:散客开房 */package com.redingsoft.openroom;import com.redingsoft.locationutil.LocationUtil;import com.redingsoft.sql.SetSQL;import com.redingsoft.sunsdk.swing.OJButton;import com.redingsoft.sunsdk.swing.xtwh_table;import com.redingsoft.timeutil.Util;import com.redingsoft.timeutil.gettimer;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.ResultSet;import java.sql.SQLException;import javax.swing.*;import javax.swing.table.DefaultTableModel;/** * * @author Administrator */public class SingleopenFrame extends JDialog implements ActionListener,Runnable{     //声明标签public static    JLabel jl1,jl2,jl3,jl4,  //房间说明信息            jl11,jl12,jl13,jl14, //显示详细房间            jl21,jl22,jl23,jl24,jl25,jl26;  //显示用户录入提示 public static   JTextField tf1,tf2,tf3,tf4;    //声明2个单选按钮    JRadioButton rb1,rb2;    //声明一个按钮组   ButtonGroup gb;    //声明1个复选框    JCheckBox jcb;    //声明2个下拉列表    JComboBox cb1,cb2;    //声明2个按钮    JButton bt1,bt2,bt3;    //声明2个表格    JTable tb1,tb2;    //声明表模式    DefaultTableModel dftm1,dftm2;    //声明2个滚滚东面板    JScrollPane sp1,sp2;    //声明面板    JPanel topPane,centerPane,bottPane,mainPane,secondMain,            jp1,jp2,jp3,jp4,jp5,jp6;    //声明标签面板    JTabbedPane TabbedPane;    //声明数组初始化表模式    String cols[]={"房间编号","房间类型"};    String[][] rows=new String[0][2];   String sql=null; //存放初始化表格的数据库操作语句    private JLabel jl27;    private JTextField tf5;    boolean flag=false; //标志表中是否又数据public    static String  intime; //入住时间    //构造方法    public  SingleopenFrame(){               //实例化标签        jl1=new JLabel("房间编号:");        jl2=new JLabel("房间类型:");        jl3=new JLabel("房间价格:");        jl4=new JLabel("房间押金:");        jl11=new JLabel("房间编号");  //房间编号        jl12=new JLabel("房间类型"); //房间类型        jl13=new JLabel("房间价格");  //房间价格        jl14=new JLabel("房间押金");  //房间押金        jl11.setForeground(Color.RED);         jl12.setForeground(Color.RED);         jl13.setForeground(Color.RED);         jl14.setForeground(Color.RED);         jl11.setFont(new Font("宋体",Font.BOLD,15));        jl12.setFont(new Font("宋体",Font.BOLD,15));        jl13.setFont(new Font("宋体",Font.BOLD,15));        jl14.setFont(new Font("宋体",Font.BOLD,15));        /////////////////////提示输入信息        jl21=new JLabel("客人姓名:");        jl22=new JLabel("客人类型:");        jl23=new JLabel("证件编号:");        jl24=new JLabel("客人性别:");        jl25=new JLabel("押金:");        jl26=new JLabel("预住天数:(天)");        jl27=new JLabel("备注:");        //实例化列表组合        cb1=new JComboBox();  //存放客人类型        cb2=new JComboBox();          String s1="select c_type from customertype";           SetSQL.initJComboBox(cb1, s1);        //实例化单选按钮        rb1=new JRadioButton("男");        rb2=new JRadioButton("女");        rb1.setSelected(true);        //实例化按钮组        gb=new ButtonGroup();         //添加单选按钮        gb.add(rb1);        gb.add(rb2);        //实例化复选框        jcb=new JCheckBox("勾选设置提醒");         //实例化按钮        bt1=new OJButton("com/redingsoft/pic/u03.gif","开设","给客人开房",true);        bt2=new OJButton("com/redingsoft/pic/recall.gif","取消","取消开房",true);        bt3=new OJButton("com/redingsoft/pic/b1.gif","刷新","刷新房间最新信息",true);       //实例化文本框        tf1=new JTextField(15);        tf2=new JTextField(15);        tf3=new JTextField(10);        tf4=new JTextField(5);        tf5=new JTextField(10);       //实例化表格        tb1=new JTable();        tb2=new JTable();       //实例化表模式        dftm1=new xtwh_table(rows,cols);        dftm2=new xtwh_table(rows,cols);        //设置表模式        tb1.setModel(dftm1);        tb2.setModel(dftm2);        //初始化表格        sql="select  id 房间编号,r_type_id 房间类型 from roominfo where state='"+"可供"+"'";        initTabel(sql);        //实例化滚动面板        sp1=new JScrollPane(tb1);        sp2=new JScrollPane(tb2);        //初始化滚滚东面板大小        sp1.setPreferredSize(new Dimension(250,100));        sp2.setPreferredSize(new Dimension(250,100));       //初始化面板        jp1=new JPanel();        jp2=new JPanel();        jp3=new JPanel();        jp4=new JPanel();        jp5=new JPanel();        jp6=new JPanel();        /////////////////////////////////////        topPane=new JPanel();        centerPane=new JPanel(new FlowLayout(FlowLayout.LEADING,1,10));        bottPane=new JPanel();        mainPane=new JPanel(new BorderLayout());        secondMain=new JPanel(new BorderLayout());        TabbedPane=new JTabbedPane();        ////////////////////添加房间信息标签到topPane        topPane.add(jl1);        topPane .add(jl11);        topPane.add(jl2);        topPane.add(jl12);        topPane.add(jl3);        topPane.add(jl13);        topPane.add(jl4);        topPane.add(jl14);        //////////////////////        jp1.add(jl22);        jp1.add(cb1); //客户类型        jp2.add(jl21); //客人姓名        jp2.add(tf1);        jp3.add(jl23);//证件biah        jp3.add(tf2);        jp4.add(jl24); //客人性别        jp4.add(rb1);        jp4.add(rb2);        jp5.add(jl26); //预住天数        jp5.add(tf3);        jp5.add(jl25); //押金        jp5.add(tf4);          jp5.add(jl27);  //备注        jp5.add(tf5);        centerPane.add(jp1);        centerPane.add(jp2);        centerPane.add(jp3);        centerPane.add(jp4);        centerPane.add(jp5);                    //添加按钮到BOTTPANE        bottPane.add(jcb);        bottPane.add(bt1);        bottPane.add(bt2);        bottPane.add(bt3);        //添加滚动面板到TabbedPane        TabbedPane.add(sp1,"可供房间信息");        TabbedPane.add(sp2,"我爱正红软件");        TabbedPane.setForeground(Color.RED);         TabbedPane.setBackground(Color.BLACK);        //设置个面板的大小        topPane.setPreferredSize(new Dimension(450,50));        centerPane.setPreferredSize(new Dimension(50,250));        bottPane.setPreferredSize(new Dimension(450,50));        secondMain.setPreferredSize(new Dimension(100,250));        TabbedPane.setPreferredSize(new Dimension(500,200));        //设置面板的边框修饰        topPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));        centerPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));        bottPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));        //c初始化标签        if(flag){        String[][] value=new String[1][2];          value[0][0]=(String) tb1.getValueAt(0, 0); //获得房间编号         value[0][1]=(String)tb1.getValueAt(0, 1);  //获得房间类型        initList(value);        }        //添加个面板到主面板        secondMain.add(BorderLayout.NORTH,topPane);        secondMain.add(BorderLayout.CENTER,centerPane);        secondMain.add(BorderLayout.SOUTH,bottPane);        mainPane.add(BorderLayout.NORTH,secondMain);        mainPane.add(BorderLayout.SOUTH, TabbedPane);        //添加事件侦听        AddTableListener(tb1);        bt1.addActionListener(this);        bt2.addActionListener(this);        bt3.addActionListener(this);                //添加到主窗口        this.add(mainPane);        this.setBounds(1, 1, 600, 500);        LocationUtil.setLocation(this);        this.setDefaultCloseOperation(SingleopenFrame.DISPOSE_ON_CLOSE);        this.setTitle("散客开房");         }                 //初始化表格/* * 函数名:public void initTabel() * 参数:null * 返回值:void * 功能:制作并初始化表格 ***********************************/public void initTabel(String sql){   //设置表格的模式    //初始化表表模式     SetSQL.initDTM(dftm1,sql);     if(dftm1.getRowCount()!=0){      tb1.setModel(dftm1);      flag=true; //    tb=new JTable();    }else{        WarnMsg("提示","还没有房间信息,请添加房间信息在进行此操作。");         flag=false;    }}////////////////////////////////////public void initTabel2(String sql){   //设置表格的模式    //初始化表表模式     SetSQL.initDTM(dftm2,sql);     if(dftm2.getRowCount()!=0){      tb2.setModel(dftm2); //    tb=new JTable();    }else{        WarnMsg("提示","还没有房间信息,请添加房间信息在进行此操作。");    }}/*******************************************************     * 函数名称:WarnMsgPane(String title ,String msg ,component null)     * 参数:tile 提示标题 msg 提示消息 显示他的父组件     * 功能:为错误的输入和连接错误做出提示     ************************************************************/ public static void WarnMsg(String title,String msg){  JOptionPane.showMessageDialog(null,msg,title,JOptionPane.WARNING_MESSAGE); }/*********************************************** public static void main(String[] gg){ new SingleopenFrame(); } ***********************************************/ /*+*++++++++++++++++++++++++++++++++++++++++++++++++++++++=  * 函数名称:public void initLabel(){}  * 参数:NULL  * 返回值:void  * 功能:初始化信息标签  **+++++++++++++++++++++++++++++++++++++++++++++++++++++*/ public void initList(String types[][]){    // System.out.println(types[0][0]);        String id=types[0][0],type=types[0][1],rType=null, rprice=null,foregift=null;           try {  String s2="select * from roomtype where  id='"+type+"'";  ResultSet  rs2=SetSQL.executeQuery(s2);            rs2.next();           rType=rs2.getString(2);           rprice =rs2.getString(4);           foregift=rs2.getString(5);                   } catch (SQLException ex) {             System.out.println(type);         }      jl11.setText(id);     jl12.setText(rType);     jl13.setText(rprice);     jl14.setText(foregift); } //添加件表格侦听public void AddTableListener(final JTable tb1){      tb1.addMouseListener(new java.awt.event.MouseAdapter(){            @Override               public void mouseClicked(java.awt.event.MouseEvent e){         String[][] selectValue= new String[1][2]; //存储用户单击表格某一行的数据             try{             int selected=tb1.getSelectedRow();        int i=0;            int colcount=0;      for(i=0;i<2;i++){        selectValue[colcount][i]=(String)tb1.getValueAt(selected, i);   //    System.out.println(selectValue[colcount][i]);      }              }catch(Exception ex){         JOptionPane.showMessageDialog(null, "你还没有添加房间信息!");        }        initList(selectValue);    }           });}  //执行计时器    public void run() {        //throw new UnsupportedOperationException("Not supported yet.");        new gettimer();    }    public void actionPerformed(ActionEvent e) {      //  throw new UnsupportedOperationException("Not supported yet.");        Object o=e.getSource();        if(o==bt1){          String r_id=jl11.getText(); //获得房间号码           intime= Util.getNowDTime(); //获得入住时间         String checkout=intime+r_id; //获得结算单号          String type_id=jl12.getText(); //获得房间类型          String r_price=jl13.getText();//获得房间价格          String  r_yajin=jl14.getText(); //房间押金          String c_type=(String) cb1.getSelectedItem(); //获得客人类型          String c_name=tf1.getText().trim(); //客人姓名          String c_sex=null;          if(rb1.isSelected()){//获得客人性别           c_sex=rb1.getText();          }else{           c_sex=rb2.getText();           }          String zj_no=tf2.getText(); //证件编号          String yajin=tf4.getText(); //押金          String day=tf3.getText(); //预祝天数          String remark=tf5.getText(); //备注          int clmark=0;          if(jcb.isSelected()){          clmark=1;  //提醒标记          }        float  acount=Float.parseFloat(r_price)*Float.parseFloat(day)+Float.parseFloat(r_yajin); //消费            System.out.println(acount+"");              //获得服务器时间          long time=SetSQL.getPrimaryKey();          System.out.print(time+intime+"");          String roomstate="update roominfo set state='"+"不可供"+"'" +                  "where id='"+r_id+"'";          String liveinfo="insert into inlive(in_no,r_no,r_type,c_type,c_name,sex,zj_no,in_time,days,account,foregift,cluemark,statemark)" +                  "values('"+intime+"','"+r_id+"','"+type_id+ "','"+c_type+"','"+c_name+"','"+c_sex+"','"+zj_no+"','"+intime+"',"+day+","+acount+","+yajin+","+clmark+",1)";       //   String incheckout="insert into checkout(chk_no,in_no,days,money,chk_time) values('"+ checkout+"','"+intime+"',"+day+","+acount+",'过"+day+"')";           int i=SetSQL.executeUpdate(liveinfo);           if(i!=0){           SetSQL.executeUpdate(roomstate);       //    SetSQL.executeUpdate(incheckout);               WarnMsg("提示","开设房间【"+r_id+"】成功");            if(clmark==1){             Thread t1=new Thread(this);              t1.start();           }           }else{           WarnMsg("提示","开设房间【"+r_id+"】失败");           }                          }//end if(o==bt1)        if(o==bt3){ //刷新         sql="select  id 房间编号,r_type_id 房间类型 from roominfo where state='"+"可供"+"'";         initTabel(sql);        }        if(o==bt2){        this.dispose();        }    }   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -