📄 cancelroom.java~73~
字号:
package com.Register;import javax.swing.*;import com.borland.jbcl.layout.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import com.dbmanage.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class CancelRoom extends JPanel{ JPanel jPanel1 = new JPanel(); XYLayout xYLayout1 = new XYLayout(); JLabel jLabel0 = new JLabel(); JLabel jLabel3 = new JLabel(); JLabel jLabel4 = new JLabel(); JLabel jLabel5 = new JLabel(); JLabel jLabel6 = new JLabel(); JTextField jTextField3 = new JTextField(); JTextField jTextField4 = new JTextField(); JTextField jTextField5 = new JTextField(); JLabel infoPanel = new JLabel(); JLabel jLabel1 = new JLabel(); JTextField jTextField1 = new JTextField(); JLabel jLabel2 = new JLabel(); JTextField jTextField2 = new JTextField(); JTextField jTextField6 = new JTextField(); JLabel jLabel7 = new JLabel(); JLabel jLabel8 = new JLabel(); JTextField jTextField7 = new JTextField(); JTextField jTextField8 = new JTextField(); JLabel jLabel9 = new JLabel(); JTextField jTextField9 = new JTextField(); JLabel jLabel10 = new JLabel(); JTextField jTextField10 = new JTextField(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JLabel jLabel11 = new JLabel(); XYLayout xYLayout2 = new XYLayout(); ////// private String searchName; private long searchIDNo; private String RoomNo; //房间识别号 private int CustNo;// 住宿人数 //private String outPut;//输出结果 private String iClass; // 房间类别 private float StandardPri;//标准价 private float RebatePri;//折后价 private float Deposit;// 押金 private String Operator; public CancelRoom() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { jLabel0.setFont(new java.awt.Font("SansSerif", 1, 22)); jLabel0.setForeground(Color.red); jLabel0.setHorizontalAlignment(SwingConstants.CENTER); jLabel0.setText("客户退房界面"); jLabel0.setVerticalAlignment(SwingConstants.CENTER); xYLayout1.setWidth(587); xYLayout1.setHeight(787); jPanel1.setLayout(xYLayout1); jPanel1.setBackground(SystemColor.textHighlightText); jPanel1.setFont(new java.awt.Font("SansSerif", 3, 20)); jPanel1.setForeground(Color.red); jPanel1.setOpaque(true); jPanel1.setToolTipText(""); jLabel3.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel3.setForeground(Color.black); jLabel3.setText("客户ID"); jLabel4.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel4.setForeground(Color.black); jLabel4.setHorizontalAlignment(SwingConstants.CENTER); jLabel4.setText("房间类别"); jLabel5.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel5.setForeground(Color.black); jLabel5.setToolTipText(""); jLabel5.setText("标准价"); jLabel6.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel6.setForeground(Color.black); jLabel6.setHorizontalAlignment(SwingConstants.CENTER); jLabel6.setText("折后价"); jTextField3.setEditable(false); jTextField3.setText(""); jTextField4.setEditable(false); jTextField4.setText(""); jTextField5.setEditable(false); jTextField5.setText(""); infoPanel.setFont(new java.awt.Font("SansSerif", 1, 20)); infoPanel.setForeground(Color.black); infoPanel.setHorizontalAlignment(SwingConstants.CENTER); infoPanel.setText("请输入查询信息"); jLabel1.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel1.setForeground(Color.black); jLabel1.setRequestFocusEnabled(true); jLabel1.setText("房间识别号"); jTextField1.setText(""); jLabel2.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel2.setForeground(Color.black); jLabel2.setHorizontalAlignment(SwingConstants.CENTER); jLabel2.setText("客户姓名"); jTextField2.setText(""); jTextField6.setEditable(false); jTextField6.setText(""); jLabel7.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel7.setForeground(Color.black); jLabel7.setHorizontalAlignment(SwingConstants.CENTER); jLabel7.setText("押金"); jLabel8.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel8.setForeground(Color.black); jLabel8.setHorizontalAlignment(SwingConstants.CENTER); jLabel8.setText("结帐"); jTextField7.setEditable(false); jTextField7.setText(""); jTextField8.setText(""); jLabel9.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel9.setForeground(Color.black); jLabel9.setHorizontalAlignment(SwingConstants.CENTER); jLabel9.setText("是否开发票"); jTextField9.setText(""); jLabel10.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel10.setForeground(Color.black); jLabel10.setHorizontalAlignment(SwingConstants.CENTER); jLabel10.setText("记帐员"); jTextField10.setText(""); jButton1.setFont(new java.awt.Font("SansSerif", 1, 15)); jButton1.setForeground(Color.black); jButton1.setText("查询"); jButton1.addActionListener(new CancelRoom_jButton1_actionAdapter(this)); jButton2.setFont(new java.awt.Font("SansSerif", 1, 15)); jButton2.setText("提交"); jButton2.addActionListener(new CancelRoom_jButton2_actionAdapter(this)); jLabel11.setFont(new java.awt.Font("SansSerif", 3, 20)); jLabel11.setForeground(Color.red); jLabel11.setHorizontalAlignment(SwingConstants.CENTER); jLabel11.setText("OR"); this.setLayout(xYLayout2); xYLayout2.setWidth(640); xYLayout2.setHeight(555); this.setBackground(SystemColor.info); this.setForeground(SystemColor.info); this.add(jLabel0, new XYConstraints(150, 22, 200, 35)); this.add(jLabel1, new XYConstraints(270, 100, 80, 35)); this.add(jTextField1, new XYConstraints(450, 100, 100, 35)); this.add(jLabel2, new XYConstraints(270, 170, 80, 35)); this.add(jTextField2, new XYConstraints(450, 170,100, 35)); this.add(infoPanel, new XYConstraints(60, 100, 178, 39)); this.add(jLabel3, new XYConstraints(30, 240, 60, 35)); this.add(jTextField3, new XYConstraints(129, 240, 100, 35)); this.add(jLabel4, new XYConstraints(325, 240, 71, 35)); this.add(jTextField4, new XYConstraints(450, 240, 100, 35)); this.add(jLabel5, new XYConstraints(30, 310, 48, 35)); this.add(jTextField5, new XYConstraints(132, 310, 100, 35)); this.add(jLabel6, new XYConstraints(325, 310, 68, 35)); this.add(jTextField6, new XYConstraints(450, 310, 100, 35)); this.add(jLabel7, new XYConstraints(30, 380, 62, 35)); this.add(jTextField7, new XYConstraints(134, 380, 100,35)); this.add(jLabel8, new XYConstraints(325, 380, 61, 35)); this.add(jTextField8, new XYConstraints(450, 380, 100, 35)); this.add(jLabel9, new XYConstraints(30, 450, 83, 35)); this.add(jTextField9, new XYConstraints(132, 450,100, 35)); this.add(jLabel10, new XYConstraints(325, 450, 54, 35)); this.add(jTextField10, new XYConstraints(450, 450, 100, 35)); this.add(jButton1, new XYConstraints(600, 310, 85, 35)); this.add(jButton2, new XYConstraints(600, 380, 100,35)); this.add(jLabel11, new XYConstraints(271, 140, 88, 29)); } void jButton1_actionPerformed(ActionEvent e) throws Exception{//查询帐单 String roomNo=jTextField1.getText().toString(); String name=jTextField2.getText().toString(); if(!name.equals("")||!roomNo.equals("")){ String queryString = "select * from HIMS_Register"; //查询语句 try { JDBCFile conn = new JDBCFile(); //得到一个对象 //首先得到查询结果的信息 ResultSet resultSet = conn.executeQuery(queryString); while (resultSet.next()) { RoomNo= resultSet.getString("ROOMNO"); //房间识别号 searchName =resultSet.getString("Name"); searchIDNo = resultSet.getLong("IDNo"); String IDNostr = Long.toString(searchIDNo); iClass=resultSet.getString("Class"); StandardPri=resultSet.getFloat("StandardPri");//标准价 String StandardPristr=Float.toString(StandardPri); RebatePri=resultSet.getLong("RebatePri");//折后价 String RebatePristr=Float.toString(RebatePri); Deposit=resultSet.getLong("Deposit");// String Depositstr=Float.toString(Deposit); CustNo= resultSet.getInt("CUSTNO"); String CustNostr = Integer.toString(CustNo); if(searchName.equals(name)||RoomNo.equals(roomNo)){//显示 jTextField1.setText(RoomNo);//房间识别号 jTextField2.setText(searchName);//客户姓名 jTextField3.setText(IDNostr); jTextField4.setText(iClass);//房间类别 jTextField5.setText(StandardPristr); jTextField6.setText(RebatePristr); jTextField7.setText(Depositstr); jTextField8.setText(""); //结帐 jTextField9.setText("");// 是否发票 jTextField10.setText("");//记帐员 }//end if else { //都为空值,显示错误信息 //JOptionPane.showMessageDialog(null,"该客户信息不存在","查询结果", // JOptionPane.PLAIN_MESSAGE); } }//end while }catch (SQLException q) { System.out.println("WE"+q); } }//end if else{//都为空值,显示错误信息 JOptionPane.showMessageDialog(null,"请输入查询信息","查询信息", JOptionPane.PLAIN_MESSAGE); } }///////////////////////////////////// void jButton2_actionPerformed(ActionEvent e) throws Exception{//提交帐单 //IDint=Integer.parseInt(jTextField0.getText()); //RoomNo=jTextField1.getText(); //房间识别号 //iClass=jTextField2.getText(); // 房间类别 // StandardPri=Float.parseFloat(jTextField3.getText());//标准价 //RebatePri=Float.parseFloat(jTextField4.getText());//折后价 //Deposit=Float.parseFloat(jTextField5.getText());// 押金 //Total=Float.parseFloat(jTextField6.getText());//总额 String Reckoningstr=jTextField8.getText(); String IsBill=jTextField9.getText(); Operator=jTextField10.getText();// 记帐员 String insertString =//不包括ID "INSERT INTO HIMS_Account(AccountNo,Name,RoomNo,Class,StandardPri,RebatePri,Deposit,Reckoning,IsBill, Operator) VALUES(" +new Long(searchIDNo)+",'"+searchName+"','"+RoomNo+"','"+iClass+"',"+new Float(StandardPri)+","+new Float(RebatePri)+"," +new Float(Deposit)+","+new Float(Reckoningstr) +",'"+IsBill+"','"+Operator+"')"; //插入语句 // System.out.println("IDint***:" + IDint); try{ JDBCFile conn2 = new JDBCFile(); //得到一个对象 //int count1=stmt.executeUpdate("INSERT INTO testTable(id,name) VALUES(1,'wu')"); int flag=conn2.insert(insertString); //if()System.out.println(""); }catch(Exception ex2){ System.out.println("SSS"+ex2); } }}//end public CancelRoomclass CancelRoom_jButton1_actionAdapter implements java.awt.event.ActionListener { CancelRoom adaptee; CancelRoom_jButton1_actionAdapter(CancelRoom adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { try{ adaptee.jButton1_actionPerformed(e); } catch(Exception ee){ System.out.println(ee); } }}class CancelRoom_jButton2_actionAdapter implements java.awt.event.ActionListener { CancelRoom adaptee; CancelRoom_jButton2_actionAdapter(CancelRoom adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { try{ adaptee.jButton2_actionPerformed(e); }catch(Exception ee){ System.out.println(ee); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -