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

📄 changeframe.java

📁 酒店管理系统·可用于一般旅社的营业操作。方便你的酒店管理
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * 说明:换房 */package com.redingsoft.openroom;import com.redingsoft.sql.SetSQL;import java.awt.Dimension;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.ResultSet;import java.sql.SQLException;import javax.swing.*;/** * * @author Administrator */public class ChangeFrame extends JDialog implements ActionListener{   //声明2个标签    JLabel jl1,jl2;    //声明二个文本框    JTextField tf1,tf2;    //声明一个按钮    JButton bt1,bt2;    //声明面板    JPanel jp1;    //声明一个响亮        //构造方法   public ChangeFrame(){   //实例化 标签       jl1=new JLabel("原房间号");       jl2=new JLabel("换到房间号");      //实例化文本框       tf1=new JTextField(15);       tf2=new JTextField(15);       //实例按钮       bt1=new JButton("交换");       bt2=new JButton("取消");       //实例化面板       jp1=new JPanel();       //添加组件到面板       jp1.add(jl1);       jp1.add(tf1);       jp1.add(jl2);       jp1.add(tf2);       jp1.add(bt1);       jp1.add(bt2);              //设置面板参数       jp1.setSize(new Dimension(200,200));       jp1.setBorder(BorderFactory.createTitledBorder(jp1.getBorder(), "换房"));       ///////////////////       bt1.addActionListener(this);       bt2.addActionListener(this);       this.add(jp1);       this.setSize(new Dimension(200,200));       this.setDefaultCloseOperation(ChangeFrame.DISPOSE_ON_CLOSE);       this.setTitle("换房");       this.setVisible(true);         }/*   public static void main(String [] aa){      new ChangeFrame();   }*/    public void actionPerformed(ActionEvent e) {      //  throw new UnsupportedOperationException("Not supported yet.");        Object o=e.getSource();        String id=tf1.getText();        String toid=tf2.getText();         ResultSet rs=null;        String sql="select * from inlive where r_no='"+id+"'";         String date[][] =new String[1][8];         int day=0;         float account1 = 0,foregift1 = 0;        if(o==bt1){                   if(rs==null){                try {                    rs= SetSQL.executeQuery(sql);                    while (rs.next()) {                       date[0][0]=(rs.getString("In_no")); //0                       date[0][1]=(rs.getString("r_type"));//1                       date[0][2]=(rs.getString("c_type"));//2                       date[0][3]=(rs.getString("c_name"));//3                       date[0][4]=(rs.getString("sex"));//4                       date[0][5]=(rs.getString("zj_no"));//5                       date[0][6]=(rs.getString("in_time"));//6                       day=(rs.getInt("days"));//7                       account1=(rs.getFloat("account"));//8                       foregift1=(rs.getFloat("foregift"));//9                           date[0][7]=(rs.getString("remark"));//10                                  }                    if(date.length>7){                      WarnMsg("提示","换房失败!此房间不允许换房!");                    }else{                 String     account2 =  String.valueOf(account1);                 String     foregift2=String.valueOf(foregift1);                  String liveinfo="insert into inlive(in_no,r_no,r_type,c_type,c_name,sex,zj_no,in_time,days," +                          "account,foregift,remark,cluemark,statemark)" +                  "values('"+date[0][0]+"','"+toid+"','"+date[0][1]+ "','"+date[0][2]+"','"+date[0][3]+"','"+date[0][4]+                          "','"+date[0][5]+"','"+date[0][6]+"',"+day+","+account2+","+foregift2+",'"+date[0][7]+"',0,1)";                                  int j= SetSQL.executeUpdate(liveinfo);                            if(j!=0){                  WarnMsg("提示","换房成功!");                  String update1="update roominfo set state='"+"可供"+"'"+"where id='"+id+"'";                  String update2="update roominfo set state='"+"不可供"+"' where id='"+toid+"'";                  String delsql="delete from inlive where r_no='"+id+"'";                  SetSQL.executeUpdate(update2);                  SetSQL.executeUpdate(update1);                  SetSQL.executeUpdate(delsql);                  }else{                   WarnMsg("提示","换房失败!");                  }                    }                } catch (SQLException ex) {                  //  Logger.getLogger(ChangeFrame.class.getName()).log(Level.SEVERE, null, ex);                     WarnMsg("提示","没有此房间的开房信息不可以兑换!");                }           }else{            WarnMsg("提示","没有此房间的开房信息不可以兑换!");           }        }//end if(o==bt1)        if(o==bt2){        this.dispose();        }    }/*******************************************************     * 函数名称: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); }}

⌨️ 快捷键说明

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