• 人事管理系统——11个基础信息管理界面


    树中第一节点——基础信息管理模块:

    添加人员信息主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 /**
      8  * 
      9  * 添加人员信息
     10  *
     11  */
     12 public class Node11Panel extends JPanel implements ActionListener,ItemListener
     13 {
     14     JPanel centerPanel = new JPanel();
     15     JPanel upPanel = new JPanel();
     16     
     17     //定义图形界面元素
     18     JLabel jLabel = new JLabel();
     19     JLabel jLabel1 = new JLabel();
     20     JLabel jLabel2 = new JLabel();
     21     JLabel jLabel3 = new JLabel();
     22     JLabel jLabel4 = new JLabel();
     23     JLabel jLabel5 = new JLabel();
     24     JLabel jLabel6 = new JLabel();
     25     JLabel jLabel7 = new JLabel();
     26     JLabel jLabel8 = new JLabel();
     27     JLabel jLabel9 = new JLabel();
     28     
     29     JTextField jTextField1 = new JTextField(15);//编号
     30     JTextField jTextField2 = new JTextField(15);//姓名
     31     JTextField jTextField3 = new JTextField(15);//性别
     32     JTextField jTextField4 = new JTextField(15);//出生年月
     33     JTextField jTextField5 = new JTextField(15);//民族
     34     JTextField jTextField6 = new JTextField(15);//地址
     35     JComboBox jComboBox1 = null;//部门
     36     String DeptID = "1";
     37     String Salary = "0";//薪酬
     38     String Assess = "未考核";//考核
     39     JTextField jTextField8 = new JTextField(15);//其他
     40     
     41     JScrollPane jScrollPane1;
     42     
     43     JButton searchInfo = new JButton();
     44     JButton addInfo = new JButton();
     45     JButton modifyInfo = new JButton();
     46     JButton deleteInfo = new JButton();
     47     JButton clearInfo = new JButton();
     48     JButton saveInfo = new JButton();
     49     JButton exitInfo = new JButton();
     50     
     51     JButton jBSee = new JButton();
     52     JButton jBSearch = new JButton();
     53     JButton jBExit = new JButton();
     54     JButton jBSum = new JButton();
     55     JButton jBGrade = new JButton();
     56     
     57     GridBagLayout girdBag = new GridBagLayout();
     58     GridBagConstraints girdBagCon;
     59     
     60     PersonBean bean = new PersonBean();
     61     
     62     public Node11Panel()
     63     {
     64         this.setLayout(new BorderLayout());
     65         try{
     66             jScrollPanelInit();
     67             panelInit();
     68             addListener();
     69         }
     70         catch(Exception e){
     71             e.printStackTrace();
     72         }
     73     }
     74     /**
     75      * jScrollPanel面板的布局
     76      */
     77     public void jScrollPanelInit() throws Exception
     78     {
     79         centerPanel.setLayout(girdBag);
     80         centerPanel.setLayout(girdBag);
     81         
     82         jLabel1.setText("人 员 编 号 :");
     83         jLabel1.setFont(new Font("Dialog",0,12));
     84         girdBagCon = new GridBagConstraints();
     85         girdBagCon.gridx = 0;
     86         girdBagCon.gridy = 1;
     87         girdBagCon.insets = new Insets(0,10,10,1);
     88         girdBag.setConstraints(jLabel1, girdBagCon);
     89         centerPanel.add(jLabel1);
     90         
     91         girdBagCon = new GridBagConstraints();
     92         girdBagCon.gridx = 1;
     93         girdBagCon.gridy = 1;
     94         girdBagCon.insets = new Insets(0,1,10,15);
     95         girdBag.setConstraints(jTextField1, girdBagCon);
     96         centerPanel.add(jTextField1);
     97         
     98         jLabel2.setText("人 员 姓 名 :");
     99         jLabel2.setFont(new Font("Dialog",0,12));
    100         girdBagCon = new GridBagConstraints();
    101         girdBagCon.gridx = 2;
    102         girdBagCon.gridy = 1;
    103         girdBagCon.insets = new Insets(0,15,10,1);
    104         girdBag.setConstraints(jLabel2, girdBagCon);
    105         centerPanel.add(jLabel2);
    106         
    107         girdBagCon = new GridBagConstraints();
    108         girdBagCon.gridx = 3;
    109         girdBagCon.gridy = 1;
    110         girdBagCon.insets = new Insets(0,1,10,10);
    111         girdBag.setConstraints(jTextField2, girdBagCon);
    112         centerPanel.add(jTextField2);
    113         
    114         jLabel3.setText("性        别 :");
    115         jLabel3.setFont(new Font("Dialog",0,12));
    116         girdBagCon = new GridBagConstraints();
    117         girdBagCon.gridx = 0;
    118         girdBagCon.gridy = 2;
    119         girdBagCon.insets = new Insets(10,10,10,1);
    120         girdBag.setConstraints(jLabel3, girdBagCon);
    121         centerPanel.add(jLabel3);
    122         
    123         girdBagCon = new GridBagConstraints();
    124         girdBagCon.gridx = 1;
    125         girdBagCon.gridy = 2;
    126         girdBagCon.insets = new Insets(10,1,10,15);
    127         girdBag.setConstraints(jTextField3, girdBagCon);
    128         centerPanel.add(jTextField3);
    129         
    130         jLabel4.setText("出 生 年 月 :");
    131         jLabel4.setFont(new Font("Dialog",0,12));
    132         girdBagCon = new GridBagConstraints();
    133         girdBagCon.gridx = 2;
    134         girdBagCon.gridy = 2;
    135         girdBagCon.insets = new Insets(10,15,10,1);
    136         girdBag.setConstraints(jLabel4, girdBagCon);
    137         centerPanel.add(jLabel4);
    138         
    139         girdBagCon = new GridBagConstraints();
    140         girdBagCon.gridx = 3;
    141         girdBagCon.gridy = 2;
    142         girdBagCon.insets = new Insets(10,1,10,10);
    143         girdBag.setConstraints(jTextField4, girdBagCon);
    144         centerPanel.add(jTextField4);
    145         
    146         jLabel5.setText("民          族 :");
    147         jLabel5.setFont(new Font("Dialog",0,12));
    148         girdBagCon = new GridBagConstraints();
    149         girdBagCon.gridx = 0;
    150         girdBagCon.gridy = 3;
    151         girdBagCon.insets = new Insets(10,10,10,1);
    152         girdBag.setConstraints(jLabel5, girdBagCon);
    153         centerPanel.add(jLabel5);
    154         
    155         girdBagCon = new GridBagConstraints();
    156         girdBagCon.gridx = 1;
    157         girdBagCon.gridy = 3;
    158         girdBagCon.insets = new Insets(10,1,10,15);
    159         girdBag.setConstraints(jTextField5, girdBagCon);
    160         centerPanel.add(jTextField5);
    161         
    162         jLabel6.setText("地           址 :");
    163         jLabel6.setFont(new Font("Dialog",0,12));
    164         girdBagCon = new GridBagConstraints();
    165         girdBagCon.gridx = 2;
    166         girdBagCon.gridy = 3;
    167         girdBagCon.insets = new Insets(10,15,10,1);
    168         girdBag.setConstraints(jLabel6, girdBagCon);
    169         centerPanel.add(jLabel6);
    170         
    171         girdBagCon = new GridBagConstraints();
    172         girdBagCon.gridx = 3;
    173         girdBagCon.gridy = 3;
    174         girdBagCon.insets = new Insets(10,1,10,10);
    175         girdBag.setConstraints(jTextField6, girdBagCon);
    176         centerPanel.add(jTextField6);
    177         
    178         jLabel7.setText("部            门 :");
    179         jLabel7.setFont(new Font("Dialog",0,12));
    180         girdBagCon = new GridBagConstraints();
    181         girdBagCon.gridx = 0;
    182         girdBagCon.gridy = 4;
    183         girdBagCon.insets = new Insets(10,10,10,1);
    184         girdBag.setConstraints(jLabel7, girdBagCon);
    185         centerPanel.add(jLabel7);
    186         
    187         girdBagCon = new GridBagConstraints();
    188         girdBagCon.gridx = 1;
    189         girdBagCon.gridy = 4;
    190         girdBagCon.insets = new Insets(10,1,10,15);
    191         girdBag.setConstraints(jComboBox1, girdBagCon);
    192         centerPanel.add(jComboBox1);
    193         
    194         jLabel8.setText("其            他 :");
    195         jLabel8.setFont(new Font("Dialog",0,12));
    196         girdBagCon = new GridBagConstraints();
    197         girdBagCon.gridx = 2;
    198         girdBagCon.gridy = 4;
    199         girdBagCon.insets = new Insets(10,15,10,1);
    200         girdBag.setConstraints(jLabel8, girdBagCon);
    201         centerPanel.add(jLabel8);
    202         
    203         girdBagCon = new GridBagConstraints();
    204         girdBagCon.gridx = 3;
    205         girdBagCon.gridy = 4;
    206         girdBagCon.insets = new Insets(10,1,10,10);
    207         girdBag.setConstraints(jTextField8, girdBagCon);
    208         centerPanel.add(jTextField8);
    209         
    210         addInfo.setText("增加");
    211         addInfo.setFont(new Font("Dialog",0,12));
    212         girdBagCon = new GridBagConstraints();
    213         girdBagCon.gridx = 0;
    214         girdBagCon.gridy = 5;
    215         girdBagCon.gridwidth = 2;
    216         girdBagCon.gridheight = 1;
    217         girdBagCon.insets = new Insets(10,10,10,10);
    218         girdBag.setConstraints(addInfo, girdBagCon);
    219         centerPanel.add(addInfo);
    220         
    221         clearInfo.setText("清空");
    222         clearInfo.setFont(new Font("Dialog",0,12));
    223         girdBagCon = new GridBagConstraints();
    224         girdBagCon.gridx = 2;
    225         girdBagCon.gridy = 5;
    226         girdBagCon.gridwidth = 2;
    227         girdBagCon.gridheight = 1;
    228         girdBagCon.insets = new Insets(10,10,10,10);
    229         girdBag.setConstraints(clearInfo, girdBagCon);
    230         centerPanel.add(clearInfo);
    231     }
    232     public void panelInit() throws Exception
    233     {
    234         upPanel.setLayout(girdBag);
    235         
    236         jLabel.setText("增加人员信息");
    237         jLabel.setFont(new Font("Dialog",0,16));
    238         girdBagCon = new GridBagConstraints();
    239         girdBagCon.gridx = 0;
    240         girdBagCon.gridy = 0;
    241         girdBagCon.insets = new Insets(0,10,0,10);
    242         girdBag.setConstraints(jLabel, girdBagCon);
    243         upPanel.add(jLabel);
    244         
    245         jScrollPane1 = new JScrollPane(centerPanel);
    246         jScrollPane1.setPreferredSize(new Dimension(450,380));
    247         
    248         girdBagCon = new GridBagConstraints();
    249         girdBagCon.gridx = 0;
    250         girdBagCon.gridy = 1;
    251         girdBagCon.insets = new Insets(0,0,0,0);
    252         girdBag.setConstraints(jScrollPane1, girdBagCon);
    253         upPanel.add(jScrollPane1);
    254         
    255         this.add(upPanel,BorderLayout.NORTH);
    256         
    257         jTextField1.setEditable(false);
    258         jTextField2.setEditable(true);
    259         jTextField3.setEditable(true);
    260         jTextField4.setEditable(true);
    261         jTextField5.setEditable(true);
    262         jTextField6.setEditable(true);
    263         jTextField8.setEditable(true);
    264         
    265         jTextField1.setText(""+bean.getId());
    266     }
    267     /**
    268      * 添加事件监听
    269      */
    270     public void addListener() throws Exception
    271     {
    272         addInfo.addActionListener(this);
    273         clearInfo.addActionListener(this);
    274         jComboBox1.addItemListener(this);
    275     }
    276     /**
    277      * 事件处理
    278      */
    279     public void actionPerformed(ActionEvent e)
    280     {
    281         Object obj = e.getSource();
    282         if(obj==addInfo){
    283             bean.add(jTextField1.getText(),jTextField2.getText(),
    284                     jTextField3.getText(),jTextField4.getText(),
    285                     jTextField5.getText(),jTextField6.getText(),
    286                     DeptID,Salary,Assess,jTextField8.getText());
    287             Node11Panel nodellPanel = new Node11Panel();
    288             HrMain.splitPane.setRightComponent(nodellPanel);
    289         }
    290         else if(obj==clearInfo){
    291             setNull();
    292         }
    293     }
    294     /**
    295      * 将文本框清空
    296      */
    297     void setNull()
    298     {
    299         jTextField2.setText(null);
    300         jTextField3.setText(null);
    301         jTextField4.setText(null);
    302         jTextField5.setText(null);
    303         jTextField6.setText(null);
    304         jTextField8.setText(null);
    305     }
    306     /**
    307      * 下拉菜单事件处理
    308      */
    309     public void itemStateChanged(ItemEvent e)
    310     {
    311         if(e.getStateChange() == ItemEvent.SELECTED){
    312             String tempStr = ""+e.getItem();
    313             int i = tempStr.indexOf("-");
    314             DeptID = tempStr.substring(0,i);
    315         }
    316     }
    317 }
    Node11Panel

    修改人员信息主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 
      8 /**
      9  * 
     10  * 修改人员信息
     11  *
     12  */
     13 public class Node12Panel extends JPanel implements ActionListener,ItemListener
     14 {
     15     JPanel centerPanel = new JPanel();
     16     JPanel upPanel = new JPanel();
     17     
     18     //定义图形界面元素
     19     JLabel jLabel = new JLabel();
     20     JLabel jLabel1 = new JLabel();
     21     JLabel jLabel2 = new JLabel();
     22     JLabel jLabel3 = new JLabel();
     23     JLabel jLabel4 = new JLabel();
     24     JLabel jLabel5 = new JLabel();
     25     JLabel jLabel6 = new JLabel();
     26     JLabel jLabel7 = new JLabel();
     27     JLabel jLabel8 = new JLabel();
     28     JLabel jLabel9 = new JLabel();
     29     
     30     JTextField jTextField1 = new JTextField(15);//编号
     31     JTextField jTextField2 = new JTextField(15);//姓名
     32     JTextField jTextField3 = new JTextField(15);//性别
     33     JTextField jTextField4 = new JTextField(15);//出生年月
     34     JTextField jTextField5 = new JTextField(15);//民族
     35     JTextField jTextField6 = new JTextField(15);//地址
     36     String DeptID = "";//部门
     37     String Salary = "";//薪酬
     38     String Assess = "";//考核
     39     JTextField jTextField8 = new JTextField(30);//其他
     40     
     41     JComboBox jComboBox1 = null;//人员信息
     42     
     43     String personID = "";
     44     String[] person = null;
     45     
     46     JScrollPane jScrollPane1;
     47     
     48     JButton searchInfo = new JButton();
     49     JButton addInfo = new JButton();
     50     JButton modifyInfo = new JButton();
     51     JButton deleteInfo = new JButton();
     52     JButton clearInfo = new JButton();
     53     JButton saveInfo = new JButton();
     54     JButton exitInfo = new JButton();
     55     
     56     JButton jBSee = new JButton();
     57     JButton jBSearch = new JButton();
     58     JButton jBExit = new JButton();
     59     JButton jBSum = new JButton();
     60     JButton jBGrade = new JButton();
     61     
     62     GridBagLayout girdBag = new GridBagLayout();
     63     GridBagConstraints girdBagCon;
     64     
     65     PersonBean bean = new PersonBean();
     66     
     67     public Node12Panel()
     68     {
     69         this.setLayout(new BorderLayout());
     70         try{
     71             jScrollPanelInit();
     72             panelInit();
     73             addListener();
     74         }
     75         catch(Exception e){
     76             e.printStackTrace();
     77         }
     78     }
     79     /**
     80      * jScrol2Panel面板的布局
     81      */
     82     public void jScrollPanelInit() throws Exception
     83     {
     84         centerPanel.setLayout(girdBag);
     85         centerPanel.setLayout(girdBag);
     86         
     87         jLabel1.setText("人 员 编 号 :");
     88         jLabel1.setFont(new Font("Dialog",0,12));
     89         girdBagCon = new GridBagConstraints();
     90         girdBagCon.gridx = 0;
     91         girdBagCon.gridy = 1;
     92         girdBagCon.insets = new Insets(0,10,10,1);
     93         girdBag.setConstraints(jLabel1, girdBagCon);
     94         centerPanel.add(jLabel1);
     95         
     96         girdBagCon = new GridBagConstraints();
     97         girdBagCon.gridx = 1;
     98         girdBagCon.gridy = 1;
     99         girdBagCon.insets = new Insets(0,1,10,15);
    100         girdBag.setConstraints(jTextField1, girdBagCon);
    101         centerPanel.add(jTextField1);
    102         
    103         jLabel2.setText("人 员 姓 名 :");
    104         jLabel2.setFont(new Font("Dialog",0,12));
    105         girdBagCon = new GridBagConstraints();
    106         girdBagCon.gridx = 2;
    107         girdBagCon.gridy = 1;
    108         girdBagCon.insets = new Insets(0,15,10,1);
    109         girdBag.setConstraints(jLabel2, girdBagCon);
    110         centerPanel.add(jLabel2);
    111         
    112         girdBagCon = new GridBagConstraints();
    113         girdBagCon.gridx = 3;
    114         girdBagCon.gridy = 1;
    115         girdBagCon.insets = new Insets(0,1,10,10);
    116         girdBag.setConstraints(jTextField2, girdBagCon);
    117         centerPanel.add(jTextField2);
    118         
    119         jLabel3.setText("性        别 :");
    120         jLabel3.setFont(new Font("Dialog",0,12));
    121         girdBagCon = new GridBagConstraints();
    122         girdBagCon.gridx = 0;
    123         girdBagCon.gridy = 2;
    124         girdBagCon.insets = new Insets(10,10,10,1);
    125         girdBag.setConstraints(jLabel3, girdBagCon);
    126         centerPanel.add(jLabel3);
    127         
    128         girdBagCon = new GridBagConstraints();
    129         girdBagCon.gridx = 1;
    130         girdBagCon.gridy = 2;
    131         girdBagCon.insets = new Insets(10,1,10,15);
    132         girdBag.setConstraints(jTextField3, girdBagCon);
    133         centerPanel.add(jTextField3);
    134         
    135         jLabel4.setText("出 生 年 月 :");
    136         jLabel4.setFont(new Font("Dialog",0,12));
    137         girdBagCon = new GridBagConstraints();
    138         girdBagCon.gridx = 2;
    139         girdBagCon.gridy = 2;
    140         girdBagCon.insets = new Insets(10,15,10,1);
    141         girdBag.setConstraints(jLabel4, girdBagCon);
    142         centerPanel.add(jLabel4);
    143         
    144         girdBagCon = new GridBagConstraints();
    145         girdBagCon.gridx = 3;
    146         girdBagCon.gridy = 2;
    147         girdBagCon.insets = new Insets(10,1,10,10);
    148         girdBag.setConstraints(jTextField4, girdBagCon);
    149         centerPanel.add(jTextField4);
    150         
    151         jLabel5.setText("民          族 :");
    152         jLabel5.setFont(new Font("Dialog",0,12));
    153         girdBagCon = new GridBagConstraints();
    154         girdBagCon.gridx = 0;
    155         girdBagCon.gridy = 3;
    156         girdBagCon.insets = new Insets(10,10,10,1);
    157         girdBag.setConstraints(jLabel5, girdBagCon);
    158         centerPanel.add(jLabel5);
    159         
    160         girdBagCon = new GridBagConstraints();
    161         girdBagCon.gridx = 1;
    162         girdBagCon.gridy = 3;
    163         girdBagCon.insets = new Insets(10,1,10,15);
    164         girdBag.setConstraints(jTextField5, girdBagCon);
    165         centerPanel.add(jTextField5);
    166         
    167         jLabel6.setText("地           址 :");
    168         jLabel6.setFont(new Font("Dialog",0,12));
    169         girdBagCon = new GridBagConstraints();
    170         girdBagCon.gridx = 2;
    171         girdBagCon.gridy = 3;
    172         girdBagCon.insets = new Insets(10,15,10,1);
    173         girdBag.setConstraints(jLabel6, girdBagCon);
    174         centerPanel.add(jLabel6);
    175         
    176         girdBagCon = new GridBagConstraints();
    177         girdBagCon.gridx = 3;
    178         girdBagCon.gridy = 3;
    179         girdBagCon.insets = new Insets(10,1,10,10);
    180         girdBag.setConstraints(jTextField6, girdBagCon);
    181         centerPanel.add(jTextField6);
    182         
    183         jLabel8.setText("其            他 :");
    184         jLabel8.setFont(new Font("Dialog",0,12));
    185         girdBagCon = new GridBagConstraints();
    186         girdBagCon.gridx = 0;
    187         girdBagCon.gridy = 4;
    188         girdBagCon.insets = new Insets(10,10,10,1);
    189         girdBag.setConstraints(jLabel8, girdBagCon);
    190         centerPanel.add(jLabel8);
    191         
    192         girdBagCon = new GridBagConstraints();
    193         girdBagCon.gridx = 1;
    194         girdBagCon.gridy = 4;
    195         girdBagCon.gridwidth = 3;
    196         girdBagCon.gridheight = 1;
    197         girdBagCon.insets = new Insets(10,1,10,115);
    198         girdBag.setConstraints(jTextField8, girdBagCon);
    199         centerPanel.add(jTextField8);
    200         
    201         jLabel9.setText("选择人员信息");
    202         jLabel9.setFont(new Font("Dialog",0,12));
    203         girdBagCon = new GridBagConstraints();
    204         girdBagCon.gridx = 0;
    205         girdBagCon.gridy = 5;
    206         girdBagCon.insets = new Insets(10,10,10,1);
    207         girdBag.setConstraints(jLabel9, girdBagCon);
    208         centerPanel.add(jLabel9);
    209         
    210         String[] allType = bean.getAllId();
    211         jComboBox1 = new JComboBox<Object>(allType);
    212         girdBagCon = new GridBagConstraints();
    213         girdBagCon.gridx = 1;
    214         girdBagCon.gridy = 5;
    215         girdBagCon.gridwidth = 1;
    216         girdBagCon.gridheight = 1;
    217         girdBagCon.insets = new Insets(1,10,10,10);
    218         girdBag.setConstraints(jComboBox1, girdBagCon);
    219         centerPanel.add(jComboBox1);
    220         
    221         modifyInfo.setText("修改");
    222         modifyInfo.setFont(new Font("Dialog",0,12));
    223         girdBagCon = new GridBagConstraints();
    224         girdBagCon.gridx = 2;
    225         girdBagCon.gridy = 5;
    226         girdBagCon.insets = new Insets(10,10,10,10);
    227         girdBag.setConstraints(modifyInfo, girdBagCon);
    228         centerPanel.add(modifyInfo);
    229         modifyInfo.setEnabled(false);
    230         
    231         clearInfo.setText("清空");
    232         clearInfo.setFont(new Font("Dialog",0,12));
    233         girdBagCon = new GridBagConstraints();
    234         girdBagCon.gridx = 3;
    235         girdBagCon.gridy = 5;
    236         girdBagCon.insets = new Insets(10,10,10,10);
    237         girdBag.setConstraints(clearInfo, girdBagCon);
    238         centerPanel.add(clearInfo);
    239     }
    240     public void panelInit() throws Exception
    241     {
    242         upPanel.setLayout(girdBag);
    243         
    244         jLabel.setText("修改人员信息");
    245         jLabel.setFont(new Font("Dialog",0,16));
    246         girdBagCon = new GridBagConstraints();
    247         girdBagCon.gridx = 0;
    248         girdBagCon.gridy = 0;
    249         girdBagCon.insets = new Insets(0,10,0,10);
    250         girdBag.setConstraints(jLabel, girdBagCon);
    251         upPanel.add(jLabel);
    252         
    253         jScrollPane1 = new JScrollPane(centerPanel);
    254         jScrollPane1.setPreferredSize(new Dimension(450,380));
    255         
    256         girdBagCon = new GridBagConstraints();
    257         girdBagCon.gridx = 0;
    258         girdBagCon.gridy = 1;
    259         girdBagCon.insets = new Insets(0,0,0,0);
    260         girdBag.setConstraints(jScrollPane1, girdBagCon);
    261         upPanel.add(jScrollPane1);
    262         
    263         this.add(upPanel,BorderLayout.NORTH);
    264         
    265         jTextField1.setEditable(false);
    266         jTextField2.setEditable(false);
    267         jTextField3.setEditable(false);
    268         jTextField4.setEditable(false);
    269         jTextField5.setEditable(false);
    270         jTextField6.setEditable(false);
    271         jTextField8.setEditable(false);
    272         
    273         jTextField1.setText("请查询人员编号");
    274     }
    275     /**
    276      * 添加事件监听
    277      */
    278     public void addListener() throws Exception
    279     {
    280         modifyInfo.addActionListener(this);
    281         clearInfo.addActionListener(this);
    282         searchInfo.addActionListener(this);
    283         jComboBox1.addItemListener(this);
    284     }
    285     /**
    286      * 事件处理
    287      */
    288     public void actionPerformed(ActionEvent e)
    289     {
    290         Object obj = e.getSource();
    291         String[] s = new String[10];
    292         if(obj == modifyInfo){
    293             bean.modify(jTextField1.getText(),jTextField2.getText(),
    294                     jTextField3.getText(),jTextField4.getText(),
    295                     jTextField5.getText(),jTextField6.getText(),
    296                     DeptID,Salary,Assess,jTextField8.getText());
    297             Node12Panel nodel2Panel = new Node12Panel();
    298             HrMain.splitPane.setRightComponent(nodel2Panel);
    299         }
    300         else if(obj == searchInfo){//编号查询
    301         }
    302         else if(obj == clearInfo){
    303             setNull();
    304         }
    305     }
    306     /**
    307      * 将文本框清空
    308      */
    309     void setNull()
    310     {
    311         jTextField2.setText(null);
    312         jTextField3.setText(null);
    313         jTextField4.setText(null);
    314         jTextField5.setText(null);
    315         jTextField6.setText(null);
    316         jTextField8.setText(null);
    317         jTextField1.setText("请查询人员编号");
    318         
    319         jTextField2.setEditable(false);
    320         jTextField3.setEditable(false);
    321         jTextField4.setEditable(false);
    322         jTextField5.setEditable(false);
    323         jTextField6.setEditable(false);
    324         jTextField8.setEditable(false);
    325         modifyInfo.setEnabled(false);
    326     }
    327     /**
    328      * 下拉菜单事件处理
    329      */
    330     public void itemStateChanged(ItemEvent e)
    331     {
    332         if(e.getStateChange() == ItemEvent.SELECTED){
    333             String tempStr = ""+e.getItem();
    334             int i = tempStr.indexOf("-");
    335             personID = tempStr.substring(0,i);
    336             person = bean.search(personID);
    337             //数组初始化
    338             jTextField1.setText(person[0]);
    339             jTextField2.setText(person[1]);
    340             jTextField3.setText(person[2]);
    341             jTextField4.setText(person[3]);
    342             jTextField5.setText(person[4]);
    343             jTextField6.setText(person[5]);
    344             DeptID = ""+person[6];
    345             Salary = ""+person[7];
    346             Assess = ""+person[8];
    347             jTextField8.setText(person[9]);
    348             
    349             jTextField2.setEditable(true);
    350             jTextField3.setEditable(true);
    351             jTextField4.setEditable(true);
    352             jTextField5.setEditable(true);
    353             jTextField6.setEditable(true);
    354             jTextField8.setEditable(true);
    355             
    356             modifyInfo.setEnabled(true);
    357         }
    358     }
    359 }
    Node12Panel

    删除人员信息主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 import javax.swing.event.*;
      8 /**
      9  * 
     10  * 人员信息删除管理
     11  *
     12  */
     13 public class Node13Panel extends JPanel implements ActionListener,ListSelectionListener
     14 {
     15     JPanel centerPanel = new JPanel();
     16     JPanel upPanel = new JPanel();
     17     JPanel downPanel = new JPanel();
     18     
     19     //定义图形界面元素
     20     JLabel jLabel = new JLabel();
     21     JLabel jLabel1 = new JLabel();
     22     JLabel jLabel2 = new JLabel();
     23     JLabel jLabel3 = new JLabel();
     24     
     25     JTextField jTextField1 = new JTextField(15);
     26     JTextField jTextField2 = new JTextField(15);
     27     JTextField jTextField3 = new JTextField(15);
     28     
     29     JButton searchInfo = new JButton();
     30     JButton addInfo = new JButton();
     31     JButton modifyInfo = new JButton();
     32     JButton deleteInfo = new JButton();
     33     JButton clearInfo = new JButton();
     34     JButton saveInfo = new JButton();
     35     JButton exitInfo = new JButton();
     36     
     37     JScrollPane jScrollPane1;
     38     JTable jTable;
     39     ListSelectionModel listSelectionModel = null;
     40     String[] colName = {"编号","姓名","出生年月","民族","地址","部门"};
     41     String[][] colValue;
     42     
     43     GridBagLayout girdBag = new GridBagLayout();
     44     GridBagConstraints girdBagCon;
     45     
     46     public Node13Panel()
     47     {
     48         this.setLayout(new BorderLayout());
     49         try{
     50             upInit();//上部面板设置
     51             centerInit();//中部面板设置
     52             downInit();//下部面板设置
     53             addListener();
     54         }
     55         catch(Exception e){
     56             e.printStackTrace();
     57         }
     58     }
     59     /**
     60      * 上部面板的布局
     61      */
     62     public void upInit() throws Exception
     63     {
     64         PersonBean bean = new PersonBean();
     65         upPanel.setLayout(girdBag);
     66         
     67         try{
     68         jLabel.setText("人员信息删除");
     69         jLabel.setFont(new Font("Dialog",0,16));
     70         girdBagCon = new GridBagConstraints();
     71         girdBagCon.gridx = 0;
     72         girdBagCon.gridy = 0;
     73         girdBagCon.insets = new Insets(0,10,0,10);
     74         girdBag.setConstraints(jLabel, girdBagCon);
     75         centerPanel.add(jLabel);
     76         upPanel.add(jLabel);
     77         
     78         colValue = bean.searchAll();
     79         jTable = new JTable(colValue,colName);
     80         jTable.setPreferredScrollableViewportSize(new Dimension(450,300));
     81         listSelectionModel = jTable.getSelectionModel();
     82         listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
     83         listSelectionModel.addListSelectionListener(this);
     84         jScrollPane1 = new JScrollPane(centerPanel);
     85         jScrollPane1.setPreferredSize(new Dimension(450,300));
     86         
     87         girdBagCon = new GridBagConstraints();
     88         girdBagCon.gridx = 0;
     89         girdBagCon.gridy = 1;
     90         girdBagCon.insets = new Insets(0,0,0,0);
     91         girdBag.setConstraints(jScrollPane1, girdBagCon);
     92         upPanel.add(jScrollPane1);
     93         }
     94         catch(Exception e){
     95             e.printStackTrace();
     96         }
     97         this.add(upPanel,BorderLayout.NORTH);
     98     }
     99     /**
    100      * 中部面板的布局
    101      */
    102     public void centerInit() throws Exception
    103     {
    104         jLabel1.setText("编号");
    105         jLabel1.setFont(new Font("Dialog",0,12));
    106         centerPanel.add(jLabel1);
    107         centerPanel.add(jTextField1);
    108         
    109         jLabel2.setText("姓名");
    110         jLabel2.setFont(new Font("Dialog",0,12));
    111         centerPanel.add(jLabel2);
    112         centerPanel.add(jTextField2);
    113         
    114         jLabel3.setText("部门");
    115         jLabel3.setFont(new Font("Dialog",0,12));
    116         centerPanel.add(jLabel3);
    117         centerPanel.add(jTextField3);
    118         
    119         //添加中部面板
    120         this.add(centerPanel,BorderLayout.CENTER);
    121         //设置是否可操作
    122         jTextField1.setEditable(false);
    123         jTextField2.setEditable(false);
    124         jTextField3.setEditable(false);
    125     }
    126     /**
    127      * 下部面板的布局
    128      */
    129     public void downInit()
    130     {
    131         deleteInfo.setText("删除");
    132         deleteInfo.setFont(new Font("Dialog",0,12));
    133         downPanel.add(deleteInfo);
    134         //添加下部面板
    135         this.add(downPanel,BorderLayout.SOUTH);
    136         //设置是否可操作
    137         deleteInfo.setEnabled(false);
    138     }
    139     /**
    140      * 添加事件监听
    141      */
    142     public void addListener() throws Exception
    143     {
    144         deleteInfo.addActionListener(this);
    145     }
    146     /**
    147      * 事件处理
    148      */
    149     public void actionPerformed(ActionEvent e)
    150     {
    151         Object obj = e.getSource();
    152         if(obj == deleteInfo){
    153             PersonBean bean = new PersonBean();
    154             HistrjnBean hb = new HistrjnBean();
    155             if(hb.isRows(jTextField1.getText()))
    156                 bean.delete(jTextField1.getText());
    157             else
    158                 JOptionPane.showMessageDialog(null, "已有数据关联,无法删除。","错误",JOptionPane.ERROR_MESSAGE);
    159             //重新生成页面
    160             Node13Panel node13Panel = new Node13Panel();
    161             HrMain.splitPane.setRightComponent(node13Panel);
    162         }
    163         jTable.revalidate();
    164     }
    165     /**
    166      * 当表格被选中时的操作
    167      */
    168     public void valueChanged(ListSelectionEvent lse)
    169     {
    170         int[] selectedRow = jTable.getSelectedRows();
    171         int[] selectedCol = jTable.getSelectedColumns();
    172         //定义文本框显示的内容
    173         for(int i=0;i<selectedRow.length;i++){
    174             for(int j=0;j<selectedCol.length;j++){
    175                 jTextField1.setText(colValue[selectedRow[i]][0]);
    176                 jTextField2.setText(colValue[selectedRow[i]][1]);
    177                 jTextField3.setText(colValue[selectedRow[i]][2]);
    178             }
    179         }
    180         deleteInfo.setEnabled(false);
    181     }
    182 }
    Node13Panel

    查询人员信息主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 import javax.swing.event.*;
      8 /**
      9  * 
     10  * 人员信息查询管理
     11  *
     12  */
     13 public class Node14Panel extends JPanel implements ActionListener
     14 {
     15     JPanel centerPanel = new JPanel();
     16     JPanel upPanel = new JPanel();
     17     JPanel downPanel = new JPanel();
     18     
     19     //定义图形界面元素
     20     JLabel jLabel = new JLabel();
     21     JLabel jLabel1 = new JLabel();
     22     JLabel jLabel2 = new JLabel();
     23     JLabel jLabel3 = new JLabel();
     24     
     25     //定义表格
     26     JScrollPane jScrollPanel;
     27     JTable jTable;
     28     ListSelectionModel listSelectionModel = null;
     29     String[] colName = {"编号","姓名","出生年月","民族","地址","部门"};
     30     String[][] colValue;
     31     
     32     GridBagLayout girdBag = new GridBagLayout();
     33     GridBagConstraints girdBagCon;
     34     
     35     public Node14Panel()
     36     {
     37         this.setLayout(new BorderLayout());
     38         try{
     39             upInit();//上部面板设置
     40             centerInit();//中部面板设置
     41             downInit();//下部面板设置
     42             addListener();
     43         }
     44         catch(Exception e){
     45             e.printStackTrace();
     46         }
     47     }
     48     
     49     /**
     50      * 上部面板的布局
     51      */
     52     public void upInit() throws Exception
     53     {
     54         PersonBean bean = new PersonBean();
     55         upPanel.setLayout(girdBag);
     56         
     57         try{
     58         jLabel.setText("人员信息查询");
     59         jLabel.setFont(new Font("Dialog",0,16));
     60         girdBagCon = new GridBagConstraints();
     61         girdBagCon.gridx = 0;
     62         girdBagCon.gridy = 0;
     63         girdBagCon.insets = new Insets(0,10,0,10);
     64         girdBag.setConstraints(jLabel, girdBagCon);
     65         centerPanel.add(jLabel);
     66         upPanel.add(jLabel);
     67         
     68         colValue = bean.searchAll();
     69         jTable = new JTable(colValue,colName);
     70         jTable.setPreferredScrollableViewportSize(new Dimension(450,380));
     71         jScrollPanel = new JScrollPane(jTable);
     72         jScrollPanel.setPreferredSize(new Dimension(450,380));
     73         
     74         girdBagCon = new GridBagConstraints();
     75         girdBagCon.gridx = 0;
     76         girdBagCon.gridy = 1;
     77         girdBagCon.insets = new Insets(0,0,0,0);
     78         girdBag.setConstraints(jScrollPanel, girdBagCon);
     79         upPanel.add(jScrollPanel);
     80         }
     81         catch(Exception e){
     82             e.printStackTrace();
     83         }
     84         this.add(upPanel,BorderLayout.NORTH);
     85     }
     86     /**
     87      * 中部面板的布局
     88      */
     89     public void centerInit() throws Exception
     90     {
     91     }
     92     /**
     93      * 下部面板的布局
     94      */
     95     public void downInit()
     96     {
     97     }
     98     /**
     99      * 添加事件监听
    100      */
    101     public void addListener() throws Exception
    102     {
    103     }
    104     /**
    105      * 事件处理
    106      */
    107     public void actionPerformed(ActionEvent e)
    108     {
    109     }
    110 }
    Node14Panel

    部门管理界面主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 import javax.swing.event.*;
      8 /**
      9  * 
     10  * 部门管理
     11  *
     12  */
     13 public class Node15Panel extends JPanel implements ActionListener,ListSelectionListener
     14 {
     15     JPanel centerPanel = new JPanel();
     16     JPanel upPanel = new JPanel();
     17     JPanel downPanel = new JPanel();
     18     
     19     //定义图形界面元素
     20     JLabel jLabel1 = new JLabel();
     21     JLabel jLabel2 = new JLabel();
     22     JLabel jLabel3 = new JLabel();
     23     
     24     JTextField jTextField1 = new JTextField(15);
     25     JTextField jTextField2 = new JTextField(15);
     26     JTextField jTextField3 = new JTextField(15);
     27     
     28     JButton searchInfo = new JButton();
     29     JButton addInfo = new JButton();
     30     JButton modifyInfo = new JButton();
     31     JButton deleteInfo = new JButton();
     32     JButton clearInfo = new JButton();
     33     JButton saveInfo = new JButton();
     34     JButton exitInfo = new JButton();
     35     
     36     //定义表格
     37     JScrollPane jScrollPane1;
     38     JTable jTable;
     39     ListSelectionModel listSelectionModel = null;
     40     String[] colName = {"部门编号","一级部门","二级部门"};
     41     String[][] colValue;
     42     
     43     GridBagLayout girdBag = new GridBagLayout();
     44     GridBagConstraints girdBagCon;
     45     
     46     public Node15Panel()
     47     {
     48         this.setLayout(new BorderLayout());
     49         try{
     50             upInit();//上部面板设置
     51             centerInit();//中部面板设置
     52             downInit();//下部面板设置
     53             addListener();
     54         }
     55         catch(Exception e){
     56             e.printStackTrace();
     57         }
     58     }
     59     /**
     60      * 上部面板的布局
     61      */
     62     public void upInit() throws Exception
     63     {
     64         DeptBean bean = new DeptBean();
     65         
     66         try{
     67             colValue = bean.searchAll();
     68             jTable = new JTable(colValue,colName);
     69             jTable.setPreferredScrollableViewportSize(new Dimension(450,300));
     70             listSelectionModel = jTable.getSelectionModel();
     71             listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     72             listSelectionModel.addListSelectionListener(this);
     73             jScrollPane1 = new JScrollPane(jTable);
     74             jScrollPane1.setPreferredSize(new Dimension(450,300));
     75         }
     76         catch(Exception e){
     77             e.printStackTrace();
     78         }
     79         upPanel.add(jScrollPane1);
     80         this.add(upPanel,BorderLayout.NORTH);
     81     }
     82     /**
     83      * 中部面板的布局
     84      */
     85     public void centerInit() throws Exception
     86     {
     87         jLabel1.setText("编号");
     88         jLabel1.setFont(new Font("Dialog",0,12));
     89         centerPanel.add(jLabel1);
     90         centerPanel.add(jTextField1);
     91         
     92         jLabel2.setText("一级部门");
     93         jLabel2.setFont(new Font("Dialog",0,12));
     94         centerPanel.add(jLabel2);
     95         centerPanel.add(jTextField2);
     96         
     97         jLabel3.setText("二级部门");
     98         jLabel3.setFont(new Font("Dialog",0,12));
     99         centerPanel.add(jLabel3);
    100         centerPanel.add(jTextField3);
    101         
    102         //添加中部面板
    103         this.add(centerPanel,BorderLayout.CENTER);
    104         //设置是否可操作
    105         jTextField1.setEditable(false);
    106         jTextField2.setEditable(false);
    107         jTextField3.setEditable(false);
    108     }
    109     /**
    110      * 下部面板的布局
    111      */
    112     public void downInit()
    113     {
    114         searchInfo.setText("获取新的编号");
    115         searchInfo.setFont(new Font("Dialog",0,12));
    116         downPanel.add(searchInfo);
    117         addInfo.setText("增加");
    118         addInfo.setFont(new Font("Dialog",0,12));
    119         downPanel.add(addInfo);
    120         modifyInfo.setText("修改");
    121         modifyInfo.setFont(new Font("Dialog",0,12));
    122         downPanel.add(modifyInfo);
    123         deleteInfo.setText("删除");
    124         deleteInfo.setFont(new Font("Dialog",0,12));
    125         downPanel.add(deleteInfo);
    126         clearInfo.setText("清空");
    127         clearInfo.setFont(new Font("Dialog",0,12));
    128         downPanel.add(clearInfo);
    129         //添加下部面板
    130         this.add(downPanel,BorderLayout.SOUTH);
    131         //设置是否可操作
    132         searchInfo.setEnabled(true);
    133         addInfo.setEnabled(false);
    134         modifyInfo.setEnabled(false);
    135         deleteInfo.setEnabled(false);
    136         clearInfo.setEnabled(true);
    137     }
    138     /**
    139      * 添加事件监听
    140      */
    141     public void addListener() throws Exception
    142     {
    143         searchInfo.addActionListener(this);
    144         addInfo.addActionListener(this);
    145         modifyInfo.addActionListener(this);
    146         deleteInfo.addActionListener(this);
    147         clearInfo.addActionListener(this);
    148     }
    149     /**
    150      * 事件处理
    151      */
    152     public void actionPerformed(ActionEvent e)
    153     {
    154         Object obj = e.getSource();
    155         if(obj == searchInfo){
    156             setNull();
    157             //获取新编号
    158             DeptBean bean = new DeptBean();
    159             jTextField1.setText(""+bean.getId());
    160             jTextField2.setEnabled(true);
    161             jTextField3.setEnabled(true);
    162             //设置是否可操作
    163             addInfo.setEnabled(true);
    164             modifyInfo.setEnabled(false);
    165             deleteInfo.setEnabled(false);
    166         }
    167         else if(obj == addInfo){
    168             DeptBean bean = new DeptBean();
    169             bean.add(jTextField1.getText(),jTextField2.getText(),jTextField3.getText());
    170             //重新生成界面
    171             Node15Panel dp = new Node15Panel();
    172             HrMain.splitPane.setRightComponent(dp);
    173         }
    174         else if(obj == modifyInfo){
    175             DeptBean bean = new DeptBean();
    176             bean.modify(jTextField1.getText(),jTextField2.getText(),jTextField3.getText());
    177             //重新生成界面
    178             Node15Panel dp = new Node15Panel();
    179             HrMain.splitPane.setRightComponent(dp);
    180         }
    181         else if(obj == deleteInfo){
    182             DeptBean bean = new DeptBean();
    183             bean.delete(jTextField1.getText());
    184             //重新生成界面
    185             Node15Panel dp = new Node15Panel();
    186             HrMain.splitPane.setRightComponent(dp);
    187         }
    188         else if(obj == clearInfo){
    189             setNull();
    190         }
    191         jTable.revalidate();
    192     }
    193     /**
    194      * 将文本框清空
    195      */
    196     void setNull()
    197     {
    198         jTextField1.setText(null);
    199         jTextField2.setText(null);
    200         jTextField3.setText(null);
    201         jTextField2.setEditable(false);
    202         jTextField3.setEditable(false);
    203         
    204         searchInfo.setEnabled(true);
    205         addInfo.setEnabled(false);
    206         modifyInfo.setEnabled(false);
    207         deleteInfo.setEnabled(false);
    208         clearInfo.setEnabled(true);
    209     }
    210     /**
    211      * 当表格被选中时的操作
    212      */
    213     public void valueChanged(ListSelectionEvent lse)
    214     {
    215         int[] selectedRow = jTable.getSelectedRows();
    216         int[] selectedCol = jTable.getSelectedColumns();
    217         //定义文本框显示的内容
    218         for(int i=0;i<selectedRow.length;i++){
    219             for(int j=0;j<selectedCol.length;j++){
    220                 jTextField1.setText(colValue[selectedRow[i]][0]);
    221                 jTextField2.setText(colValue[selectedRow[i]][1]);
    222                 jTextField3.setText(colValue[selectedRow[i]][2]);
    223             }
    224         }
    225         //设置是否可操作
    226         jTextField2.setEditable(true);
    227         jTextField3.setEditable(true);
    228         
    229         searchInfo.setEnabled(true);
    230         addInfo.setEnabled(false);
    231         modifyInfo.setEnabled(true);
    232         deleteInfo.setEnabled(true);
    233         clearInfo.setEnabled(true);
    234     }
    235 }
    Node15Panel

    树中第二节点——人员调动管理模块:

    人员调动主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 import javax.swing.event.*;
      8 import java.util.*;
      9 import java.text.*;
     10 /**
     11  * 
     12  * 人员调动
     13  *
     14  */
     15 public class Node21Panel extends JPanel implements ActionListener,ListSelectionListener,ItemListener
     16 {
     17     JPanel centerPanel = new JPanel();
     18     JPanel upPanel = new JPanel();
     19     JPanel downPanel = new JPanel();
     20     
     21     //定义图形界面元素
     22     JLabel jLabel = new JLabel();
     23     JLabel jLabel1 = new JLabel();
     24     JLabel jLabel2 = new JLabel();
     25     JLabel jLabel3 = new JLabel();
     26     
     27     JTextField jTextField1 = new JTextField(15);
     28     JTextField jTextField2 = new JTextField(15);
     29     String DeptID = "1";
     30     String PersonID = null;
     31     String oldDeptID = null;
     32     
     33     JComboBox jComboBox1 = null;
     34 
     35     JButton modifyInfo = new JButton();
     36     JButton clearInfo = new JButton();
     37     
     38     //定义表格
     39     JScrollPane jScrollPane1;
     40     JTable jTable;
     41     ListSelectionModel listSelectionModel = null;
     42     String[] colName = {"工号","姓名","性别","部门","薪酬","考核信息"};
     43     String[][] colValue;
     44     
     45     GridBagLayout girdBag = new GridBagLayout();
     46     GridBagConstraints girdBagCon;
     47     
     48     public Node21Panel()
     49     {
     50         this.setLayout(new BorderLayout());
     51         try{
     52             upInit();
     53             centerInit();
     54             downInit();
     55             addListener();
     56         }
     57         catch(Exception e){
     58             e.printStackTrace();
     59         }
     60     }
     61     /**
     62      * 上部面板的布局
     63      */
     64     public void upInit() throws Exception
     65     {
     66         PersonBean bean = new PersonBean();
     67         upPanel.setLayout(girdBag);
     68         
     69         try{
     70             jLabel.setText("人员调动");
     71             jLabel.setFont(new Font("Dialog",0,16));
     72             girdBagCon = new GridBagConstraints();
     73             girdBagCon.gridx = 0;
     74             girdBagCon.gridy = 0;
     75             girdBagCon.insets = new Insets(0,10,0,10);
     76             girdBag.setConstraints(jLabel, girdBagCon);
     77             upPanel.add(jLabel);
     78             
     79             colValue = bean.searchAllForNode();
     80             jTable = new JTable(colValue,colName);
     81             jTable.setPreferredScrollableViewportSize(new Dimension(450,300));
     82             listSelectionModel = jTable.getSelectionModel();
     83             listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     84             listSelectionModel.addListSelectionListener(this);
     85             jScrollPane1 = new JScrollPane(jTable);
     86             jScrollPane1.setPreferredSize(new Dimension(450,300));
     87             
     88             girdBagCon = new GridBagConstraints();
     89             girdBagCon.gridx = 0;
     90             girdBagCon.gridy = 1;
     91             girdBagCon.insets = new Insets(0,0,0,0);
     92             girdBag.setConstraints(jScrollPane1, girdBagCon);
     93             upPanel.add(jScrollPane1);
     94         }
     95         catch(Exception e){
     96             e.printStackTrace();
     97         }
     98         this.add(upPanel,BorderLayout.NORTH);
     99     }
    100     /**
    101      * 中部面板的布局
    102      */
    103     public void centerInit() throws Exception
    104     {
    105         jLabel1.setText("姓名");
    106         jLabel1.setFont(new Font("Dialog",0,12));
    107         centerPanel.add(jLabel1);
    108         centerPanel.add(jTextField1);
    109         
    110         jLabel2.setText("原部门");
    111         jLabel2.setFont(new Font("Dialog",0,12));
    112         centerPanel.add(jLabel2);
    113         centerPanel.add(jTextField2);
    114         
    115         jLabel3.setText("新部门");
    116         jLabel3.setFont(new Font("Dialog",0,12));
    117         centerPanel.add(jLabel3);
    118         DeptBean tbean = new DeptBean();
    119         String[] allType = tbean.searchAllForNode();
    120         jComboBox1 = new JComboBox(allType);
    121         centerPanel.add(jComboBox1);
    122         //添加中部面板
    123         this.add(centerPanel,BorderLayout.CENTER);
    124         //设置是否可操作
    125         jTextField1.setEditable(false);
    126         jTextField2.setEditable(false);
    127         jComboBox1.setEditable(false);
    128     }
    129     /**
    130      * 下部面板的布局
    131      */
    132     public void downInit()
    133     {
    134         modifyInfo.setText("调入新部门");
    135         modifyInfo.setFont(new Font("Dialog",0,12));
    136         downPanel.add(modifyInfo);
    137         clearInfo.setText("清空信息");
    138         clearInfo.setFont(new Font("Dialog",0,12));
    139         downPanel.add(clearInfo);
    140         //添加下部面板
    141         this.add(downPanel,BorderLayout.SOUTH);
    142         //设置是否可操作
    143         modifyInfo.setEnabled(false);
    144         clearInfo.setEnabled(true);
    145     }
    146     /**
    147      * 添加事件监听
    148      */
    149     public void addListener() throws Exception
    150     {
    151         modifyInfo.addActionListener(this);
    152         clearInfo.addActionListener(this);
    153         
    154         jComboBox1.addItemListener(this);
    155     }
    156     /**
    157      * 事件处理
    158      */
    159     public void actionPerformed(ActionEvent e)
    160     {
    161         Object obj = e.getSource();
    162         if(obj == modifyInfo){
    163             PersonBean bean = new PersonBean();
    164             oldDeptID = bean.getDeptId(PersonID);
    165             if(oldDeptID == DeptID||oldDeptID.equals(DeptID)){
    166                 JOptionPane.showMessageDialog(null, "请选择不同的部门","错误",JOptionPane.ERROR_MESSAGE);
    167                 oldDeptID = null;
    168                 return;
    169             }else{
    170                 bean.updateDept(PersonID, DeptID);
    171                 HistrjnBean hbean = new HistrjnBean();
    172                 String f1 = ""+hbean.getId();
    173                 String f5 = ""+hbean.getChgTime("人员调动", PersonID);
    174                 java.util.Date now = new java.util.Date();
    175                 DateFormat date = DateFormat.getDateInstance();
    176                 String f6 = ""+date.format(now);
    177                 hbean.add(f1, "人员调动",oldDeptID,DeptID,f5,f6,PersonID);
    178                 //重新生成界面
    179                 Node21Panel dp = new Node21Panel();
    180                 HrMain.splitPane.setRightComponent(dp);
    181             }
    182         }
    183         else if(obj == clearInfo){
    184             setNull();
    185         }
    186         jTable.revalidate();
    187     }
    188     /**
    189      * 将文本框清空
    190      */
    191     void setNull()
    192     {
    193         jTextField1.setText(null);
    194         jTextField2.setText(null);
    195         jTextField1.setEditable(false);
    196         jTextField2.setEditable(false);
    197         
    198         modifyInfo.setEnabled(false);
    199         clearInfo.setEnabled(true);
    200         jComboBox1.setEnabled(false);
    201     }
    202     /**
    203      * 当表格被选中时的操作
    204      */
    205     public void valueChanged(ListSelectionEvent lse)
    206     {
    207         int[] selectedRow = jTable.getSelectedRows();
    208         int[] selectedCol = jTable.getSelectedColumns();
    209         //定义文本框显示的内容
    210         for(int i=0;i<selectedRow.length;i++){
    211             for(int j=0;j<selectedCol.length;j++){
    212                 jTextField1.setText(colValue[selectedRow[i]][1]);//姓名
    213                 jTextField2.setText(colValue[selectedRow[i]][3]);//部门
    214                 PersonID = colValue[selectedRow[i]][0];//工号
    215             }
    216         }
    217         //设置是否可操作
    218         jComboBox1.setEditable(true);
    219         modifyInfo.setEnabled(true);
    220         clearInfo.setEnabled(true);
    221     }
    222     /**
    223      * 下拉菜单事件处理
    224      */
    225     public void itemStateChanged(ItemEvent e)
    226     {
    227         if(e.getStateChange() == ItemEvent.SELECTED){
    228             String tempStr = "" +e.getItem();
    229             int i = tempStr.indexOf("-");
    230             DeptID = tempStr.substring(0,i);
    231         }
    232     }
    233 }
    Node21Panel

    人员调动历史查询主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 import javax.swing.event.*;
      8 import java.util.*;
      9 import java.text.*;
     10 /**
     11  * 
     12  * 调动历史查询
     13  *
     14  */
     15 public class Node22Panel extends JPanel implements ActionListener
     16 {
     17     JPanel upPanel = new JPanel();
     18     JPanel centerPanel = new JPanel();
     19     JPanel downPanel = new JPanel();
     20     
     21     //定义图形界面元素
     22     JLabel jLabel = new JLabel();
     23     JLabel jLabel1 = new JLabel();
     24     JLabel jLabel2 = new JLabel();
     25     JLabel jLabel3 = new JLabel();
     26     
     27     //定义表格
     28     JScrollPane jScrollPane1;
     29     JTable jTable;
     30     ListSelectionModel listSelectionModel = null;
     31     String[] colName = {"流水号","人员姓名","原部门","新部门","变更次数","变更日期"};
     32     String[][] colValue;
     33     
     34     GridBagLayout girdBag = new GridBagLayout();
     35     GridBagConstraints girdBagCon;
     36     
     37     public Node22Panel()
     38     {
     39         this.setLayout(new BorderLayout());
     40         try{
     41             upInit();
     42             centerInit();
     43             downInit();
     44             addListener();
     45         }
     46         catch(Exception e){
     47             e.printStackTrace();
     48         }
     49     }
     50     /**
     51      * 上部面板的布局
     52      */
     53     public void upInit() throws Exception
     54     {
     55         HistrjnBean bean = new HistrjnBean();
     56         upPanel.setLayout(girdBag);
     57         
     58         try{
     59             jLabel.setText("调动历史查询");
     60             jLabel.setFont(new Font("Dialog",0,16));
     61             girdBagCon = new GridBagConstraints();
     62             girdBagCon.gridx = 0;
     63             girdBagCon.gridy = 0;
     64             girdBagCon.insets = new Insets(0,10,0,10);
     65             girdBag.setConstraints(jLabel, girdBagCon);
     66             upPanel.add(jLabel);
     67             
     68             colValue = bean.searchAllForDept();
     69             jTable = new JTable(colValue,colName);
     70             jTable.setPreferredScrollableViewportSize(new Dimension(450,380));
     71             jScrollPane1 = new JScrollPane(jTable);
     72             jScrollPane1.setPreferredSize(new Dimension(450,380));
     73             
     74             girdBagCon = new GridBagConstraints();
     75             girdBagCon.gridx = 0;
     76             girdBagCon.gridy = 1;
     77             girdBagCon.insets = new Insets(0,0,0,0);
     78             girdBag.setConstraints(jScrollPane1, girdBagCon);
     79             upPanel.add(jScrollPane1);
     80         }
     81         catch(Exception e){
     82             e.printStackTrace();
     83         }
     84         this.add(upPanel,BorderLayout.NORTH);
     85     }
     86     /**
     87      * 中部面板的布局
     88      */
     89     public void centerInit() throws Exception
     90     {
     91         
     92     }
     93     /**
     94      * 下部面板的布局
     95      */
     96     public void downInit()
     97     {
     98         
     99     }
    100     /**
    101      * 添加事件监听
    102      */
    103     public void addListener() throws Exception
    104     {
    105         
    106     }
    107     /**
    108      * 事件处理
    109      */
    110     public void actionPerformed(ActionEvent e)
    111     {
    112         
    113     }
    114 }
    Node22Panel

    树中第三节点——人员考核管理模块:

    人员考核主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 import javax.swing.event.*;
      8 import java.util.*;
      9 import java.text.*;
     10 /**
     11  * 
     12  * 人员考核
     13  *
     14  */
     15 public class Node31Panel extends JPanel implements ActionListener,ListSelectionListener,ItemListener
     16 {
     17     JPanel centerPanel = new JPanel();
     18     JPanel upPanel = new JPanel();
     19     JPanel downPanel = new JPanel();
     20     
     21     //定义图形界面元素
     22     JLabel jLabel = new JLabel();
     23     JLabel jLabel1 = new JLabel();
     24     JLabel jLabel2 = new JLabel();
     25     JLabel jLabel3 = new JLabel();
     26     
     27     JTextField jTextField1 = new JTextField(15);
     28     JTextField jTextField2 = new JTextField(15);
     29     String PersonID = null;
     30     String oldInfo = null;
     31     String newInfo = "优秀";
     32     
     33     JComboBox jComboBox1 = null;
     34 
     35     JButton modifyInfo = new JButton();
     36     JButton clearInfo = new JButton();
     37     
     38     //定义表格
     39     JScrollPane jScrollPane1;
     40     JTable jTable;
     41     ListSelectionModel listSelectionModel = null;
     42     String[] colName = {"工号","姓名","性别","部门","薪酬","考核信息"};
     43     String[][] colValue;
     44     
     45     GridBagLayout girdBag = new GridBagLayout();
     46     GridBagConstraints girdBagCon;
     47     
     48     public Node31Panel()
     49     {
     50         this.setLayout(new BorderLayout());
     51         try{
     52             upInit();
     53             centerInit();
     54             downInit();
     55             addListener();
     56         }
     57         catch(Exception e){
     58             e.printStackTrace();
     59         }
     60     }
     61     /**
     62      * 上部面板的布局
     63      */
     64     public void upInit() throws Exception
     65     {
     66         PersonBean bean = new PersonBean();
     67         upPanel.setLayout(girdBag);
     68         
     69         try{
     70             jLabel.setText("人员考核");
     71             jLabel.setFont(new Font("Dialog",0,16));
     72             girdBagCon = new GridBagConstraints();
     73             girdBagCon.gridx = 0;
     74             girdBagCon.gridy = 0;
     75             girdBagCon.insets = new Insets(0,10,0,10);
     76             girdBag.setConstraints(jLabel, girdBagCon);
     77             centerPanel.add(jLabel);
     78             upPanel.add(jLabel);
     79             
     80             colValue = bean.searchAllForNode();
     81             jTable = new JTable(colValue,colName);
     82             jTable.setPreferredScrollableViewportSize(new Dimension(450,300));
     83             listSelectionModel = jTable.getSelectionModel();
     84             listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     85             listSelectionModel.addListSelectionListener(this);
     86             jScrollPane1 = new JScrollPane(jTable);
     87             jScrollPane1.setPreferredSize(new Dimension(450,300));
     88             
     89             girdBagCon = new GridBagConstraints();
     90             girdBagCon.gridx = 0;
     91             girdBagCon.gridy = 1;
     92             girdBagCon.insets = new Insets(0,0,0,0);
     93             girdBag.setConstraints(jScrollPane1, girdBagCon);
     94             upPanel.add(jScrollPane1);
     95         }
     96         catch(Exception e){
     97             e.printStackTrace();
     98         }
     99         this.add(upPanel,BorderLayout.NORTH);
    100     }
    101     /**
    102      * 中部面板的布局
    103      */
    104     public void centerInit() throws Exception
    105     {
    106         jLabel1.setText("姓名");
    107         jLabel1.setFont(new Font("Dialog",0,12));
    108         centerPanel.add(jLabel1);
    109         centerPanel.add(jTextField1);
    110         
    111         jLabel2.setText("上次考核");
    112         jLabel2.setFont(new Font("Dialog",0,12));
    113         centerPanel.add(jLabel2);
    114         centerPanel.add(jTextField2);
    115         
    116         jLabel3.setText("本次考核");
    117         jLabel3.setFont(new Font("Dialog",0,12));
    118         centerPanel.add(jLabel3);
    119         String[] allType = {"优秀","合格","不合格"};
    120         jComboBox1 = new JComboBox(allType);
    121         centerPanel.add(jComboBox1);
    122         //添加中部面板
    123         this.add(centerPanel,BorderLayout.CENTER);
    124         //设置是否可操作
    125         jTextField1.setEditable(false);
    126         jTextField2.setEditable(false);
    127         jComboBox1.setEditable(false);
    128     }
    129     /**
    130      * 下部面板的布局
    131      */
    132     public void downInit()
    133     {
    134         modifyInfo.setText("确定");
    135         modifyInfo.setFont(new Font("Dialog",0,12));
    136         downPanel.add(modifyInfo);
    137         clearInfo.setText("清空");
    138         clearInfo.setFont(new Font("Dialog",0,12));
    139         downPanel.add(clearInfo);
    140         //添加下部面板
    141         this.add(downPanel,BorderLayout.SOUTH);
    142         //设置是否可操作
    143         modifyInfo.setEnabled(false);
    144         clearInfo.setEnabled(true);
    145     }
    146     /**
    147      * 添加事件监听
    148      */
    149     public void addListener() throws Exception
    150     {
    151         modifyInfo.addActionListener(this);
    152         clearInfo.addActionListener(this);
    153         
    154         jComboBox1.addItemListener(this);
    155     }
    156     /**
    157      * 事件处理
    158      */
    159     public void actionPerformed(ActionEvent e)
    160     {
    161         Object obj = e.getSource();
    162         if(obj == modifyInfo){
    163             PersonBean bean = new PersonBean();
    164             oldInfo = jTextField2.getText();
    165             bean.updateAssess(PersonID, newInfo);
    166             HistrjnBean hbean = new HistrjnBean();
    167             String f1 = ""+hbean.getId();
    168             String f5 = ""+hbean.getChgTime("人员考核", PersonID);
    169             java.util.Date now = new java.util.Date();
    170             DateFormat date = DateFormat.getDateInstance();
    171             String f6 = ""+date.format(now);
    172             hbean.add(f1, "人员考核",oldInfo,newInfo,f5,f6,PersonID);
    173             //重新生成界面
    174             Node31Panel dp = new Node31Panel();
    175             HrMain.splitPane.setRightComponent(dp);
    176         }
    177         else if(obj == clearInfo){
    178             setNull();
    179         }
    180         jTable.revalidate();
    181     }
    182     /**
    183      * 将文本框清空
    184      */
    185     void setNull()
    186     {
    187         jTextField1.setText(null);
    188         jTextField2.setText(null);
    189         jTextField1.setEditable(false);
    190         jTextField2.setEditable(false);
    191         
    192         modifyInfo.setEnabled(false);
    193         clearInfo.setEnabled(true);
    194         jComboBox1.setEnabled(false);
    195     }
    196     /**
    197      * 当表格被选中时的操作
    198      */
    199     public void valueChanged(ListSelectionEvent lse)
    200     {
    201         int[] selectedRow = jTable.getSelectedRows();
    202         int[] selectedCol = jTable.getSelectedColumns();
    203         //定义文本框显示的内容
    204         for(int i=0;i<selectedRow.length;i++){
    205             for(int j=0;j<selectedCol.length;j++){
    206                 jTextField1.setText(colValue[selectedRow[i]][1]);//姓名
    207                 jTextField2.setText(colValue[selectedRow[i]][3]);//部门
    208                 PersonID = colValue[selectedRow[i]][0];//工号
    209             }
    210         }
    211         //设置是否可操作
    212         jComboBox1.setEditable(true);
    213         modifyInfo.setEnabled(true);
    214         clearInfo.setEnabled(true);
    215     }
    216     /**
    217      * 下拉菜单事件处理
    218      */
    219     public void itemStateChanged(ItemEvent e)
    220     {
    221         if(e.getStateChange() == ItemEvent.SELECTED){
    222             newInfo = ""+e.getItem();
    223         }
    224     }
    225 }
    Node31Panel

    人员考核历史查询主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 import javax.swing.event.*;
      8 import java.util.*;
      9 import java.text.*;
     10 /**
     11  * 
     12  * 调动历史查询
     13  *
     14  */
     15 public class Node32Panel extends JPanel implements ActionListener
     16 {
     17     JPanel upPanel = new JPanel();
     18     JPanel centerPanel = new JPanel();
     19     JPanel downPanel = new JPanel();
     20     
     21     //定义图形界面元素
     22     JLabel jLabel = new JLabel();
     23     JLabel jLabel1 = new JLabel();
     24     JLabel jLabel2 = new JLabel();
     25     JLabel jLabel3 = new JLabel();
     26     
     27     //定义表格
     28     JScrollPane jScrollPane1;
     29     JTable jTable;
     30     ListSelectionModel listSelectionModel = null;
     31     String[] colName = {"流水号","人员姓名","原部门","新部门","变更次数","变更日期"};
     32     String[][] colValue;
     33     
     34     GridBagLayout girdBag = new GridBagLayout();
     35     GridBagConstraints girdBagCon;
     36     
     37     public Node32Panel()
     38     {
     39         this.setLayout(new BorderLayout());
     40         try{
     41             upInit();
     42             centerInit();
     43             downInit();
     44             addListener();
     45         }
     46         catch(Exception e){
     47             e.printStackTrace();
     48         }
     49     }
     50     /**
     51      * 上部面板的布局
     52      */
     53     public void upInit() throws Exception
     54     {
     55         HistrjnBean bean = new HistrjnBean();
     56         upPanel.setLayout(girdBag);
     57         
     58         try{
     59             jLabel.setText("调动历史查询");
     60             jLabel.setFont(new Font("Dialog",0,16));
     61             girdBagCon = new GridBagConstraints();
     62             girdBagCon.gridx = 0;
     63             girdBagCon.gridy = 0;
     64             girdBagCon.insets = new Insets(0,10,0,10);
     65             girdBag.setConstraints(jLabel, girdBagCon);
     66             upPanel.add(jLabel);
     67             
     68             colValue = bean.searchAllForDept();
     69             jTable = new JTable(colValue,colName);
     70             jTable.setPreferredScrollableViewportSize(new Dimension(450,380));
     71             jScrollPane1 = new JScrollPane(jTable);
     72             jScrollPane1.setPreferredSize(new Dimension(450,380));
     73             
     74             girdBagCon = new GridBagConstraints();
     75             girdBagCon.gridx = 0;
     76             girdBagCon.gridy = 1;
     77             girdBagCon.insets = new Insets(0,0,0,0);
     78             girdBag.setConstraints(jScrollPane1, girdBagCon);
     79             upPanel.add(jScrollPane1);
     80         }
     81         catch(Exception e){
     82             e.printStackTrace();
     83         }
     84         this.add(upPanel,BorderLayout.NORTH);
     85     }
     86     /**
     87      * 中部面板的布局
     88      */
     89     public void centerInit() throws Exception
     90     {
     91         
     92     }
     93     /**
     94      * 下部面板的布局
     95      */
     96     public void downInit()
     97     {
     98         
     99     }
    100     /**
    101      * 添加事件监听
    102      */
    103     public void addListener() throws Exception
    104     {
    105         
    106     }
    107     /**
    108      * 事件处理
    109      */
    110     public void actionPerformed(ActionEvent e)
    111     {
    112         
    113     }
    114 }
    Node32Panel

    树中第四节点——劳资管理模块:

    劳资分配主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 import javax.swing.event.*;
      8 import java.util.*;
      9 import java.text.*;
     10 /**
     11  * 
     12  * 劳资分配
     13  *
     14  */
     15 public class Node41Panel extends JPanel implements ActionListener,ListSelectionListener
     16 {
     17     JPanel centerPanel = new JPanel();
     18     JPanel upPanel = new JPanel();
     19     JPanel downPanel = new JPanel();
     20     
     21     //定义图形界面元素
     22     JLabel jLabel = new JLabel();
     23     JLabel jLabel1 = new JLabel();
     24     JLabel jLabel2 = new JLabel();
     25     JLabel jLabel3 = new JLabel();
     26     
     27     JTextField jTextField1 = new JTextField(15);
     28     JTextField jTextField2 = new JTextField(15);
     29     JTextField jTextField3 = new JTextField(15);
     30     String PersonID = null;
     31     String oldInfo = null;
     32     String newInfo = null;
     33     
     34     JComboBox jComboBox1 = null;
     35 
     36     JButton modifyInfo = new JButton();
     37     JButton clearInfo = new JButton();
     38     
     39     //定义表格
     40     JScrollPane jScrollPane1;
     41     JTable jTable;
     42     ListSelectionModel listSelectionModel = null;
     43     String[] colName = {"工号","姓名","性别","部门","薪酬","考核信息"};
     44     String[][] colValue;
     45     
     46     GridBagLayout girdBag = new GridBagLayout();
     47     GridBagConstraints girdBagCon;
     48     
     49     public Node41Panel()
     50     {
     51         this.setLayout(new BorderLayout());
     52         try{
     53             upInit();
     54             centerInit();
     55             downInit();
     56             addListener();
     57         }
     58         catch(Exception e){
     59             e.printStackTrace();
     60         }
     61     }
     62     /**
     63      * 上部面板的布局
     64      */
     65     public void upInit() throws Exception
     66     {
     67         PersonBean bean = new PersonBean();
     68         upPanel.setLayout(girdBag);
     69         
     70         try{
     71             jLabel.setText("劳资分配");
     72             jLabel.setFont(new Font("Dialog",0,16));
     73             girdBagCon = new GridBagConstraints();
     74             girdBagCon.gridx = 0;
     75             girdBagCon.gridy = 0;
     76             girdBagCon.insets = new Insets(0,10,0,10);
     77             girdBag.setConstraints(jLabel, girdBagCon);
     78             centerPanel.add(jLabel);
     79             upPanel.add(jLabel);
     80             
     81             colValue = bean.searchAllForNode();
     82             jTable = new JTable(colValue,colName);
     83             jTable.setPreferredScrollableViewportSize(new Dimension(450,300));
     84             listSelectionModel = jTable.getSelectionModel();
     85             listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     86             listSelectionModel.addListSelectionListener(this);
     87             jScrollPane1 = new JScrollPane(jTable);
     88             jScrollPane1.setPreferredSize(new Dimension(450,300));
     89             
     90             girdBagCon = new GridBagConstraints();
     91             girdBagCon.gridx = 0;
     92             girdBagCon.gridy = 1;
     93             girdBagCon.insets = new Insets(0,0,0,0);
     94             girdBag.setConstraints(jScrollPane1, girdBagCon);
     95             upPanel.add(jScrollPane1);
     96         }
     97         catch(Exception e){
     98             e.printStackTrace();
     99         }
    100         this.add(upPanel,BorderLayout.NORTH);
    101     }
    102     /**
    103      * 中部面板的布局
    104      */
    105     public void centerInit() throws Exception
    106     {
    107         jLabel1.setText("姓名");
    108         jLabel1.setFont(new Font("Dialog",0,12));
    109         centerPanel.add(jLabel1);
    110         centerPanel.add(jTextField1);
    111         
    112         jLabel2.setText("调整前的工资");
    113         jLabel2.setFont(new Font("Dialog",0,12));
    114         centerPanel.add(jLabel2);
    115         centerPanel.add(jTextField2);
    116         
    117         jLabel3.setText("调整后的工资");
    118         jLabel3.setFont(new Font("Dialog",0,12));
    119         centerPanel.add(jLabel3);
    120         centerPanel.add(jTextField3);
    121         //添加中部面板
    122         this.add(centerPanel,BorderLayout.CENTER);
    123         //设置是否可操作
    124         jTextField1.setEditable(false);
    125         jTextField2.setEditable(false);
    126     }
    127     /**
    128      * 下部面板的布局
    129      */
    130     public void downInit()
    131     {
    132         modifyInfo.setText("确定");
    133         modifyInfo.setFont(new Font("Dialog",0,12));
    134         downPanel.add(modifyInfo);
    135         clearInfo.setText("清空");
    136         clearInfo.setFont(new Font("Dialog",0,12));
    137         downPanel.add(clearInfo);
    138         //添加下部面板
    139         this.add(downPanel,BorderLayout.SOUTH);
    140         //设置是否可操作
    141         modifyInfo.setEnabled(false);
    142         clearInfo.setEnabled(true);
    143     }
    144     /**
    145      * 添加事件监听
    146      */
    147     public void addListener() throws Exception
    148     {
    149         modifyInfo.addActionListener(this);
    150         clearInfo.addActionListener(this);
    151     }
    152     /**
    153      * 事件处理
    154      */
    155     public void actionPerformed(ActionEvent e)
    156     {
    157         Object obj = e.getSource();
    158         if(obj == modifyInfo){
    159             PersonBean bean = new PersonBean();
    160             oldInfo = jTextField2.getText();
    161             newInfo = jTextField3.getText();
    162             bean.updateAssess(PersonID, newInfo);
    163             
    164             HistrjnBean hbean = new HistrjnBean();
    165             String f1 = ""+hbean.getId();
    166             String f5 = ""+hbean.getChgTime("劳资分配", PersonID);
    167             java.util.Date now = new java.util.Date();
    168             DateFormat date = DateFormat.getDateInstance();
    169             String f6 = ""+date.format(now);
    170             hbean.add(f1, "劳资分配",oldInfo,newInfo,f5,f6,PersonID);
    171             //重新生成界面
    172             Node41Panel dp = new Node41Panel();
    173             HrMain.splitPane.setRightComponent(dp);
    174         }
    175         else if(obj == clearInfo){
    176             setNull();
    177         }
    178         jTable.revalidate();
    179     }
    180     /**
    181      * 将文本框清空
    182      */
    183     void setNull()
    184     {
    185         jTextField1.setText(null);
    186         jTextField2.setText(null);
    187         jTextField1.setEditable(false);
    188         jTextField2.setEditable(false);
    189         
    190         modifyInfo.setEnabled(false);
    191         clearInfo.setEnabled(true);
    192     }
    193     /**
    194      * 当表格被选中时的操作
    195      */
    196     public void valueChanged(ListSelectionEvent lse)
    197     {
    198         int[] selectedRow = jTable.getSelectedRows();
    199         int[] selectedCol = jTable.getSelectedColumns();
    200         //定义文本框显示的内容
    201         for(int i=0;i<selectedRow.length;i++){
    202             for(int j=0;j<selectedCol.length;j++){
    203                 jTextField1.setText(colValue[selectedRow[i]][1]);//姓名
    204                 jTextField2.setText(colValue[selectedRow[i]][4]);//工资
    205                 PersonID = colValue[selectedRow[i]][0];//工号
    206             }
    207         }
    208         //设置是否可操作
    209         modifyInfo.setEnabled(true);
    210         clearInfo.setEnabled(true);
    211     }
    212 }
    Node41Panel

    劳资历史查询主要代码:

      1 package PersonSystem;
      2 
      3 import javax.swing.*;
      4 import java.awt.*;
      5 import java.awt.event.*;
      6 import java.net.*;
      7 import javax.swing.event.*;
      8 import java.util.*;
      9 import java.text.*;
     10 /**
     11  * 
     12  * 劳资历史查询
     13  *
     14  */
     15 public class Node42Panel extends JPanel implements ActionListener
     16 {
     17     JPanel upPanel = new JPanel();
     18     JPanel centerPanel = new JPanel();
     19     JPanel downPanel = new JPanel();
     20     
     21     //定义图形界面元素
     22     JLabel jLabel = new JLabel();
     23     JLabel jLabel1 = new JLabel();
     24     JLabel jLabel2 = new JLabel();
     25     JLabel jLabel3 = new JLabel();
     26     
     27     //定义表格
     28     JScrollPane jScrollPane1;
     29     JTable jTable;
     30     ListSelectionModel listSelectionModel = null;
     31     String[] colName = {"流水号","人员姓名","原薪水","新薪水","变更次数","变更日期"};
     32     String[][] colValue;
     33     
     34     GridBagLayout girdBag = new GridBagLayout();
     35     GridBagConstraints girdBagCon;
     36     
     37     public Node42Panel()
     38     {
     39         this.setLayout(new BorderLayout());
     40         try{
     41             upInit();
     42             centerInit();
     43             downInit();
     44             addListener();
     45         }
     46         catch(Exception e){
     47             e.printStackTrace();
     48         }
     49     }
     50     /**
     51      * 上部面板的布局
     52      */
     53     public void upInit() throws Exception
     54     {
     55         HistrjnBean bean = new HistrjnBean();
     56         upPanel.setLayout(girdBag);
     57         
     58         try{
     59             jLabel.setText("劳资历史查询");
     60             jLabel.setFont(new Font("Dialog",0,16));
     61             girdBagCon = new GridBagConstraints();
     62             girdBagCon.gridx = 0;
     63             girdBagCon.gridy = 0;
     64             girdBagCon.insets = new Insets(0,10,0,10);
     65             girdBag.setConstraints(jLabel, girdBagCon);
     66             centerPanel.add(jLabel);
     67             upPanel.add(jLabel);
     68             
     69             colValue = bean.searchAllForSalary();
     70             jTable = new JTable(colValue,colName);
     71             jTable.setPreferredScrollableViewportSize(new Dimension(450,380));
     72             jScrollPane1 = new JScrollPane(jTable);
     73             jScrollPane1.setPreferredSize(new Dimension(450,380));
     74             
     75             girdBagCon = new GridBagConstraints();
     76             girdBagCon.gridx = 0;
     77             girdBagCon.gridy = 1;
     78             girdBagCon.insets = new Insets(0,0,0,0);
     79             girdBag.setConstraints(jScrollPane1, girdBagCon);
     80             upPanel.add(jScrollPane1);
     81         }
     82         catch(Exception e){
     83             e.printStackTrace();
     84         }
     85         this.add(upPanel,BorderLayout.NORTH);
     86     }
     87     /**
     88      * 中部面板的布局
     89      */
     90     public void centerInit() throws Exception
     91     {
     92         
     93     }
     94     /**
     95      * 下部面板的布局
     96      */
     97     public void downInit()
     98     {
     99         
    100     }
    101     /**
    102      * 添加事件监听
    103      */
    104     public void addListener() throws Exception
    105     {
    106         
    107     }
    108     /**
    109      * 事件处理
    110      */
    111     public void actionPerformed(ActionEvent e)
    112     {
    113         
    114     }
    115 }
    Node42Panel
  • 相关阅读:
    int.Parse()及其异常判断
    三个框框的EditBox
    等价类的划分方法与EditorBox问题等价类划分
    初学软件测试
    软件测试方法的分类细谈
    浅谈软件测试之回归测试
    白盒测试——基本路径法
    初探灰盒测试——介于白盒测试与黑盒测试的测试
    对闰年测试的非法输入处理的思考
    等价类测试——进一步完善的Web输入合法验证
  • 原文地址:https://www.cnblogs.com/wxywxy/p/6952269.html
Copyright © 2020-2023  润新知