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

📄 empinfoquery.java

📁 酒店信息管理系统包括客户的信息
💻 JAVA
字号:
package EmpManagement;

import java.awt.BorderLayout;
import hotelinformationmanagesystem.*;
import ShowTable.*;
import javax.swing.JFrame;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JTable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import java.awt.Font;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.ButtonGroup;
import javax.swing.JOptionPane;

/**
 * <p>Title: 酒店信息管理系统</p>
 *
 * <p>Description: HotelInformationManageSystem</p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: JSP</p>
 *
 * @author 江世澎
 * @version 1.0
 */
public class EmpInfoQuery extends JFrame {
    JTable jTable1;
    TableExample table = new TableExample();
    JScrollPane jScrollPane1 = new JScrollPane();

    XYLayout xYLayout1 = new XYLayout();
    JButton jBQuit = new JButton();
    JPanel jPEmpInfShow = new JPanel();
    XYLayout xYLayout2 = new XYLayout();
    JRadioButton jRBSex = new JRadioButton();
    JRadioButton jRBName = new JRadioButton();
    JRadioButton jRBDepartment = new JRadioButton();
    JPanel jPQueryName = new JPanel();
    XYLayout xYLayout3 = new XYLayout();
    JTextField jTFName = new JTextField();
    JPanel jPQueryDepartmentShow = new JPanel();
    XYLayout xYLayout4 = new XYLayout();
    JPanel jPSexQueryShow = new JPanel();
    XYLayout xYLayout5 = new XYLayout();
    JComboBox jCBSex = new JComboBox();
    ButtonGroup BGQuery = new ButtonGroup();
    JComboBox jCBDepartment = new JComboBox();
    JButton jBQuery = new JButton();

    public EmpInfoQuery() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        jTable1 = table.createTable();
        getContentPane().setLayout(xYLayout1);
        this.setResizable(false);
        this.setTitle("酒店员工查询界面");
        jBQuit.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jBQuit.setText("退出");
        jBQuit.addActionListener(new EmpInfoQuery_jBQuit_actionAdapter(this));
        xYLayout1.setWidth(394);
        xYLayout1.setHeight(339);
        jPEmpInfShow.setLayout(xYLayout2);
        jPEmpInfShow.setBorder(BorderFactory.createEtchedBorder());
        jPEmpInfShow.setToolTipText("");
        jPQueryName.setBorder(BorderFactory.createEtchedBorder());
        jPQueryName.setLayout(xYLayout3);
        jPQueryDepartmentShow.setLayout(xYLayout4);
        jPQueryDepartmentShow.setBorder(BorderFactory.createEtchedBorder());
        jPSexQueryShow.setLayout(xYLayout5);
        jPSexQueryShow.setBorder(BorderFactory.createEtchedBorder());
        jRBName.addActionListener(new
                                  EmpInfoQuery_jRadioButton2_actionAdapter(this));
        jRBDepartment.addActionListener(new
                                        EmpInfoQuery_jRadioButton3_actionAdapter(this));
        jRBSex.addActionListener(new
                                 EmpInfoQuery_jRadioButton1_actionAdapter(this));
        jBQuery.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jBQuery.setText("查询");
        jBQuery.addActionListener(new EmpInfoQuery_jBQuery_actionAdapter(this));
        jPSexQueryShow.add(jRBSex, new XYConstraints(0, 3, -1, -1));
        jRBSex.setText("按性别查询");
        jRBName.setText("按姓名查询");
        jRBDepartment.setText("按部门查询");
        BGQuery.add(jRBSex);
        BGQuery.add(jRBName);
        BGQuery.add(jRBDepartment);
        jPQueryName.add(jRBName, new XYConstraints(6, 3, -1, -1));
        jPQueryName.add(jTFName, new XYConstraints(101, 3, 111, 25));
        this.getContentPane().add(jBQuit, new XYConstraints(311, 301, 79, 35));
        this.getContentPane().add(jBQuery, new XYConstraints(229, 301, 79, 35));
        jPQueryDepartmentShow.add(jRBDepartment, new XYConstraints(5, 4, -1, -1));
        jPQueryDepartmentShow.add(jCBDepartment,
                                  new XYConstraints(101, 3, 111, 25));
        this.getContentPane().add(jPQueryDepartmentShow,
                                  new XYConstraints(3, 302, 221, 35));
        this.getContentPane().add(jPQueryName,
                                  new XYConstraints(3, 264, 221, 36));
        jScrollPane1.getViewport().add(jTable1);
        jPSexQueryShow.add(jCBSex, new XYConstraints(90, 3, 62, -1));
        jPEmpInfShow.add(jScrollPane1, new XYConstraints(0, 1, 380, 251));
        this.getContentPane().add(jPEmpInfShow,
                                  new XYConstraints(3, 3, 387, 258));
        this.getContentPane().add(jPSexQueryShow,
                                  new XYConstraints(226, 264, 164, 36));
        jTFName.setEnabled(false);
        jCBSex.setEnabled(false);
        jCBDepartment.setEnabled(false);

        this.setSize(400, 380);
        SetFormCenter wcenter = new SetFormCenter();
        wcenter.setcenter(this);
    }

    /**
     * 退出模块函数:退出本模块
     * */
    public void jBQuit_actionPerformed(ActionEvent e) {
        this.setVisible(false);
    }

    public void jRadioButton2_actionPerformed(ActionEvent e) {
        jTFName.setText("");
        jTFName.setEnabled(true);

        jCBSex.removeAllItems();
        jCBSex.setEnabled(false);
        jCBDepartment.removeAllItems();
        jCBDepartment.setEnabled(false);

    }

    public void jRadioButton3_actionPerformed(ActionEvent e) {
        jCBDepartment.setEnabled(true);
        jCBDepartment.removeAllItems();
        jCBDepartment.addItem(" ");
        jCBDepartment.addItem("服务部");
        jCBDepartment.addItem("客房部");

        jTFName.setText("");
        jTFName.setEnabled(false);
        jCBSex.removeAllItems();
        jCBSex.setEnabled(false);

    }

    public void jRadioButton1_actionPerformed(ActionEvent e) {
        jCBSex.setEnabled(true);
        jCBSex.removeAllItems();
        jCBSex.addItem(" ");
        jCBSex.addItem("男");
        jCBSex.addItem("女");

        jTFName.setText("");
        jTFName.setEnabled(false);
        jCBDepartment.removeAllItems();
        jCBDepartment.setEnabled(false);
    }

    public void jBQuery_actionPerformed(ActionEvent e) {
        if (BGQuery.getSelection() == jRBName.getModel()) { //按姓名查询
            String strName = null;
            strName = jTFName.getText();

            table.fetch("select EmpID as 员工ID,Name as 姓名,Sex as 性别,Nationality as 民族,Birthday as 出生日期,IDCard as 身份证号,Native as 籍贯, Address as 地址,Phone as 联系电话,Department as 部门,Duty as 职务,Remark as 备注   from HIMS_Employee Where Name like '%" +
                        strName +
                        "%';");
            if (jTable1.getRowCount() == 0) {
                JOptionPane.showMessageDialog(null,
                                              "您所要查找的数据不在数据库中!!",
                                              "酒店信息管理系统警告",
                                              JOptionPane.WARNING_MESSAGE);
                jTFName.setText("");
            }
            return;
        }
        if (BGQuery.getSelection() == jRBSex.getModel()) { //按性别查询
            String strSex = null;
            try {
                strSex = jCBSex.getSelectedItem().toString();
            } catch (Exception ex) {
                strSex = "";
            }
            table.fetch("select EmpID as 员工ID,Name as 姓名,Sex as 性别,Nationality as 民族,Birthday as 出生日期,IDCard as 身份证号,Native as 籍贯, Address as 地址,Phone as 联系电话,Department as 部门,Duty as 职务,Remark as 备注   from HIMS_Employee Where Sex = '" +
                        strSex +
                        "';");
            if (jTable1.getRowCount() == 0) {
                JOptionPane.showMessageDialog(null,
                                              "您所要查找的数据不在数据库中!!",
                                              "酒店信息管理系统警告",
                                              JOptionPane.WARNING_MESSAGE);
                jCBSex.removeAllItems();
            }
            return;
        }
        if (BGQuery.getSelection() == jRBDepartment.getModel()) { //按部门查询
            String strDepartment = null;
            try {
                strDepartment = jCBDepartment.getSelectedItem().toString();
            } catch (Exception ex) {
                strDepartment = "";
            }
            table.fetch("select EmpID as 员工ID,Name as 姓名,Sex as 性别,Nationality as 民族,Birthday as 出生日期,IDCard as 身份证号,Native as 籍贯, Address as 地址,Phone as 联系电话,Department as 部门,Duty as 职务,Remark as 备注   from HIMS_Employee Where Department = '" +
                        strDepartment +
                        "';");
            if (jTable1.getRowCount() == 0) {
                JOptionPane.showMessageDialog(null,
                                              "您所要查找的数据不在数据库中!!",
                                              "酒店信息管理系统警告",
                                              JOptionPane.WARNING_MESSAGE);
                jCBDepartment.removeAllItems();
            }

            return;
        }
    }
}


class EmpInfoQuery_jBQuery_actionAdapter implements ActionListener {
    private EmpInfoQuery adaptee;
    EmpInfoQuery_jBQuery_actionAdapter(EmpInfoQuery adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jBQuery_actionPerformed(e);
    }
}


class EmpInfoQuery_jRadioButton1_actionAdapter implements ActionListener {
    private EmpInfoQuery adaptee;
    EmpInfoQuery_jRadioButton1_actionAdapter(EmpInfoQuery adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jRadioButton1_actionPerformed(e);
    }
}


class EmpInfoQuery_jRadioButton2_actionAdapter implements ActionListener {
    private EmpInfoQuery adaptee;
    EmpInfoQuery_jRadioButton2_actionAdapter(EmpInfoQuery adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jRadioButton2_actionPerformed(e);
    }
}


class EmpInfoQuery_jRadioButton3_actionAdapter implements ActionListener {
    private EmpInfoQuery adaptee;
    EmpInfoQuery_jRadioButton3_actionAdapter(EmpInfoQuery adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jRadioButton3_actionPerformed(e);
    }
}


class EmpInfoQuery_jBQuit_actionAdapter implements ActionListener {
    private EmpInfoQuery adaptee;
    EmpInfoQuery_jBQuit_actionAdapter(EmpInfoQuery adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jBQuit_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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