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

📄 himsemployeesearch.java

📁 基于java的一个小应用程序开发与应用
💻 JAVA
字号:
package com.employee;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 HIMSEmployeeSearch extends JPanel {  XYLayout xYLayout1 = new XYLayout();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  JTextField jTextField1 = new JTextField();  JButton jButton1 = new JButton();  XYLayout xYLayout2 = new XYLayout();  JLabel jLabel3 = new JLabel();  JLabel jLabel4 = new JLabel();  JTextField jTextField2 = new JTextField();  ////////////////  //变量 private String  searchName;//员工姓名 private int   searchIDNo; //员工ID private String title;  //   --职务 private int phone; //房间识别号 private String outPut;//输出结果  public HIMSEmployeeSearch() {    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.setHorizontalTextPosition(SwingConstants.CENTER);    jLabel1.setText("宾馆员工信息查询");    this.setLayout(xYLayout1);    jLabel2.setFont(new java.awt.Font("SansSerif", 1, 15));    jLabel2.setForeground(Color.black);    jLabel2.setRequestFocusEnabled(true);    jLabel2.setHorizontalAlignment(SwingConstants.CENTER);    jLabel2.setText("员工姓名");    jButton1.setFont(new java.awt.Font("SansSerif", 1, 15));    jButton1.setText("查询");    jButton1.addActionListener(new HIMSEmployeeSearch_jButton1_actionAdapter(this));    this.setLayout(xYLayout2);    jLabel3.setFont(new java.awt.Font("SansSerif", 1, 15));    jLabel3.setForeground(Color.black);    jLabel3.setHorizontalAlignment(SwingConstants.CENTER);    jLabel3.setHorizontalTextPosition(SwingConstants.TRAILING);    jLabel3.setText("员工ID");    jLabel4.setFont(new java.awt.Font("SansSerif", 3, 22));    jLabel4.setForeground(Color.red);    jLabel4.setHorizontalAlignment(SwingConstants.CENTER);    jLabel4.setHorizontalTextPosition(SwingConstants.CENTER);    jLabel4.setText("OR");    xYLayout2.setWidth(475);    xYLayout2.setHeight(404);    this.setBackground(SystemColor.info);    this.setForeground(Color.red);    this.add(jLabel1,  new XYConstraints(150, 41, 200, 40));    this.add(jLabel2, new XYConstraints(75, 115, 80, 35));    this.add(jTextField1, new XYConstraints(270, 120, 127, 35));    this.add(jLabel3, new XYConstraints(75, 260, 60, 35));    this.add(jLabel4,  new XYConstraints(230, 196, 60, 35));    this.add(jTextField2, new XYConstraints(270, 254, 120, 35));    this.add(jButton1,  new XYConstraints(250, 350, 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_Employee"; //查询语句        outPut="姓名           员工编号            职务     联系电话 \n";      try {           JDBCFile conn = new JDBCFile(); //得到一个对象           //首先得到查询结果的信息           ResultSet resultSet = conn.executeQuery(queryString);           while (resultSet.next()) {             searchName =resultSet.getString("Name");             searchIDNo = resultSet.getInt("IDCard");             String IDNostr =Integer.toString(searchIDNo);             String title=resultSet.getString("Title");             phone = resultSet.getInt("Phone");             String phonestr=Integer.toString(phone);             if(searchName.equals(name)||IDNostr.equals(IDcard)){               outPut+="\n";               outPut=outPut+" "+searchName+"   "+IDNostr+"    "+                   title+"         "+phonestr;              }//end if           }//end while         }catch (SQLException q) {           System.out.println("EM"+q);         }          System.out.println(outPut);        JOptionPane.showMessageDialog(null,outPut,"查询结果信息",                                      JOptionPane.PLAIN_MESSAGE);    }//end if        else{//都为空值,显示错误信息        JOptionPane.showMessageDialog(null,"请输入查询信息","查询信息",                                      JOptionPane.PLAIN_MESSAGE);          }  }} //end public classclass HIMSEmployeeSearch_jButton1_actionAdapter implements java.awt.event.ActionListener {  HIMSEmployeeSearch adaptee;  HIMSEmployeeSearch_jButton1_actionAdapter(HIMSEmployeeSearch 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 + -