📄 himsonduty.java~30~
字号:
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 HIMSOnDuty extends JPanel{ JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); JLabel jLabel3 = new JLabel(); XYLayout xYLayout1 = new XYLayout(); JLabel jLabel4 = new JLabel(); JTextField jTextField1 = new JTextField(); JTextField jTextField2 = new JTextField(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JLabel jLabel5 = new JLabel(); JLabel jLabel6 = new JLabel(); JTextField jTextField3 = new JTextField(); ///// String outPut; String onDate; String name; int onDutyNo; int phone; public HIMSOnDuty() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { jLabel1.setFont(new java.awt.Font("SansSerif", 1, 20)); jLabel1.setForeground(Color.blue); jLabel1.setToolTipText(""); jLabel1.setHorizontalAlignment(SwingConstants.CENTER); jLabel1.setText("值班人员查询"); jLabel2.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel2.setForeground(Color.blue); jLabel2.setText("值班日期"); jLabel3.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel3.setForeground(Color.blue); jLabel3.setHorizontalAlignment(SwingConstants.LEADING); jLabel3.setHorizontalTextPosition(SwingConstants.CENTER); jLabel3.setText("姓名"); this.setLayout(xYLayout1); jLabel4.setFont(new java.awt.Font("SansSerif", 3, 22)); jLabel4.setForeground(Color.red); jLabel4.setText("OR"); xYLayout1.setWidth(437); xYLayout1.setHeight(489); jButton1.setFont(new java.awt.Font("SansSerif", 1, 15)); jButton1.setForeground(Color.blue); jButton1.setText("重置"); jButton1.addActionListener(new HIMSOnDuty_jButton1_actionAdapter(this)); jButton2.setFont(new java.awt.Font("SansSerif", 1, 15)); jButton2.setForeground(Color.blue); jButton2.setText("查询"); jButton2.addActionListener(new HIMSOnDuty_jButton2_actionAdapter(this)); jLabel5.setFont(new java.awt.Font("SansSerif", 3, 22)); jLabel5.setForeground(Color.red); jLabel5.setText("OR"); jLabel6.setFont(new java.awt.Font("SansSerif", 1, 15)); jLabel6.setForeground(Color.blue); jLabel6.setText("值班号"); jTextField3.setText("jTextField3"); this.setFont(new java.awt.Font("SansSerif", 1, 15)); this.setForeground(Color.black); jTextField1.setText(""); this.add(jLabel1, new XYConstraints(145, 14, 150, 35)); this.add(jLabel2, new XYConstraints(100, 80, 70, 35)); this.add(jTextField1, new XYConstraints(200, 80, 150, 35)); this.add(jLabel3, new XYConstraints(100, 200, 50, 35)); this.add(jTextField2, new XYConstraints(200, 200, 150, 35)); this.add(jLabel4, new XYConstraints(200, 150, 50, 35)); this.add(jLabel5, new XYConstraints(200, 265, 50, 35)); this.add(jLabel6, new XYConstraints(100, 324, 50, 35)); this.add(jTextField3, new XYConstraints(200, 321, 150, 35)); this.add(jButton1, new XYConstraints(70, 420, 80, 35)); this.add(jButton2, new XYConstraints(270, 420, 80, 35)); } void jButton1_actionPerformed(ActionEvent e) {//置空 jTextField1.setText(""); jTextField2.setText(""); jTextField3.setText(""); } void jButton2_actionPerformed(ActionEvent e) throws Exception{//查询 String getdate=jTextField1.getText().toString(); String getname=jTextField2.getText().toString(); String getduty=jTextField3.getText().toString(); if(!getdate.equals("")||!getname.equals("")||!getduty.equals("")){ String queryString = "select * from HIMS_OnDuty"; //查询语句 outPut="日期 姓名 值班号 电话联系 \n"; try { JDBCFile conn = new JDBCFile(); //得到一个对象 //首先得到查询结果的信息 ResultSet resultSet = conn.executeQuery(queryString); while (resultSet.next()) { onDate =resultSet.getDate("OnDate").toString(); name =resultSet.getString("Name"); onDutyNo= resultSet.getInt("OnDutyNo"); String onDutyNostr=Integer.toString(onDutyNo); phone = resultSet.getInt("Phone"); String phonestr=Integer.toString(phone); if(onDate.equals(getdate)||name.equals(getname)||onDutyNostr.equals(getduty)){ outPut+="\n"; outPut=outPut+" "+onDate+" "+name+" "+ onDutyNostr+" "+phonestr; }//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 classclass HIMSOnDuty_jButton1_actionAdapter implements java.awt.event.ActionListener { HIMSOnDuty adaptee; HIMSOnDuty_jButton1_actionAdapter(HIMSOnDuty adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}class HIMSOnDuty_jButton2_actionAdapter implements java.awt.event.ActionListener { HIMSOnDuty adaptee; HIMSOnDuty_jButton2_actionAdapter(HIMSOnDuty 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 + -