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

📄 finddriver.java

📁 出租车管理系统,为本人毕业设计. 还请大家多多指教了
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package car;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.sql.ResultSet;
import java.sql.*;
import java.awt.Font;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class FindDriver extends JFrame {
    TableExample te = new TableExample();
    public FindDriver() {
        try {
            jbInit();
//            this.setSize(563,520);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

//    public static void main(String[] args) {
//        FindDriver finddriver = new FindDriver();
//    }

    private void jbInit() throws Exception {
        this.getContentPane().setLayout(xYLayout1);

        jPanel2.setBorder(border2);
        jPanel2.setLayout(xYLayout3);
        jButton1.setBackground(Color.white);
        jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jButton1.setToolTipText("查   找");
        jButton1.addActionListener(new FindDriver_jButton1_actionAdapter(this));
        jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel1.setText("请输入驾驶证号:");
        jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jLabel2.setText("请选择准驾类型:");
        jTextField1.setText("");
        jTextField1.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                jTextField1_keyPressed(e);
            }
        });
        jTextField1.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent e) {
                jTextField1_focusLost(e);
            }
        });
        jComboBox1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jComboBox1.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
                jComboBox1_keyPressed(e);
            }
        });
        jComboBox1.addItem("  A1");
        jComboBox1.addItem("  A2");
        jComboBox1.addItem("  A3");
        jComboBox1.addItem("  B1");
        jComboBox1.addItem("  B2");
        jComboBox1.addItem("  C1");
        jComboBox1.addItem("  C2");
        jComboBox1.addItem("  C3");
        jComboBox1.addItem("  C4");
        jComboBox1.addItem("  D");
        jComboBox1.addItem("  E");
        jComboBox1.addItem("  F");
        jComboBox1.addItem("  M");
        jComboBox1.addItem("  N");
        jComboBox1.addItem("  P");

        jCheckBox1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jCheckBox1.addActionListener(new FindDriver_jCheckBox1_actionAdapter(this));
        jCheckBox1.addItemListener(new FindDriver_jCheckBox1_itemAdapter(this));
        jCheckBox2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jCheckBox2.setText("按准驾类型查找");
        jCheckBox2.addActionListener(new FindDriver_jCheckBox2_actionAdapter(this));
        jCheckBox2.addItemListener(new FindDriver_jCheckBox2_itemAdapter(this));
        jButton2.setBackground(Color.white);
        jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
        jButton2.addActionListener(new FindDriver_jButton2_actionAdapter(this));
        this.setTitle("沈阳志远出租汽车公司出租车信息管理系统--查看驾驶员信息窗口");
        jPanel1.setLayout(xYLayout2);
        jCheckBox1.setText("按驾驶证号查找");
        jPanel1.setBorder(border1);
        xYLayout1.setWidth(629);
        xYLayout1.setHeight(532);
        jScrollPane1.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
        //  jTable1.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
        jPanel2.add(jCheckBox2, new XYConstraints(7, 8, -1, -1));
        jPanel2.add(jComboBox1, new XYConstraints(318, 7, 121, 33));
        jPanel2.add(jLabel2, new XYConstraints(200, 10, -1, 26));
        jPanel1.add(jTextField1, new XYConstraints(318, 9, 120, 32));
        jPanel1.add(jCheckBox1, new XYConstraints(9, 6, -1, -1));
        jPanel1.add(jLabel1, new XYConstraints(200, 14, -1, -1));
        this.getContentPane().add(jPanel2, new XYConstraints(23, 77, 467, 49));
        jTable1 = te.createTable();
        jScrollPane1.getViewport().add(jTable1);
        this.getContentPane().add(jPanel1, new XYConstraints(23, 25, 467, 49));
        this.getContentPane().add(jScrollPane1,
                                  new XYConstraints(24, 137, 466, 378));
        this.getContentPane().add(jButton2, new XYConstraints(508, 79, 102, 46));
        this.getContentPane().add(jButton1, new XYConstraints(507, 27, 103, 44));
        this.setLocation(170, 50);
        this.setSize(640, 600);

        this.setVisible(true);

        addWindowListener(new WindowAdapter() {
            public void WindowClosing(WindowEvent e) {
                if (db != null)
                    db.closeConnection();
                if (db2 != null)
                    db2.closeConnection();
                dispose();
            }
        });

    }

    JPanel jPanel1 = new JPanel();
    DataBaseManager db = null;
    DataBaseManager db2 = null;
    ResultSet r;
    XYLayout xYLayout1 = new XYLayout();
    Border border1 = BorderFactory.createEtchedBorder(Color.white,
            new Color(165, 163, 151));
    JPanel jPanel2 = new JPanel();
    Border border2 = BorderFactory.createEtchedBorder(Color.white,
            new Color(165, 163, 151));
    JCheckBox jCheckBox1 = new JCheckBox();
    XYLayout xYLayout2 = new XYLayout();
    JCheckBox jCheckBox2 = new JCheckBox();
    XYLayout xYLayout3 = new XYLayout();
    JButton jButton1 = new JButton(new ImageIcon("image\\113.gif"));
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JComboBox jComboBox1 = new JComboBox();
    JButton jButton2 = new JButton(new ImageIcon("image\\back.gif"));
    Border border3 = BorderFactory.createEtchedBorder(EtchedBorder.RAISED,
            Color.white, new Color(178, 178, 178));
    JScrollPane jScrollPane1 = new JScrollPane();
    JTable jTable1;
    public void jButton2_actionPerformed(ActionEvent e) {
        if (db != null)
            db.closeConnection();
        if (db2 != null)
            db2.closeConnection();
        dispose();
    }

    public void jButton1_actionPerformed(ActionEvent e) {
        String sql =
                "select 驾驶证号,驾驶员姓名,性别,民族,文化程度,驾证初领日,身份证号,住址,联系电话,准驾类型 from driver where ";
        String str = "";
        db = new DataBaseManager();
        try {
            if (jCheckBox1.isSelected() && jCheckBox2.isSelected()) {
                if (!db.getResult("select * from driver where 驾驶证号='" +
                                  jTextField1.getText().trim() + "'").first()) {
                    String s = "没有编号为" + jTextField1.getText().trim() +
                               "的驾驶员,请重新输入驾驶证号。";
                    JOptionPane.showMessageDialog(null, s);
                    jTextField1.setText("");
                } else {
                    str = "驾驶证号='" + jTextField1.getText().trim() +
                          "' and 准驾类型='" + jComboBox1.getSelectedItem() + "'";
                }
            } else if (jCheckBox1.isSelected()) {
                if (!db.getResult("select * from driver where 驾驶证号='" +
                                  jTextField1.getText().trim() + "'").first()) {
                    String s = "没有编号为" + jTextField1.getText().trim() +
                               "的驾驶员,请重新输入驾驶证号。";
                    JOptionPane.showMessageDialog(null, s);
                    jTextField1.setText("");
                } else {
                    str = "驾驶证号='" + jTextField1.getText().trim() + "'";
                }
            } else if (jCheckBox2.isSelected()) {
                if (db.getResult(
                        "select 驾驶证号,驾驶员姓名,性别,民族,文化程度,驾证初领日,身份证号,住址,联系电话,准驾类型 from driver where 准驾类型='" +
                        jComboBox1.getSelectedItem() + "'").first()) {
                    str = "准驾类型='" + jComboBox1.getSelectedItem() + "'";
                }

            }
            te.fetch(sql + str); //
        } catch (HeadlessException ex) {

⌨️ 快捷键说明

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