树中第一节点——基础信息管理模块:
添加人员信息主要代码:
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 Exception233 {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 Exception271 {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 }
修改人员信息主要代码:
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
删除人员信息主要代码:
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 Exception103 {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 Exception143 {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 else158 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
查询人员信息主要代码:
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 Exception102 {103 }104 /**105 * 事件处理106 */107 public void actionPerformed(ActionEvent e)108 {109 }110 }
部门管理界面主要代码:
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 Exception142 {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
树中第二节点——人员调动管理模块:
人员调动主要代码:
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 Exception104 {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 Exception150 {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
人员调动历史查询主要代码:
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 Exception104 {105 106 }107 /**108 * 事件处理109 */110 public void actionPerformed(ActionEvent e)111 {112 113 }114 }
树中第三节点——人员考核管理模块:
人员考核主要代码:
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 Exception105 {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 Exception150 {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
人员考核历史查询主要代码:
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 Exception104 {105 106 }107 /**108 * 事件处理109 */110 public void actionPerformed(ActionEvent e)111 {112 113 }114 }
树中第四节点——劳资管理模块:
劳资分配主要代码:
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 Exception106 {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 Exception148 {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
劳资历史查询主要代码:
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 Exception105 {106 107 }108 /**109 * 事件处理110 */111 public void actionPerformed(ActionEvent e)112 {113 114 }115 }