📄 himsroomsearch.java
字号:
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 HIMSRoomSearch extends JPanel { JLabel jLabel1 = new JLabel(); JTextField jTextField1 = new JTextField(); JLabel jLabel2 = new JLabel(); JButton jButton1 = new JButton(); JLabel jLabel3 = new JLabel(); JTextField jTextField2 = new JTextField(); JLabel jLabel4 = new JLabel(); XYLayout xYLayout2 = new XYLayout(); //变量 private String searchName; private long searchIDNo; private String RoomNo; //房间识别号 private int CustNo;// 住宿人数 private String outPut;//输出结果 public HIMSRoomSearch() {//构造函数 try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { jLabel1.setFont(new java.awt.Font("SansSerif", 1, 20)); jLabel1.setForeground(Color.black); jLabel1.setHorizontalAlignment(SwingConstants.CENTER); jLabel1.setText("宾馆客人查询"); jTextField1.setText(""); jLabel2.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel2.setForeground(Color.black); jLabel2.setHorizontalAlignment(SwingConstants.CENTER); jLabel2.setText("姓名"); jButton1.setFont(new java.awt.Font("SansSerif", 1, 15)); jButton1.setForeground(Color.black); jButton1.setHorizontalTextPosition(SwingConstants.TRAILING); jButton1.setSelected(false); jButton1.setText("查询"); jButton1.addActionListener(new HIMSRoomSearch_jButton1_actionAdapter(this)); jLabel3.setEnabled(true); jLabel3.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel3.setForeground(Color.black); jLabel3.setRequestFocusEnabled(true); jLabel3.setHorizontalAlignment(SwingConstants.CENTER); jLabel3.setText("证件号"); jTextField2.setText(""); jTextField2.addActionListener(new HIMSRoomSearch_jButton1_actionAdapter(this)); jLabel4.setFont(new java.awt.Font("Serif", 3, 22)); jLabel4.setForeground(Color.red); jLabel4.setVerifyInputWhenFocusTarget(true); jLabel4.setHorizontalAlignment(SwingConstants.CENTER); jLabel4.setText("OR"); this.setLayout(xYLayout2); xYLayout2.setWidth(414); xYLayout2.setHeight(347); this.setBackground(SystemColor.info); this.setDebugGraphicsOptions(0); this.add(jLabel1, new XYConstraints(160, 8, -1, -1)); this.add(jLabel2, new XYConstraints(75, 80, 60, 35)); this.add(jLabel3, new XYConstraints(75, 200, 60, 35)); this.add(jLabel4, new XYConstraints(150, 150, 77, 35)); this.add(jTextField1, new XYConstraints(230, 80, 120, 35)); this.add(jTextField2, new XYConstraints(230, 200, 120, 35)); this.add(jButton1, new XYConstraints(250, 300, 90, 35)); } void jButton1_actionPerformed(ActionEvent e) throws Exception{//查询按钮 String name=jTextField1.getText().toString(); String IDcard=jTextField2.getText().toString(); if(!name.equals("")||!IDcard.equals("")){ String queryString = "select * from HIMS_Register"; //查询语句 outPut="姓名 证件号 房间号 住宿人数 \n"; try { JDBCFile conn = new JDBCFile(); //得到一个对象 //首先得到查询结果的信息 ResultSet resultSet = conn.executeQuery(queryString); while (resultSet.next()) { searchName =resultSet.getString("Name"); searchIDNo = resultSet.getLong("IDNo"); String IDNostr = Long.toString(searchIDNo); RoomNo= resultSet.getString("ROOMNO"); //房间识别号 CustNo= resultSet.getInt("CUSTNO"); String CustNostr = Integer.toString(CustNo); System.out.println(searchName); System.out.println("SSSSS"+name); if(searchName.equals(name)||IDNostr.equals(IDcard)){ outPut+="\n"; outPut=outPut+" "+searchName+" "+IDNostr+" "+ RoomNo+" "+CustNostr; }//end if }//end while }catch (SQLException q) { System.out.println(q); } System.out.println(outPut); JOptionPane.showMessageDialog(null,outPut,"查询结果信息", JOptionPane.PLAIN_MESSAGE); }//end if else{//都为空值,显示错误信息 JOptionPane.showMessageDialog(null,"请输入查询信息","查询信息", JOptionPane.PLAIN_MESSAGE); } }} //end public class///////////////////////////////////////class HIMSRoomSearch_jButton1_actionAdapter implements java.awt.event.ActionListener { HIMSRoomSearch adaptee; HIMSRoomSearch_jButton1_actionAdapter(HIMSRoomSearch adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e){ try{ adaptee.jButton1_actionPerformed(e); }catch(Exception ee){ System.out.println(ee); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -