├── .gitignore
├── .idea
├── inspectionProfiles
│ └── Project_Default.xml
├── libraries
│ └── lib.xml
├── misc.xml
├── modules.xml
└── workspace.xml
├── EPMS.iml
├── README.md
├── screenshots
├── 1.png
├── 10.png
├── 11.png
├── 12.png
├── 2.png
├── 3.png
├── 4.png
├── 5.png
├── 6.png
├── 7.png
├── 8.png
└── 9.png
├── sql
└── epms.sql
└── src
├── dao
├── AccountDao.java
├── DeptDao.java
├── DutyDao.java
├── NativePlaceDao.java
├── PersonDao.java
├── RoleDao.java
└── TimecardDao.java
├── druid.properties
├── images
├── ActualSizeHS.png
├── CalculatorHS.png
├── NavBack.png
├── NavForward.png
├── PrintHS.png
├── RepeatHS.png
├── RestartHS.png
├── TimeCard.png
├── about.png
├── add.png
├── base.png
├── bg.jpg
├── bg2.jpg
├── bookManager.png
├── bookTypeManager.png
├── delete.png
├── edit.png
├── exit.png
├── favicon.png
├── hrm.png
├── java1234.png
├── kontact_contacts.png
├── login.png
├── logo.png
├── me.png
├── modify.png
├── myapp2.ico
├── password.png
├── refresh.png
├── reset.png
├── saveHS.png
├── search.png
├── storage_128px.png
├── timg.png
├── userName.png
└── view.png
├── lib
├── beautyeye_lnf.jar
├── commons-codec-1.14.jar
├── commons-logging-1.2.jar
├── druid-1.0.9.jar
├── mysql-connector-java-5.1.48.jar
├── spring-beans-4.2.4.RELEASE.jar
├── spring-core-4.2.4.RELEASE.jar
├── spring-jdbc-4.2.4.RELEASE.jar
└── spring-tx-4.2.4.RELEASE.jar
├── model
├── TbAccount.java
├── TbDept.java
├── TbDuty.java
├── TbNativePlace.java
├── TbPerson.java
├── TbRole.java
└── TbTimecard.java
├── test
└── Main.java
├── tools
├── IoUtil.java
├── JCalculator.java
├── JDBCUtils.java
├── JNotepad.java
├── PwEncryption.java
├── StringUtil.java
├── Time.java
└── TxtExport.java
└── view
├── AddPersonInfoFrame.java
├── EnrolmentFrame.java
├── LoginFrame.java
├── MainFrame.java
├── PersonInfoFrame.java
└── PersonInfoFrame2.java
/.gitignore:
--------------------------------------------------------------------------------
1 | out
2 | bin
3 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/libraries/lib.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | AccessibilityLintAndroid
10 |
11 |
12 | Android
13 |
14 |
15 | CSS
16 |
17 |
18 | CorrectnessLintAndroid
19 |
20 |
21 | Groovy
22 |
23 |
24 | Invalid elementsCSS
25 |
26 |
27 | JSP
28 |
29 |
30 | Java
31 |
32 |
33 | LintAndroid
34 |
35 |
36 | OtherGroovy
37 |
38 |
39 | Play
40 |
41 |
42 | Spring
43 |
44 |
45 | Spring CoreSpring
46 |
47 |
48 | XMLSpring CoreSpring
49 |
50 |
51 | 声明冗余Java
52 |
53 |
54 | 安全性Java
55 |
56 |
57 | 线程问题Java
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | show
67 | delDeptButton_Do
68 | 删除
69 | del
70 | 导出
71 | JLabel
72 | Jlabel
73 | 搜索
74 | dealExportbtn
75 | 修改
76 |
77 |
78 |
79 |
85 |
86 |
87 | true
88 |
89 | true
90 | true
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 | 1590902776222
306 |
307 |
308 | 1590902776222
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 | 1.8
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 | EPMS
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 | 1.8
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
--------------------------------------------------------------------------------
/EPMS.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 企业人事管理系统EPMS
2 | Java Swing技术的企业人事管理系统,没有使用Maven构建,因此源码包含lib
3 |
4 | ## 项目简介
5 |
6 | 面向企业的对人事信息管理要求,企业人事管理系统应运而生,它能提供对员工、部门、考勤、工资等的信息管理,从而高效的处理数据。方便对企业各类数据进行大数据分析。
7 |
8 | ## 技术栈:
9 |
10 | Swing+Druid+jdbcTemple+jdk1.8
11 |
12 | 数据库: MySQL_5.6.46
13 |
14 | 开发工具:IDEA_2019.1.3
15 |
16 | ## 项目使用说明
17 |
18 | 1. 导入结构和数据:sql/epms.sql
19 |
20 | 2. 解压下载zip重命名EPMS-master文件夹为EPMS,IDEA打开该EPMS项目
21 |
22 | 3. 修改配置数据库连接文件:druid.properties
23 |
24 | 4. 启动文件为src/test/Main类中的main方法
25 |
26 | 管理员 帐号:T00001 密码:123456
27 |
28 |
29 | ## 功能描述
30 |
31 | 
32 |
33 |
34 |
35 | ## 功能分析用例图
36 |
37 | 
38 |
39 |
40 |
41 | ## 数据库设计
42 | 
43 |
44 |
45 |
46 | ## 代码结构
47 |
48 | 
49 |
50 | 
51 |
52 |
53 |
54 | ## 功能实现部分截图
55 |
56 | 
57 |
58 | 
59 |
60 | 
61 |
62 | 
63 |
64 | 
65 |
66 | 
67 |
68 | 
69 |
--------------------------------------------------------------------------------
/screenshots/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/1.png
--------------------------------------------------------------------------------
/screenshots/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/10.png
--------------------------------------------------------------------------------
/screenshots/11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/11.png
--------------------------------------------------------------------------------
/screenshots/12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/12.png
--------------------------------------------------------------------------------
/screenshots/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/2.png
--------------------------------------------------------------------------------
/screenshots/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/3.png
--------------------------------------------------------------------------------
/screenshots/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/4.png
--------------------------------------------------------------------------------
/screenshots/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/5.png
--------------------------------------------------------------------------------
/screenshots/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/6.png
--------------------------------------------------------------------------------
/screenshots/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/7.png
--------------------------------------------------------------------------------
/screenshots/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/8.png
--------------------------------------------------------------------------------
/screenshots/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/screenshots/9.png
--------------------------------------------------------------------------------
/sql/epms.sql:
--------------------------------------------------------------------------------
1 | /*
2 | Navicat Premium Data Transfer
3 |
4 | Source Server : MySQL
5 | Source Server Type : MySQL
6 | Source Server Version : 50646
7 | Source Host : localhost:3306
8 | Source Schema : epms
9 |
10 | Target Server Type : MySQL
11 | Target Server Version : 50646
12 | File Encoding : 65001
13 |
14 | Date: 31/05/2020 13:29:44
15 | */
16 |
17 | SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
18 |
19 | -- ----------------------------
20 | -- Table structure for tb_account
21 | -- ----------------------------
22 |
23 | DROP TABLE IF EXISTS `tb_account`;
24 | CREATE TABLE `tb_account` (
25 | `TIMECARD_ID` int(11) NOT NULL,
26 | `NAME` varchar(10) NOT NULL,
27 | `TYPE` varchar(10) NOT NULL,
28 | `MONEY` varchar(10) NOT NULL,
29 | PRIMARY KEY (`TIMECARD_ID`) USING BTREE
30 | ) ENGINE = InnoDB;
31 |
32 | -- ----------------------------
33 | -- Records of tb_account
34 | -- ----------------------------
35 | INSERT INTO `tb_account` VALUES (1, '加班', '发放', '50');
36 | INSERT INTO `tb_account` VALUES (2, '迟到', '扣除', '10');
37 | INSERT INTO `tb_account` VALUES (3, '早退', '扣除', '10');
38 | INSERT INTO `tb_account` VALUES (4, '值班', '发放', '15');
39 |
40 | -- ----------------------------
41 | -- Table structure for tb_dept
42 | -- ----------------------------
43 | DROP TABLE IF EXISTS `tb_dept`;
44 | CREATE TABLE `tb_dept` (
45 | `ID` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
46 | `NAME` varchar(20) NULL DEFAULT NULL COMMENT '部门名称',
47 | PRIMARY KEY (`ID`) USING BTREE
48 | ) ENGINE = InnoDB AUTO_INCREMENT = 25;
49 |
50 | -- ----------------------------
51 | -- Records of tb_dept
52 | -- ----------------------------
53 | INSERT INTO `tb_dept` VALUES (0, '——');
54 | INSERT INTO `tb_dept` VALUES (1, '财务部');
55 | INSERT INTO `tb_dept` VALUES (2, '人事部');
56 | INSERT INTO `tb_dept` VALUES (3, '办公室');
57 | INSERT INTO `tb_dept` VALUES (4, '销售部');
58 | INSERT INTO `tb_dept` VALUES (5, '测试部');
59 | INSERT INTO `tb_dept` VALUES (21, 'fff');
60 | INSERT INTO `tb_dept` VALUES (22, 'ddd');
61 | INSERT INTO `tb_dept` VALUES (24, '77');
62 |
63 | -- ----------------------------
64 | -- Table structure for tb_duty
65 | -- ----------------------------
66 | DROP TABLE IF EXISTS `tb_duty`;
67 | CREATE TABLE `tb_duty` (
68 | `ID` int(11) NOT NULL,
69 | `NAME` varchar(20) NOT NULL,
70 | PRIMARY KEY (`ID`) USING BTREE
71 | ) ENGINE = InnoDB;
72 |
73 | -- ----------------------------
74 | -- Records of tb_duty
75 | -- ----------------------------
76 | INSERT INTO `tb_duty` VALUES (0, '——');
77 | INSERT INTO `tb_duty` VALUES (1, '经理');
78 | INSERT INTO `tb_duty` VALUES (2, '项目经理');
79 | INSERT INTO `tb_duty` VALUES (3, '部门经理');
80 | INSERT INTO `tb_duty` VALUES (4, '员工');
81 |
82 | -- ----------------------------
83 | -- Table structure for tb_native_place
84 | -- ----------------------------
85 | DROP TABLE IF EXISTS `tb_native_place`;
86 | CREATE TABLE `tb_native_place` (
87 | `ID` int(11) NOT NULL,
88 | `NAME` varchar(20) NOT NULL,
89 | PRIMARY KEY (`ID`) USING BTREE
90 | ) ENGINE = InnoDB;
91 |
92 | -- ----------------------------
93 | -- Records of tb_native_place
94 | -- ----------------------------
95 | INSERT INTO `tb_native_place` VALUES (0, '——');
96 | INSERT INTO `tb_native_place` VALUES (1, '福建省');
97 | INSERT INTO `tb_native_place` VALUES (2, '浙江省');
98 | INSERT INTO `tb_native_place` VALUES (3, '四川省');
99 | INSERT INTO `tb_native_place` VALUES (4, '北京市');
100 | INSERT INTO `tb_native_place` VALUES (5, '江苏省');
101 |
102 | -- ----------------------------
103 | -- Table structure for tb_person
104 | -- ----------------------------
105 | DROP TABLE IF EXISTS `tb_person`;
106 | CREATE TABLE `tb_person` (
107 | `ID` int(11) NOT NULL AUTO_INCREMENT,
108 | `RECORD_NUMBER` varchar(20) NOT NULL,
109 | `DEPT_ID` int(11) NULL DEFAULT 0,
110 | `DUTY_ID` int(3) NULL DEFAULT 0,
111 | `NAME` varchar(10) NULL DEFAULT NULL,
112 | `SEX` char(2) NULL DEFAULT NULL,
113 | `BIRTHDAY` datetime NULL DEFAULT NULL,
114 | `PHOTO` char(27) NULL DEFAULT NULL,
115 | `ID_CARD` varchar(20) NULL DEFAULT NULL,
116 | `MARRIAGED` char(4) NULL DEFAULT NULL,
117 | `NATIVE_PLACE_ID` int(11) NULL DEFAULT 0,
118 | `PARTY_MEMBER` char(2) NULL DEFAULT NULL,
119 | `SCHOOL_AGE` varchar(10) NULL DEFAULT NULL,
120 | `SPECIALTY` varchar(40) NULL DEFAULT NULL,
121 | `FOREIGN_LANGUAGE` varchar(10) NULL DEFAULT NULL,
122 | `GRADE` varchar(10) NULL DEFAULT NULL,
123 | `PASSWORD` varchar(30) NULL DEFAULT 'pkA8u6agfASAta9CR2J2mw==',
124 | `STATE` varchar(6) NULL DEFAULT NULL,
125 | `ROLE_ID` int(10) NULL DEFAULT NULL,
126 | PRIMARY KEY (`ID`) USING BTREE
127 | ) ENGINE = InnoDB AUTO_INCREMENT = 17;
128 |
129 | -- ----------------------------
130 | -- Records of tb_person
131 | -- ----------------------------
132 | INSERT INTO `tb_person` VALUES (1, 'T00001', 1, 1, '陈晓', '男', '1999-07-09 00:00:00', 'T00001.jpg', '652837465760784534', '未婚', 1, '否', '本科', '计算机', '英语', '四级', 'pkA8u6agfASAta9CR2J2mw==', '正常', 1);
133 | INSERT INTO `tb_person` VALUES (4, 'T00002', 1, 2, '张三', '男', '1988-08-08 00:00:00', 'T00002.jpg', '26526', '已婚', 1, '否', '本科', 'fdsfs', 'fdsf', 'fdsf', 'pkA8u6agfASAta9CR2J2mw==', '', 2);
134 | INSERT INTO `tb_person` VALUES (5, 'T00003', 1, 2, 'ccccc', '女', '1998-10-22 00:00:00', 'T00003.jpg', '1384564555555555', '未婚', 2, '是', '本科', '英语', '', '', 'pkA8u6agfASAta9CR2J2mw==', '', 2);
135 | INSERT INTO `tb_person` VALUES (6, 'T00004', 1, 3, 'ddddd', '男', '1999-05-25 00:00:00', NULL, '123555555555', '未婚', 1, '是', '本科', '计算机', '英语', '4级', 'pkA8u6agfASAta9CR2J2mw==', '', 2);
136 | INSERT INTO `tb_person` VALUES (16, 'T11111', 0, 0, 'ccc', NULL, '1111-11-11 00:00:00', NULL, '', NULL, 0, NULL, '', '', '', '', 'pkA8u6agfASAta9CR2J2mw==', '', 0);
137 |
138 | -- ----------------------------
139 | -- Table structure for tb_role
140 | -- ----------------------------
141 | DROP TABLE IF EXISTS `tb_role`;
142 | CREATE TABLE `tb_role` (
143 | `ID` int(4) NOT NULL,
144 | `NAME` varchar(20) NULL DEFAULT NULL,
145 | PRIMARY KEY (`ID`) USING BTREE
146 | ) ENGINE = InnoDB;
147 |
148 | -- ----------------------------
149 | -- Records of tb_role
150 | -- ----------------------------
151 | INSERT INTO `tb_role` VALUES (0, '——');
152 | INSERT INTO `tb_role` VALUES (1, '超级管理员');
153 | INSERT INTO `tb_role` VALUES (2, '普通员工');
154 |
155 | -- ----------------------------
156 | -- Table structure for tb_timecard
157 | -- ----------------------------
158 | DROP TABLE IF EXISTS `tb_timecard`;
159 | CREATE TABLE `tb_timecard` (
160 | `ID` int(11) NOT NULL AUTO_INCREMENT,
161 | `TIMECARD_ID` int(11) NOT NULL,
162 | `PERSON_ID` varchar(20) NOT NULL,
163 | `TIMECARD_DATE` datetime NOT NULL,
164 | `RATIFIER_ID` varchar(20) NOT NULL,
165 | `EXPLAINS` varchar(255) NOT NULL,
166 | PRIMARY KEY (`ID`) USING BTREE
167 | ) ENGINE = InnoDB AUTO_INCREMENT = 7;
168 |
169 | -- ----------------------------
170 | -- Records of tb_timecard
171 | -- ----------------------------
172 | INSERT INTO `tb_timecard` VALUES (1, 1, 'T00002', '2020-05-29 00:00:00', 'T00001', '张三2020.05.29加班说明');
173 | INSERT INTO `tb_timecard` VALUES (2, 1, 'T00002', '2020-05-30 18:53:33', 'T00001', 'fffff');
174 | INSERT INTO `tb_timecard` VALUES (3, 1, 'T00001', '2020-05-30 23:19:20', 'T00001', 'www');
175 | INSERT INTO `tb_timecard` VALUES (4, 1, 'T00001', '2020-05-30 23:19:20', 'T00001', '');
176 | INSERT INTO `tb_timecard` VALUES (5, 1, 'T00001', '2020-05-30 23:22:03', 'T00001', '123');
177 | INSERT INTO `tb_timecard` VALUES (6, 2, 'T00001', '2020-05-30 23:22:03', 'T00001', '123');
178 |
--------------------------------------------------------------------------------
/src/dao/AccountDao.java:
--------------------------------------------------------------------------------
1 | package dao;
2 |
3 | import java.util.List;
4 |
5 | import model.TbAccount;
6 | import model.TbDept;
7 | import model.TbPerson;
8 |
9 | import org.springframework.dao.DataAccessException;
10 | import org.springframework.jdbc.core.BeanPropertyRowMapper;
11 | import org.springframework.jdbc.core.JdbcTemplate;
12 |
13 | import tools.JDBCUtils;
14 |
15 | public class AccountDao {
16 | private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
17 | public static List findAllAccount() {
18 | try {
19 | String sql = "select * from tb_account";
20 | List a = template.query(sql,new BeanPropertyRowMapper(TbAccount.class));
21 | return a;
22 | } catch (DataAccessException e) {
23 | e.printStackTrace();
24 | return null;
25 | }
26 | }
27 | public static String findAccountMoneyById(int i) {
28 | try {
29 | String sql = "select * from tb_account where timecard_id=?";
30 | TbAccount tbAccount = template.queryForObject(sql,new BeanPropertyRowMapper(TbAccount.class),i);
31 | return tbAccount.getMoney();
32 | } catch (DataAccessException e) {
33 | e.printStackTrace();
34 | return null;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/dao/DeptDao.java:
--------------------------------------------------------------------------------
1 | package dao;
2 |
3 | import java.util.List;
4 |
5 | import model.TbDept;
6 |
7 | import org.springframework.dao.DataAccessException;
8 | import org.springframework.jdbc.core.BeanPropertyRowMapper;
9 | import org.springframework.jdbc.core.JdbcTemplate;
10 |
11 | import tools.JDBCUtils;
12 |
13 | public class DeptDao {
14 | private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
15 |
16 | public static TbDept findDeptById(int deptId) {
17 | String sql = "select * from tb_dept where id=?";
18 | TbDept dept = template.queryForObject(sql, new BeanPropertyRowMapper(TbDept.class),deptId);
19 | return dept;
20 |
21 | }
22 |
23 | public static List findAllDept() {
24 | try {
25 | String sql = "select * from tb_dept";
26 | List tbDept = template.query(sql,new BeanPropertyRowMapper(TbDept.class));
27 | return tbDept;
28 | } catch (DataAccessException e) {
29 | e.printStackTrace();
30 | return null;
31 | }
32 | }
33 |
34 | public static int findDeptIdByName(String item) {
35 | String sql = "select * from tb_dept where name=?";
36 | TbDept dept = template.queryForObject(sql, new BeanPropertyRowMapper(TbDept.class),item);
37 | return dept.getId();
38 | }
39 |
40 | public static List findAllDeptExceptZero() {
41 | try {
42 | String sql = "select * from tb_dept where id<>0";
43 | List tbDept = template.query(sql,new BeanPropertyRowMapper(TbDept.class));
44 | return tbDept;
45 | } catch (DataAccessException e) {
46 | e.printStackTrace();
47 | return null;
48 | }
49 | }
50 |
51 | public static TbDept findDeptByName(String name) {
52 | try {
53 | String sql = "select * from tb_dept where name=?";
54 | TbDept dept = template.queryForObject(sql, new BeanPropertyRowMapper(TbDept.class),name);
55 | return dept;
56 | } catch (DataAccessException e) {
57 | e.printStackTrace();
58 | return null;
59 | }
60 | }
61 |
62 | public static void addDept(TbDept d2) {
63 | try {
64 | String sql = "insert into tb_dept(name) values (?)";
65 | template.update(sql,d2.getName());
66 | } catch (DataAccessException e) {
67 | e.printStackTrace();
68 | }
69 |
70 | }
71 |
72 | public static void deleteDeptById(int id) {
73 | try {
74 | String sql = "delete from tb_dept where id=?";
75 | template.update(sql,id);
76 | } catch (DataAccessException e) {
77 | e.printStackTrace();
78 | }
79 |
80 | }
81 |
82 | public static void updateDept(int id, String input) {
83 | try {
84 | String sql = "update tb_dept set name = ? where id = ?";
85 | template.update(sql,input,id);
86 | } catch (Exception e) {
87 | e.printStackTrace();
88 | }
89 |
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/dao/DutyDao.java:
--------------------------------------------------------------------------------
1 | package dao;
2 |
3 | import java.util.List;
4 |
5 | import model.TbDept;
6 | import model.TbDuty;
7 |
8 | import org.springframework.dao.DataAccessException;
9 | import org.springframework.jdbc.core.BeanPropertyRowMapper;
10 | import org.springframework.jdbc.core.JdbcTemplate;
11 |
12 | import tools.JDBCUtils;
13 |
14 | public class DutyDao {
15 | private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
16 |
17 | public static TbDuty findDutyById(int DutyId) {
18 | String sql = "select * from tb_duty where id=?";
19 | TbDuty duty = template.queryForObject(sql, new BeanPropertyRowMapper(TbDuty.class),DutyId);
20 | return duty;
21 |
22 | }
23 |
24 | public static List findAllDuty() {
25 | try {
26 | String sql = "select * from tb_duty";
27 | List tbDuty = template.query(sql,new BeanPropertyRowMapper(TbDuty.class));
28 | return tbDuty;
29 | } catch (DataAccessException e) {
30 | e.printStackTrace();
31 | return null;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/dao/NativePlaceDao.java:
--------------------------------------------------------------------------------
1 | package dao;
2 |
3 | import java.util.List;
4 |
5 | import model.TbDuty;
6 | import model.TbNativePlace;
7 |
8 | import org.springframework.dao.DataAccessException;
9 | import org.springframework.jdbc.core.BeanPropertyRowMapper;
10 | import org.springframework.jdbc.core.JdbcTemplate;
11 |
12 | import tools.JDBCUtils;
13 |
14 | public class NativePlaceDao {
15 | private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
16 |
17 | public static TbNativePlace findNativePlaceById(int nativeId) {
18 | String sql = "select * from tb_native_place where id=?";
19 | TbNativePlace nativePlace = template.queryForObject(sql, new BeanPropertyRowMapper(TbNativePlace.class),nativeId);
20 | return nativePlace;
21 |
22 | }
23 |
24 | public static List findAllNativePlace() {
25 | try {
26 | String sql = "select * from tb_native_place";
27 | List tbNativePlace = template.query(sql,new BeanPropertyRowMapper(TbNativePlace.class));
28 | return tbNativePlace;
29 | } catch (DataAccessException e) {
30 | e.printStackTrace();
31 | return null;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/dao/PersonDao.java:
--------------------------------------------------------------------------------
1 | package dao;
2 |
3 | import java.util.List;
4 |
5 | import model.TbPerson;
6 |
7 | import org.springframework.dao.DataAccessException;
8 | import org.springframework.jdbc.core.BeanPropertyRowMapper;
9 | import org.springframework.jdbc.core.JdbcTemplate;
10 |
11 | import tools.JDBCUtils;
12 |
13 | public class PersonDao {
14 | private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
15 |
16 | public static TbPerson queryRecordByNum(String num) {
17 | try {
18 | String sql = "select * from tb_person where record_number=?";
19 | TbPerson tbRecord = template.queryForObject(sql,new BeanPropertyRowMapper(TbPerson.class),num);
20 | return tbRecord;
21 | } catch (DataAccessException e) {
22 | e.printStackTrace();
23 | return null;
24 | }
25 | }
26 |
27 | public static List findAllPerson() {
28 | try {
29 | String sql = "select * from tb_person";
30 | List tbPerson = template.query(sql,new BeanPropertyRowMapper(TbPerson.class));
31 | return tbPerson;
32 | } catch (DataAccessException e) {
33 | e.printStackTrace();
34 | return null;
35 | }
36 | }
37 |
38 | public static List likePersonByRecordNumber(String recordNumber) {
39 | try {
40 | String sql = "select * from tb_person where record_number like '%' ? '%'";
41 | List tbPerson = template.query(sql,new BeanPropertyRowMapper(TbPerson.class),recordNumber);
42 | return tbPerson;
43 | } catch (DataAccessException e) {
44 | e.printStackTrace();
45 | return null;
46 | }
47 | }
48 |
49 | public static List findPersonByDeptId(int i) {
50 | try {
51 | String sql = "select * from tb_person where dept_id=?";
52 | List tbPerson = template.query(sql,new BeanPropertyRowMapper(TbPerson.class),i);
53 | return tbPerson;
54 | } catch (DataAccessException e) {
55 | e.printStackTrace();
56 | return null;
57 | }
58 | }
59 |
60 | public static TbPerson findPersonByRecordNumber(String recordNumber) {
61 | try {
62 | String sql = "select * from tb_person where record_number=?";
63 | TbPerson tbPerson = template.queryForObject(sql,new BeanPropertyRowMapper(TbPerson.class),recordNumber);
64 | return tbPerson;
65 | } catch (DataAccessException e) {
66 | System.out.println("查找员工为空数据");
67 | e.printStackTrace();
68 | return null;
69 | }
70 | }
71 |
72 | public static void updatePerson(TbPerson person) {
73 | try {
74 | String sql = "update tb_person set dept_id=?,duty_id=?,name=?,sex=?,"
75 | + "birthday=?,photo=?,id_card=?,marriaged=?,native_place_id=?,"
76 | + "party_member=?,school_age=?,specialty=?,foreign_language=?,"
77 | + "grade=?,state=?,role_id=? where record_number=?";
78 | template.update(sql,person.getDeptId(),person.getDutyId(),person.getName(),
79 | person.getSex(),person.getBirthday(),person.getPhoto(),person.getIdCard(),
80 | person.getMarriaged(),person.getNativePlaceId(),person.getPartyMember(),
81 | person.getSchoolAge(),person.getSpecialty(),person.getForeignLanguage(),
82 | person.getGrade(),person.getState(),person.getRoleId(),person.getRecordNumber());
83 | } catch (Exception e) {
84 | e.printStackTrace();
85 | }
86 | }
87 |
88 | public static void addPerson(TbPerson person) {
89 | try {
90 | String sql = "insert into tb_person(record_number,dept_id,duty_id,name,sex,"
91 | + "birthday,photo,id_card,marriaged,native_place_id,"
92 | + "party_member,school_age,specialty,foreign_language,"
93 | + "grade,state,role_id) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
94 | template.update(sql,person.getRecordNumber(),person.getDeptId(),person.getDutyId(),
95 | person.getName(),person.getSex(),person.getBirthday(),person.getPhoto(),
96 | person.getIdCard(),person.getMarriaged(),person.getNativePlaceId(),
97 | person.getPartyMember(),person.getSchoolAge(),person.getSpecialty(),
98 | person.getForeignLanguage(),person.getGrade(),person.getState(),person.getRoleId());
99 | } catch (DataAccessException e) {
100 | e.printStackTrace();
101 | }
102 |
103 | }
104 |
105 | public static void deletePersonByrecordNumber(String recordNumber) {
106 | try {
107 | String sql = "delete from tb_person where record_number=?";
108 | template.update(sql,recordNumber);
109 | } catch (DataAccessException e) {
110 | e.printStackTrace();
111 | }
112 | }
113 |
114 | public static TbPerson login(TbPerson person) {
115 | try {
116 | String sql = "select * from tb_person where record_number=? and password=?";
117 | TbPerson tbPerson = template.queryForObject(sql,new BeanPropertyRowMapper(TbPerson.class),person.getRecordNumber(),person.getPassword());
118 | return tbPerson;
119 | } catch (DataAccessException e) {
120 | System.out.println("空结果数据访问异常");
121 | e.printStackTrace();
122 | return null;
123 | }
124 | }
125 |
126 | public static void updatePersonPassword(TbPerson person) {
127 | try {
128 | String sql = "update tb_person set password = ? where record_number= ?";
129 | template.update(sql,person.getPassword(),person.getRecordNumber());
130 | } catch (Exception e) {
131 | e.printStackTrace();
132 | }
133 | }
134 |
135 | public static List likePersonByName(String name) {
136 | try {
137 | String sql = "select * from tb_person where name like '%' ? '%'";
138 | List tbPerson = template.query(sql,new BeanPropertyRowMapper(TbPerson.class),name);
139 | return tbPerson;
140 | } catch (DataAccessException e) {
141 | e.printStackTrace();
142 | return null;
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/src/dao/RoleDao.java:
--------------------------------------------------------------------------------
1 | package dao;
2 |
3 | import java.util.List;
4 |
5 | import model.TbDept;
6 | import model.TbRole;
7 |
8 | import org.springframework.dao.DataAccessException;
9 | import org.springframework.jdbc.core.BeanPropertyRowMapper;
10 | import org.springframework.jdbc.core.JdbcTemplate;
11 |
12 | import tools.JDBCUtils;
13 |
14 | public class RoleDao {
15 | private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
16 |
17 | public static TbRole findRoleById(int roleId) {
18 | String sql = "select * from tb_role where id=?";
19 | TbRole role = template.queryForObject(sql, new BeanPropertyRowMapper(TbRole.class),roleId);
20 | return role;
21 |
22 | }
23 |
24 | public static List findAllRole() {
25 | try {
26 | String sql = "select * from tb_role";
27 | List tbRole = template.query(sql,new BeanPropertyRowMapper(TbRole.class));
28 | return tbRole;
29 | } catch (DataAccessException e) {
30 | e.printStackTrace();
31 | return null;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/dao/TimecardDao.java:
--------------------------------------------------------------------------------
1 | package dao;
2 |
3 | import model.TbPerson;
4 | import model.TbTimecard;
5 |
6 | import org.springframework.dao.DataAccessException;
7 | import org.springframework.jdbc.core.JdbcTemplate;
8 |
9 | import tools.JDBCUtils;
10 |
11 | public class TimecardDao {
12 | private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
13 |
14 | public static void addTimecard(TbTimecard tc) {
15 | try {
16 | String sql = "insert into tb_timecard(timecard_id,person_id,timecard_date,ratifier_id,explains) values(?,?,?,?,?)";
17 | template.update(sql,tc.getTimecardId(),tc.getPersonId(),tc.getTimecardDate(),tc.getRatifierId(),tc.getExplains());
18 | } catch (DataAccessException e) {
19 | e.printStackTrace();
20 | }
21 |
22 | }
23 |
24 | public static int findTimecardCountByPersonId(int tcid,String recordNumber) {
25 | try {
26 | String sql = "select count(*) from tb_timecard where timecard_id = ? and person_id = ?";
27 | int a = template.queryForObject(sql, Integer.class,tcid,recordNumber);
28 | return a;
29 | } catch (DataAccessException e) {
30 | e.printStackTrace();
31 | return 0;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/druid.properties:
--------------------------------------------------------------------------------
1 | driverClassName=com.mysql.jdbc.Driver
2 | url=jdbc:mysql://127.0.0.1:3306/epms
3 | username=root
4 | password=root
5 | initialSize=5
6 | maxActive=10
7 | maxWait=3000
--------------------------------------------------------------------------------
/src/images/ActualSizeHS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/ActualSizeHS.png
--------------------------------------------------------------------------------
/src/images/CalculatorHS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/CalculatorHS.png
--------------------------------------------------------------------------------
/src/images/NavBack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/NavBack.png
--------------------------------------------------------------------------------
/src/images/NavForward.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/NavForward.png
--------------------------------------------------------------------------------
/src/images/PrintHS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/PrintHS.png
--------------------------------------------------------------------------------
/src/images/RepeatHS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/RepeatHS.png
--------------------------------------------------------------------------------
/src/images/RestartHS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/RestartHS.png
--------------------------------------------------------------------------------
/src/images/TimeCard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/TimeCard.png
--------------------------------------------------------------------------------
/src/images/about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/about.png
--------------------------------------------------------------------------------
/src/images/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/add.png
--------------------------------------------------------------------------------
/src/images/base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/base.png
--------------------------------------------------------------------------------
/src/images/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/bg.jpg
--------------------------------------------------------------------------------
/src/images/bg2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/bg2.jpg
--------------------------------------------------------------------------------
/src/images/bookManager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/bookManager.png
--------------------------------------------------------------------------------
/src/images/bookTypeManager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/bookTypeManager.png
--------------------------------------------------------------------------------
/src/images/delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/delete.png
--------------------------------------------------------------------------------
/src/images/edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/edit.png
--------------------------------------------------------------------------------
/src/images/exit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/exit.png
--------------------------------------------------------------------------------
/src/images/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/favicon.png
--------------------------------------------------------------------------------
/src/images/hrm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/hrm.png
--------------------------------------------------------------------------------
/src/images/java1234.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/java1234.png
--------------------------------------------------------------------------------
/src/images/kontact_contacts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/kontact_contacts.png
--------------------------------------------------------------------------------
/src/images/login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/login.png
--------------------------------------------------------------------------------
/src/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/logo.png
--------------------------------------------------------------------------------
/src/images/me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/me.png
--------------------------------------------------------------------------------
/src/images/modify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/modify.png
--------------------------------------------------------------------------------
/src/images/myapp2.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/myapp2.ico
--------------------------------------------------------------------------------
/src/images/password.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/password.png
--------------------------------------------------------------------------------
/src/images/refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/refresh.png
--------------------------------------------------------------------------------
/src/images/reset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/reset.png
--------------------------------------------------------------------------------
/src/images/saveHS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/saveHS.png
--------------------------------------------------------------------------------
/src/images/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/search.png
--------------------------------------------------------------------------------
/src/images/storage_128px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/storage_128px.png
--------------------------------------------------------------------------------
/src/images/timg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/timg.png
--------------------------------------------------------------------------------
/src/images/userName.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/userName.png
--------------------------------------------------------------------------------
/src/images/view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/images/view.png
--------------------------------------------------------------------------------
/src/lib/beautyeye_lnf.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/lib/beautyeye_lnf.jar
--------------------------------------------------------------------------------
/src/lib/commons-codec-1.14.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/lib/commons-codec-1.14.jar
--------------------------------------------------------------------------------
/src/lib/commons-logging-1.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/lib/commons-logging-1.2.jar
--------------------------------------------------------------------------------
/src/lib/druid-1.0.9.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/lib/druid-1.0.9.jar
--------------------------------------------------------------------------------
/src/lib/mysql-connector-java-5.1.48.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/lib/mysql-connector-java-5.1.48.jar
--------------------------------------------------------------------------------
/src/lib/spring-beans-4.2.4.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/lib/spring-beans-4.2.4.RELEASE.jar
--------------------------------------------------------------------------------
/src/lib/spring-core-4.2.4.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/lib/spring-core-4.2.4.RELEASE.jar
--------------------------------------------------------------------------------
/src/lib/spring-jdbc-4.2.4.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/lib/spring-jdbc-4.2.4.RELEASE.jar
--------------------------------------------------------------------------------
/src/lib/spring-tx-4.2.4.RELEASE.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rawchen/epms/HEAD/src/lib/spring-tx-4.2.4.RELEASE.jar
--------------------------------------------------------------------------------
/src/model/TbAccount.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | public class TbAccount {
4 | private int timecardId;
5 | private String name;
6 | private String type;
7 | private String money;
8 | public int getTimecardId() {
9 | return timecardId;
10 | }
11 | public void setTimecardId(int timecardId) {
12 | this.timecardId = timecardId;
13 | }
14 | public String getName() {
15 | return name;
16 | }
17 | public void setName(String name) {
18 | this.name = name;
19 | }
20 | public String getType() {
21 | return type;
22 | }
23 | public void setType(String type) {
24 | this.type = type;
25 | }
26 | public String getMoney() {
27 | return money;
28 | }
29 | public void setMoney(String money) {
30 | this.money = money;
31 | }
32 | @Override
33 | public String toString() {
34 | return "TbAccount [timecardId=" + timecardId + ", name=" + name
35 | + ", type=" + type + ", money=" + money + "]";
36 | }
37 |
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/model/TbDept.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | public class TbDept {
4 |
5 | private int id;
6 |
7 | private String name;
8 |
9 | public TbDept() {
10 |
11 | }
12 |
13 | public int getId() {
14 | return this.id;
15 | }
16 |
17 | public void setId(int id) {
18 | this.id = id;
19 | }
20 |
21 | public String getName() {
22 | return this.name;
23 | }
24 |
25 | public void setName(String name) {
26 | this.name = name;
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/src/model/TbDuty.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | public class TbDuty {
4 |
5 | private int id;
6 | private String name;
7 |
8 | public TbDuty() {
9 | }
10 |
11 |
12 | public int getId() {
13 | return this.id;
14 | }
15 |
16 | public void setId(int id) {
17 | this.id = id;
18 | }
19 |
20 | public String getName() {
21 | return this.name;
22 | }
23 |
24 | public void setName(String name) {
25 | this.name = name;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/model/TbNativePlace.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | public class TbNativePlace {
4 |
5 | // Fields
6 |
7 | private Integer id;
8 |
9 | private String name;
10 |
11 | // Constructors
12 |
13 | public TbNativePlace() {
14 | }
15 |
16 | // Property accessors
17 |
18 | public Integer getId() {
19 | return this.id;
20 | }
21 |
22 | public void setId(Integer id) {
23 | this.id = id;
24 | }
25 |
26 | public String getName() {
27 | return this.name;
28 | }
29 |
30 | public void setName(String name) {
31 | this.name = name;
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/src/model/TbPerson.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | import java.util.Date;
4 |
5 | public class TbPerson {
6 |
7 | // Fields
8 |
9 | private int id;
10 |
11 | private String recordNumber;
12 |
13 | private int nativePlaceId;
14 |
15 | private int deptId;
16 |
17 | private int dutyId;
18 |
19 | private String name;
20 |
21 | private String sex;
22 |
23 | private Date birthday;
24 |
25 | private String photo;
26 |
27 | private String idCard;
28 |
29 | private String marriaged;
30 |
31 | private String partyMember;
32 |
33 | private String schoolAge;
34 |
35 | private String specialty;
36 |
37 | private String foreignLanguage;
38 |
39 | private String grade;
40 |
41 | private String password;
42 |
43 | private String state;
44 |
45 | private int roleId;
46 |
47 |
48 |
49 | public TbPerson(String recordNumber, String password) {
50 | super();
51 | this.recordNumber = recordNumber;
52 | this.password = password;
53 | }
54 |
55 | public TbPerson() {
56 | }
57 |
58 | public int getDutyId() {
59 | return dutyId;
60 | }
61 |
62 | public void setDutyId(int dutyId) {
63 | this.dutyId = dutyId;
64 | }
65 |
66 | public int getDeptId() {
67 | return deptId;
68 | }
69 |
70 | public void setDeptId(int deptId) {
71 | this.deptId = deptId;
72 | }
73 |
74 | public int getId() {
75 | return id;
76 | }
77 |
78 | public void setId(int id) {
79 | this.id = id;
80 | }
81 |
82 | public String getRecordNumber() {
83 | return recordNumber;
84 | }
85 |
86 | public void setRecordNumber(String recordNumber) {
87 | this.recordNumber = recordNumber;
88 | }
89 |
90 | public int getNativePlaceId() {
91 | return nativePlaceId;
92 | }
93 |
94 | public void setNativePlaceId(int nativePlaceId) {
95 | this.nativePlaceId = nativePlaceId;
96 | }
97 |
98 | public String getName() {
99 | return name;
100 | }
101 |
102 | public void setName(String name) {
103 | this.name = name;
104 | }
105 |
106 | public String getSex() {
107 | return sex;
108 | }
109 |
110 | public void setSex(String sex) {
111 | this.sex = sex;
112 | }
113 |
114 | public Date getBirthday() {
115 | return birthday;
116 | }
117 |
118 | public void setBirthday(Date birthday) {
119 | this.birthday = birthday;
120 | }
121 |
122 | public String getPhoto() {
123 | return photo;
124 | }
125 |
126 | public void setPhoto(String photo) {
127 | this.photo = photo;
128 | }
129 |
130 | public String getIdCard() {
131 | return idCard;
132 | }
133 |
134 | public void setIdCard(String idCard) {
135 | this.idCard = idCard;
136 | }
137 |
138 | public String getMarriaged() {
139 | return marriaged;
140 | }
141 |
142 | public void setMarriaged(String marriaged) {
143 | this.marriaged = marriaged;
144 | }
145 |
146 | public String getPartyMember() {
147 | return partyMember;
148 | }
149 |
150 | public void setPartyMember(String partyMember) {
151 | this.partyMember = partyMember;
152 | }
153 |
154 | public String getSchoolAge() {
155 | return schoolAge;
156 | }
157 |
158 | public void setSchoolAge(String schoolAge) {
159 | this.schoolAge = schoolAge;
160 | }
161 |
162 | public String getSpecialty() {
163 | return specialty;
164 | }
165 |
166 | public void setSpecialty(String specialty) {
167 | this.specialty = specialty;
168 | }
169 |
170 | public String getForeignLanguage() {
171 | return foreignLanguage;
172 | }
173 |
174 | public void setForeignLanguage(String foreignLanguage) {
175 | this.foreignLanguage = foreignLanguage;
176 | }
177 |
178 | public String getGrade() {
179 | return grade;
180 | }
181 |
182 | public void setGrade(String grade) {
183 | this.grade = grade;
184 | }
185 |
186 | public String getPassword() {
187 | return password;
188 | }
189 |
190 | public void setPassword(String password) {
191 | this.password = password;
192 | }
193 |
194 | public String getState() {
195 | return state;
196 | }
197 |
198 | public void setState(String state) {
199 | this.state = state;
200 | }
201 |
202 | public int getRoleId() {
203 | return roleId;
204 | }
205 |
206 | public void setRoleId(int roleId) {
207 | this.roleId = roleId;
208 | }
209 |
210 | @Override
211 | public String toString() {
212 | return "TbPerson [id=" + id + ", recordNumber=" + recordNumber
213 | + ", nativePlaceId=" + nativePlaceId + ", deptId=" + deptId
214 | + ", dutyId=" + dutyId + ", name=" + name + ", sex=" + sex
215 | + ", birthday=" + birthday + ", photo=" + photo + ", idCard="
216 | + idCard + ", marriaged=" + marriaged + ", partyMember="
217 | + partyMember + ", schoolAge=" + schoolAge + ", specialty="
218 | + specialty + ", foreignLanguage=" + foreignLanguage
219 | + ", grade=" + grade + ", password=" + password + ", state="
220 | + state + ", roleId=" + roleId + "]";
221 | }
222 |
223 |
224 |
225 | }
--------------------------------------------------------------------------------
/src/model/TbRole.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | public class TbRole {
4 |
5 | private int id;
6 |
7 | private String name;
8 |
9 | public TbRole() {
10 |
11 | }
12 |
13 | public int getId() {
14 | return this.id;
15 | }
16 |
17 | public void setId(int id) {
18 | this.id = id;
19 | }
20 |
21 | public String getName() {
22 | return this.name;
23 | }
24 |
25 | public void setName(String name) {
26 | this.name = name;
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/src/model/TbTimecard.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | import java.util.Date;
4 |
5 | public class TbTimecard {
6 | private int timecardId;
7 | private String personId;
8 | private Date timecardDate;
9 | private String ratifierId;
10 | private String explains;
11 |
12 | public int getTimecardId() {
13 | return timecardId;
14 | }
15 | public void setTimecardId(int timecardId) {
16 | this.timecardId = timecardId;
17 | }
18 | public String getPersonId() {
19 | return personId;
20 | }
21 | public void setPersonId(String personId) {
22 | this.personId = personId;
23 | }
24 | public Date getTimecardDate() {
25 | return timecardDate;
26 | }
27 | public void setTimecardDate(Date timecardDate) {
28 | this.timecardDate = timecardDate;
29 | }
30 | public String getRatifierId() {
31 | return ratifierId;
32 | }
33 | public void setRatifierId(String ratifierId) {
34 | this.ratifierId = ratifierId;
35 | }
36 | public String getExplains() {
37 | return explains;
38 | }
39 | public void setExplains(String explains) {
40 | this.explains = explains;
41 | }
42 |
43 | public TbTimecard(int timecardId, String personId,
44 | Date timecardDate, String ratifierId, String explains) {
45 | super();
46 | this.timecardId = timecardId;
47 | this.personId = personId;
48 | this.timecardDate = timecardDate;
49 | this.ratifierId = ratifierId;
50 | this.explains = explains;
51 | }
52 | @Override
53 | public String toString() {
54 | return "TbTimecard [timecardId=" + timecardId
55 | + ", personId=" + personId + ", timecardDate=" + timecardDate
56 | + ", ratifierId=" + ratifierId + ", explains=" + explains + "]";
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/Main.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;
4 | import view.LoginFrame;
5 |
6 | import javax.swing.*;
7 | import java.awt.*;
8 |
9 | public class Main {
10 | public static void main(String[] args) {
11 | try{
12 | BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.generalNoTranslucencyShadow;
13 | org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
14 | }catch(Exception e){}
15 | UIManager.put("RootPane.setupButtonVisible", false);
16 |
17 | /** UIManager中UI字体相关的key */
18 | String[] DEFAULT_FONT = new String[]{
19 | "Table.font","TableHeader.font","CheckBox.font","Tree.font","Viewport.font","ProgressBar.font"
20 | ,"RadioButtonMenuItem.font"
21 | ,"ToolBar.font"
22 | ,"ColorChooser.font"
23 | ,"ToggleButton.font"
24 | ,"Panel.font"
25 | ,"TextArea.font"
26 | ,"Menu.font"
27 | ,"TableHeader.font"
28 | ,"TextField.font"
29 | ,"OptionPane.font"
30 | ,"MenuBar.font"
31 | ,"Button.font"
32 | ,"Label.font"
33 | ,"PasswordField.font"
34 | ,"ScrollPane.font"
35 | ,"MenuItem.font"
36 | ,"ToolTip.font"
37 | ,"List.font"
38 | ,"EditorPane.font"
39 | ,"Table.font"
40 | ,"TabbedPane.font"
41 | ,"RadioButton.font"
42 | ,"CheckBoxMenuItem.font"
43 | ,"TextPane.font"
44 | ,"PopupMenu.font"
45 | ,"TitledBorder.font"
46 | ,"ComboBox.font"
47 | };
48 | for (int i = 0; i < DEFAULT_FONT.length; i++){
49 | UIManager.put(DEFAULT_FONT[i],new Font("Dialog", Font.PLAIN,15));
50 | }
51 |
52 | LoginFrame frame = new LoginFrame();
53 | frame.setVisible(true);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/tools/IoUtil.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import java.io.File;
4 | import java.io.FileWriter;
5 | import java.io.IOException;
6 |
7 | import javax.swing.JTable;
8 | import javax.swing.table.DefaultTableModel;
9 | import javax.swing.table.TableModel;
10 |
11 | /**
12 | * IO工具类
13 | * @author 22219
14 | *
15 | */
16 | public class IoUtil {
17 |
18 | public static void exportTable(JTable table, File file) throws IOException {
19 | TableModel model = table.getModel();// 得到Jtable的Model
20 | FileWriter out = new FileWriter(file);
21 |
22 | for (int i = 0; i < model.getColumnCount(); i++) {
23 | out.write(model.getColumnName(i) + "\t");
24 | }
25 | out.write("\n");
26 | for (int i = 0; i < model.getRowCount(); i++) {
27 | for (int j = 0; j < model.getColumnCount(); j++) {
28 | if(model.getValueAt(i,j).toString()!=null&&!model.getValueAt(i,j).toString().equals(""))
29 | {
30 | out.write(model.getValueAt(i,j).toString()+"\t");
31 | }else{
32 | out.write("null"+"\t");
33 | }
34 | // out.write(model.getValueAt(i, j).toString() + "\t");
35 | }
36 | out.write("\n");
37 | }
38 | out.close();
39 | System.out.println(file);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/tools/JCalculator.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import java.awt.*;
4 | import java.awt.event.*;
5 | import javax.swing.*;
6 |
7 | public class JCalculator extends JFrame implements ActionListener {
8 | int i;
9 | private final String[] str = { "7", "8", "9", "/", "4", "5", "6", "*", "1",
10 | "2", "3", "-", ".", "0", "=", "+" };
11 | JButton[] buttons = new JButton[str.length];
12 | JButton reset = new JButton("CE");
13 | JTextField display = new JTextField("0");
14 |
15 | public JCalculator() {
16 | super("Calculator");
17 |
18 | JPanel panel1 = new JPanel(new GridLayout(4, 4));
19 |
20 | for (i = 0; i < str.length; i++) {
21 | buttons[i] = new JButton(str[i]);
22 | panel1.add(buttons[i]);
23 | }
24 | JPanel panel2 = new JPanel(new BorderLayout());
25 |
26 | panel2.add("Center", display);
27 | panel2.add("East", reset);
28 |
29 | getContentPane().setLayout(new BorderLayout());
30 | getContentPane().add("North", panel2);
31 | getContentPane().add("Center", panel1);
32 |
33 | for (i = 0; i < str.length; i++)
34 | buttons[i].addActionListener(this);
35 |
36 | reset.addActionListener(this);
37 |
38 | display.addActionListener(this);
39 |
40 | setDefaultCloseOperation(DISPOSE_ON_CLOSE);
41 |
42 | setLocationRelativeTo(null);
43 |
44 | setVisible(true);
45 |
46 | pack();
47 | }
48 |
49 | public void actionPerformed(ActionEvent e) {
50 | Object target = e.getSource();
51 | String label = e.getActionCommand();
52 | if (target == reset)
53 | handleReset();
54 | else if ("0123456789.".indexOf(label) > 0)
55 | handleNumber(label);
56 | else
57 | handleOperator(label);
58 | }
59 |
60 | boolean isFirstDigit = true;
61 |
62 | public void handleNumber(String key) {
63 | if (isFirstDigit)
64 | display.setText(key);
65 | else if ((key.equals(".")) && (display.getText().indexOf(".") < 0))
66 | display.setText(display.getText() + ".");
67 | else if (!key.equals("."))
68 | display.setText(display.getText() + key);
69 | isFirstDigit = false;
70 | }
71 |
72 | public void handleReset() {
73 | display.setText("0");
74 | isFirstDigit = true;
75 | operator = "=";
76 | }
77 |
78 | double number = 0.0;
79 | String operator = "=";
80 |
81 | public void handleOperator(String key) {
82 | if (operator.equals("+"))
83 | number += Double.valueOf(display.getText());
84 | else if (operator.equals("-"))
85 | number -= Double.valueOf(display.getText());
86 | else if (operator.equals("*"))
87 | number *= Double.valueOf(display.getText());
88 | else if (operator.equals("/"))
89 | number /= Double.valueOf(display.getText());
90 | else if (operator.equals("="))
91 | number = Double.valueOf(display.getText());
92 | display.setText(String.valueOf(number));
93 | operator = key;
94 | isFirstDigit = true;
95 | }
96 |
97 | }
--------------------------------------------------------------------------------
/src/tools/JDBCUtils.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import com.alibaba.druid.pool.DruidDataSourceFactory;
4 |
5 | import javax.sql.DataSource;
6 | import java.sql.Connection;
7 | import java.sql.ResultSet;
8 | import java.sql.SQLException;
9 | import java.sql.Statement;
10 | import java.util.Properties;
11 |
12 | /**
13 | * Druid连接池工具类,将来dao层调用
14 | */
15 | public class JDBCUtils {
16 | private static DataSource dataSource; //定义成员变量DataSource
17 | static {
18 | try {
19 | //加载配置文件
20 | Properties properties = new Properties();
21 | properties.load(JDBCUtils.class.getClassLoader().getResourceAsStream("druid.properties"));
22 |
23 | //获取DataSource
24 | dataSource = DruidDataSourceFactory.createDataSource(properties);
25 | } catch (Exception e) {
26 | e.printStackTrace();
27 | }
28 | }
29 |
30 | /**
31 | * 获取连接
32 | */
33 | public static Connection getConnection() throws SQLException {
34 | return dataSource.getConnection();
35 | }
36 |
37 | /**
38 | * 释放资源
39 | */
40 | public static void close(Statement statement,Connection connection) {
41 | close(null,statement,connection);
42 | }
43 |
44 | public static void close(ResultSet resultSet, Statement statement, Connection connection) {
45 | if (resultSet != null) {
46 | try {
47 | resultSet.close();
48 | } catch (SQLException e) {
49 | e.printStackTrace();
50 | }
51 | }
52 |
53 | if (statement != null) {
54 | try {
55 | statement.close();
56 | } catch (SQLException e) {
57 | e.printStackTrace();
58 | }
59 | }
60 |
61 | if (connection != null) {
62 | try {
63 | connection.close();//归还连接
64 | }catch (SQLException e) {
65 | e.printStackTrace();
66 | }
67 | }
68 | }
69 |
70 | /**
71 | * 获取连接池方法
72 | */
73 | public static DataSource getDataSource() {
74 | return dataSource;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/tools/JNotepad.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import java.awt.*;
4 | import javax.swing.*;
5 | import javax.swing.filechooser.FileNameExtensionFilter;
6 | import javax.swing.undo.UndoManager;
7 | import java.awt.event.*;
8 | import java.io.*;
9 |
10 | public class JNotepad extends JFrame implements ActionListener {
11 |
12 | JMenuBar menubar = new JMenuBar();
13 | JMenu file = new JMenu("文件(F)");
14 | JMenu edit = new JMenu("编辑(E)");
15 | JMenu format = new JMenu("格式(O)");
16 | JMenu help = new JMenu("帮助(H)");
17 | JMenuItem create = new JMenuItem("新建");
18 | JMenuItem open = new JMenuItem("打开...");
19 | JMenuItem save = new JMenuItem("保存");
20 | JMenuItem saveAs = new JMenuItem("另存为...");
21 | JMenuItem exit = new JMenuItem("退出");
22 | JMenuItem undo = new JMenuItem("撤销");
23 | JMenuItem cut = new JMenuItem("剪切");
24 | JMenuItem copy = new JMenuItem("复制");
25 | JMenuItem paste = new JMenuItem("粘贴");
26 | JMenuItem findRep = new JMenuItem("查找替换");
27 | JMenuItem selectAll = new JMenuItem("全选");
28 | JMenuItem font = new JMenuItem("字体");
29 | JMenuItem about = new JMenuItem("关于");
30 | JMenuItem cut2 = new JMenuItem("剪切(X)");
31 |
32 | JMenuItem copy2 = new JMenuItem("复制(C)");
33 | JMenuItem paste2 = new JMenuItem("粘贴(V)");
34 | JMenuItem selectAll2 = new JMenuItem("全选(A)");
35 | public static JTextArea textarea = new JTextArea();
36 | UndoManager um = new UndoManager();
37 | JScrollPane scroll = new JScrollPane(textarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
38 | JPopupMenu popup = new JPopupMenu();
39 | String pathSelect;
40 |
41 | // 获取屏幕尺寸
42 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
43 |
44 | public JNotepad() {
45 |
46 | // 此处定义键盘快捷键
47 | // MenuBar
48 | file.setMnemonic(KeyEvent.VK_F);
49 | edit.setMnemonic(KeyEvent.VK_E);
50 | format.setMnemonic(KeyEvent.VK_O);
51 | help.setMnemonic(KeyEvent.VK_H);
52 | // MenuItem
53 | create.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
54 | open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
55 | save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
56 | undo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
57 | cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
58 | copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
59 | paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
60 | findRep.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK));
61 | selectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
62 |
63 | // 事件监听者
64 | save.addActionListener(this);
65 | create.addActionListener(this);
66 | open.addActionListener(this);
67 | saveAs.addActionListener(this);
68 | exit.addActionListener(this);
69 | undo.addActionListener(this);
70 | cut.addActionListener(this);
71 | copy.addActionListener(this);
72 | paste.addActionListener(this);
73 | selectAll.addActionListener(this);
74 | font.addActionListener(this);
75 | about.addActionListener(this);
76 | cut2.addActionListener(this);
77 | copy2.addActionListener(this);
78 | paste2.addActionListener(this);
79 | selectAll2.addActionListener(this);
80 | findRep.addActionListener(this);
81 | // 设置撤销文本的管理器
82 | textarea.getDocument().addUndoableEditListener(um);
83 | textarea.setFont(Format.font);
84 | // 文件
85 | file.add(create);
86 | file.add(open);
87 | file.add(save);
88 | file.add(saveAs);
89 | file.addSeparator();
90 | file.add(exit);
91 |
92 | // 编辑
93 | edit.add(undo);
94 | edit.addSeparator();
95 | edit.add(cut);
96 | edit.add(copy);
97 | edit.add(paste);
98 | edit.addSeparator();
99 | edit.add(findRep);
100 | edit.addSeparator();
101 | edit.add(selectAll);
102 |
103 | // 格式
104 | format.add(font);
105 |
106 | // 帮助
107 | help.add(about);
108 |
109 | // 菜单栏
110 | menubar.add(file);
111 | menubar.add(edit);
112 | menubar.add(format);
113 | menubar.add(help);
114 |
115 | // 右键菜单
116 | popup.add(cut2);
117 | popup.add(copy2);
118 | popup.add(paste2);
119 | popup.addSeparator();
120 | popup.add(selectAll2);
121 |
122 | // 添加到文本域容器
123 | textarea.add(popup);
124 |
125 | // 匿名内部类监听器右键动作
126 | textarea.addMouseListener(new MouseAdapter() {
127 | public void mouseReleased(MouseEvent e) {
128 | if (e.getButton() == MouseEvent.BUTTON3) {
129 | popup.show(textarea, e.getX(), e.getY());
130 | }
131 | }
132 | });
133 |
134 | // 边界布局
135 | this.add(menubar, BorderLayout.NORTH);
136 | this.add(scroll, BorderLayout.CENTER);
137 | this.setTitle("记事本");
138 | this.setSize(500, 400);
139 | this.setLocationRelativeTo(null);
140 | this.setIconImage(new ImageIcon(this.getClass().getResource("/images/edit.png")).getImage());
141 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
142 | this.setVisible(true);
143 |
144 | }
145 |
146 | // 重写actionPerformed
147 | @Override
148 | public void actionPerformed(ActionEvent e) {
149 | // Event对象发生源
150 | if (e.getSource() == open) {
151 |
152 | JFileChooser chooser = new JFileChooser();
153 | FileNameExtensionFilter filter = new FileNameExtensionFilter("文本文档(*.txt)", "txt");
154 | chooser.setFileFilter(filter);
155 | chooser.setDialogTitle("文件打开");
156 | chooser.showOpenDialog(null);
157 | chooser.setVisible(true);
158 |
159 | try {
160 | pathSelect = chooser.getSelectedFile().getPath();
161 | FileReader wjl = new FileReader(pathSelect);
162 | BufferedReader hcl = new BufferedReader(wjl);
163 | String s = "", zfc = "";
164 | while ((s = hcl.readLine()) != null) {
165 | zfc += (s + "\n");
166 | }
167 | textarea.setText(zfc);
168 |
169 | } catch (Exception e1) {
170 | }
171 | }
172 |
173 | if (e.getSource() == saveAs) {// 另存为
174 |
175 | JFileChooser chooser = new JFileChooser();
176 | FileNameExtensionFilter filter = new FileNameExtensionFilter("文本文档(*.txt)", "txt");
177 | chooser.setFileFilter(filter);
178 | chooser.setDialogTitle("另存为");
179 | chooser.showSaveDialog(null);
180 | chooser.setVisible(true);
181 |
182 | PrintStream ps;
183 | try {
184 | String select = chooser.getSelectedFile().getPath();
185 | ps = new PrintStream(select);
186 | System.setOut(ps);
187 | System.out.println(this.textarea.getText());
188 |
189 | } catch (Exception e1) {
190 | }
191 | }
192 |
193 | if (e.getSource() == save && (pathSelect == null)) {// 保存
194 | JFileChooser chooser = new JFileChooser();
195 |
196 | chooser.setDialogTitle("保存");
197 | chooser.showSaveDialog(null);
198 | chooser.setVisible(true);
199 |
200 | PrintStream ps;
201 | try {
202 | pathSelect = chooser.getSelectedFile().getPath();
203 | ps = new PrintStream(pathSelect);
204 | System.setOut(ps);
205 | System.out.println(this.textarea.getText());
206 |
207 | } catch (Exception e1) {
208 | }
209 | } else if (e.getSource() == save && !(pathSelect == null)) {
210 | PrintStream ps;
211 | try {
212 | ps = new PrintStream(pathSelect);
213 | System.setOut(ps);
214 | System.out.println(this.textarea.getText());
215 | } catch (FileNotFoundException e1) {
216 | }
217 | }
218 |
219 | if (e.getSource() == create) {
220 | textarea.setText("");
221 | pathSelect = null;
222 | }
223 |
224 | if (e.getSource() == exit) {
225 | System.exit(0);
226 | }
227 |
228 | if (e.getSource() == undo) {
229 | if (um.canUndo()) {
230 | um.undo();
231 | }
232 | }
233 |
234 | if (e.getSource() == cut || e.getSource() == cut2) {
235 | textarea.cut();
236 | } else if (e.getSource() == copy || e.getSource() == copy2) {
237 | textarea.copy();
238 | } else if (e.getSource() == paste || e.getSource() == paste2) {
239 | textarea.paste();
240 | } else if (e.getSource() == findRep) {
241 | new FindAndReplace(textarea);
242 | }
243 |
244 | else if (e.getSource() == selectAll || e.getSource() == selectAll2) {
245 | textarea.selectAll();
246 | }
247 | if (e.getSource() == font) {
248 | new Format(textarea);
249 | }
250 | if (e.getSource() == about) {
251 | new About();
252 | }
253 |
254 | }
255 |
256 | public static void main(String[] args) {
257 | new JNotepad();
258 | }
259 |
260 | }
261 |
262 | class FindAndReplace extends JDialog implements ActionListener {// 查找和替换
263 | JLabel findLabel = new JLabel("查找内容:");
264 | JLabel repLabel = new JLabel(" 替换为:");
265 | JTextField findTf = new JTextField(8);
266 | JTextField repTf = new JTextField(8);
267 | JButton findBtn = new JButton("查找");
268 | JButton repBtn = new JButton("替换");
269 | JPanel findPn = new JPanel();
270 | JPanel repPn = new JPanel();
271 | JTextArea textarea;
272 |
273 | String text;
274 | boolean flg = false;
275 | int len;
276 | int start = 0;
277 | int k = 0;
278 |
279 | public FindAndReplace(JTextArea textarea) {
280 |
281 | this.textarea = textarea;
282 |
283 | findPn.add(findLabel);
284 | findPn.add(findTf);
285 | findPn.add(findBtn);
286 | repPn.add(repLabel);
287 | repPn.add(repTf);
288 | repPn.add(repBtn);
289 | this.add(findPn);
290 | this.add(repPn);
291 |
292 | findBtn.addActionListener(this);
293 | repBtn.addActionListener(this);
294 |
295 | this.setTitle("查找和替换");
296 | this.setLayout(new GridLayout(2, 1));
297 | // this.setBounds(400, 200, 300, 140);
298 | this.pack();
299 | this.setLocationRelativeTo(null);
300 | this.setResizable(false);
301 | this.setVisible(true);
302 | this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
303 | }
304 |
305 | @SuppressWarnings("deprecation")
306 | public void actionPerformed(ActionEvent e) {
307 | String findText = findTf.getText();
308 | String repText = repTf.getText();
309 | text = textarea.getText();
310 | if (e.getSource() == findBtn) {
311 | findBtn.setLabel("下一个");
312 | if (findText != null) {
313 | len = findText.length();
314 | start = text.indexOf(findText, k);
315 | k = start + len;
316 | textarea.select(start, start + len);
317 | flg = true;
318 | if (start == -1) {
319 | JOptionPane.showMessageDialog(null, "已到文件尾部!", "提示", JOptionPane.INFORMATION_MESSAGE);
320 | start = 0;
321 | k = 0;
322 | flg = false;
323 | }
324 | }
325 | } else if (e.getSource() == repBtn) {
326 | if (flg) {
327 | textarea.replaceRange(repText, start, start + len);
328 | flg = false;
329 | }
330 | }
331 | }
332 | }
333 |
334 | // 字体格式
335 | class Format extends JDialog implements ActionListener {
336 |
337 | public static int style = 0; // 全局变量类型,默认值为0
338 | public static int size = 16; // 全局变量字体大小,默认值为16
339 | public static Font font = new Font("新宋体", style, size); // 全局变量字体,默认值为新宋体
340 |
341 | JPanel pn = new JPanel();
342 | JPanel okCelPn = new JPanel();
343 | JPanel fontPn = new JPanel();
344 | JPanel ptPn = new JPanel();
345 | JLabel fontLabel = new JLabel("字体: ");
346 | JLabel fontStyleLabel = new JLabel(" 字形: ");
347 | JLabel ptLabel = new JLabel(" 磅值: ");
348 | JButton ok = new JButton("确定");
349 | JButton cancel = new JButton("取消");
350 | GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();// 获取系统中可用的字体的名字
351 | String[] fontName = e.getAvailableFontFamilyNames();// 获取系统中可用的字体的名字
352 | String[] fontType = { "常规", "倾斜", "粗体", "粗偏斜体" };
353 | JList fontList = new JList(fontName);
354 | JList fontTypeList = new JList(fontType);
355 | JScrollPane fontScroll = new JScrollPane(fontList);
356 | JScrollPane fontTypeScroll = new JScrollPane(fontTypeList);
357 |
358 | JTextArea textarea;
359 | SpinnerModel spinnerModel = new SpinnerNumberModel(size, // initial value
360 | 0, // min
361 | 100, // max
362 | 2 // Step
363 | );
364 | JSpinner spinner = new JSpinner(spinnerModel);
365 |
366 | public Format(JTextArea textarea) {
367 | this.textarea = textarea;
368 | ok.addActionListener(this);
369 | cancel.addActionListener(this);
370 |
371 | pn.setLayout(new GridLayout(2, 1));
372 | pn.add(fontPn);
373 | pn.add(ptPn);
374 |
375 | fontPn.add(fontLabel);
376 | fontPn.add(fontScroll);
377 | fontPn.add(fontStyleLabel);
378 | fontPn.add(fontTypeScroll);
379 |
380 | ptPn.add(ptLabel);
381 | ptPn.add(spinner);
382 |
383 | fontList.setVisibleRowCount(5);
384 | fontList.setFixedCellWidth(60);
385 | fontList.setSelectedIndex(50);
386 | fontList.setSelectedValue(font.getFontName(), true);
387 |
388 | fontTypeList.setVisibleRowCount(5);
389 | fontTypeList.setSelectedIndex(style);
390 | okCelPn.add(ok);
391 | okCelPn.add(cancel);
392 |
393 | okCelPn.setLayout(new FlowLayout(FlowLayout.RIGHT));
394 |
395 | this.add(pn, BorderLayout.CENTER);
396 | this.add(okCelPn, BorderLayout.SOUTH);
397 |
398 | this.setTitle("字体");
399 | this.pack();
400 | this.setLocationRelativeTo(null);
401 | this.setResizable(false);
402 | this.setVisible(true);
403 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
404 | }
405 |
406 | public void actionPerformed(ActionEvent e) {
407 | if (e.getSource() == ok) {
408 | System.out.println(fontList.getSelectedValue());
409 | style = this.type();
410 | size = Integer.parseInt(spinner.getValue().toString());
411 | font = new Font((String) fontList.getSelectedValue(), style, size);
412 | textarea.setFont(font);
413 | this.dispose();
414 | System.out.println(type());
415 | } else if (e.getSource() == cancel) {
416 | this.dispose();
417 | }
418 | }
419 |
420 | private int type() {
421 | if (fontTypeList.getSelectedValue().equals("倾斜")) {
422 | return 1;
423 | } else if (fontTypeList.getSelectedValue().equals("粗体")) {
424 | return 2;
425 | } else if (fontTypeList.getSelectedValue().equals("粗偏斜体")) {
426 | return 3;
427 | } else
428 | return 0;
429 | }
430 |
431 | }
432 |
433 | class About extends JDialog {// 关于窗口
434 |
435 | About() {
436 | JOptionPane.showMessageDialog(null, " 作者:csq 版本:v1.0\n\n 联系:yoyling.com", "关于",
437 | JOptionPane.PLAIN_MESSAGE);
438 | }
439 | }
--------------------------------------------------------------------------------
/src/tools/PwEncryption.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import java.security.NoSuchAlgorithmException;
4 | import java.security.SecureRandom;
5 | import java.util.logging.Level;
6 | import java.util.logging.Logger;
7 |
8 | import javax.crypto.Cipher;
9 | import javax.crypto.KeyGenerator;
10 | import javax.crypto.SecretKey;
11 | import javax.crypto.spec.SecretKeySpec;
12 | import javax.swing.JOptionPane;
13 |
14 | import model.TbPerson;
15 |
16 | import org.apache.commons.codec.binary.Base64;
17 |
18 | import dao.PersonDao;
19 |
20 | /**
21 | * @version V1.0
22 | * @desc AES 加密工具类
23 | */
24 |
25 | public class PwEncryption {
26 | private static final String KEY_ALGORITHM = "AES";
27 | private static final String DEFAULT_CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";//默认的加密算法
28 |
29 | /**
30 | * AES 加密操作
31 | *
32 | * @param content 待加密内容
33 | * @param password 加密密码
34 | * @return 返回Base64转码后的加密数据
35 | */
36 | public static String encrypt(String content, String password) {
37 | try {
38 | Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);// 创建密码器
39 | byte[] byteContent = content.getBytes("utf-8");
40 | cipher.init(Cipher.ENCRYPT_MODE, getSecretKey(password));// 初始化为加密模式的密码器
41 | byte[] result = cipher.doFinal(byteContent);// 加密
42 | return Base64.encodeBase64String(result);//通过Base64转码返回
43 | } catch (Exception ex) {
44 | Logger.getLogger(PwEncryption.class.getName()).log(Level.SEVERE, null, ex);
45 | }
46 | return null;
47 |
48 | }
49 |
50 | /**
51 | * AES 解密操作
52 | *
53 | * @param content
54 | * @param password
55 | * @return
56 | */
57 | public static String decrypt(String content, String password) {
58 | try {
59 | //实例化
60 | Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);
61 | //使用密钥初始化,设置为解密模式
62 | cipher.init(Cipher.DECRYPT_MODE, getSecretKey(password));
63 | //执行操作
64 | byte[] result = cipher.doFinal(Base64.decodeBase64(content));
65 | return new String(result, "utf-8");
66 | } catch (Exception ex) {
67 | Logger.getLogger(PwEncryption.class.getName()).log(Level.SEVERE, null, ex);
68 | }
69 | return null;
70 | }
71 |
72 | /**
73 | * 生成加密秘钥
74 | * @return
75 | */
76 | private static SecretKeySpec getSecretKey(final String password) {
77 | //返回生成指定算法密钥生成器的 KeyGenerator 对象
78 | KeyGenerator kg = null;
79 | try {
80 | kg = KeyGenerator.getInstance(KEY_ALGORITHM);
81 | //AES 要求密钥长度为 128
82 | kg.init(128, new SecureRandom(password.getBytes()));
83 | //生成一个密钥
84 | SecretKey secretKey = kg.generateKey();
85 | return new SecretKeySpec(secretKey.getEncoded(), KEY_ALGORITHM);// 转换为AES专用密钥
86 | } catch (NoSuchAlgorithmException ex) {
87 | Logger.getLogger(PwEncryption.class.getName()).log(Level.SEVERE, null, ex);
88 | }
89 | return null;
90 | }
91 | public static void main(String[] args) {
92 | String s = "123456";
93 | System.out.println("s:" + s);
94 | String s1 = PwEncryption.encrypt(s, "key");
95 | System.out.println(s+"加密:" + s1);
96 | System.out.println("解密:"+PwEncryption.decrypt("Ebw+f2puaXnEvwTQ/QVY/Q==", "key"));
97 |
98 | TbPerson p=PersonDao.findPersonByRecordNumber("T00001");
99 | if (p.getPassword().equals(s1)) {
100 | System.out.println("相等");
101 | }else {
102 | System.out.println("不相等");
103 | }
104 | }
105 | }
--------------------------------------------------------------------------------
/src/tools/StringUtil.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.util.regex.Matcher;
5 | import java.util.regex.Pattern;
6 |
7 | /**
8 | * 字符串工具类
9 | *
10 | * @author 22219
11 | *
12 | */
13 | public class StringUtil {
14 |
15 | /**
16 | * 判断是否为空
17 | *
18 | * @param str
19 | * @return
20 | */
21 | public static boolean isEmpty(String str) {
22 | if (str == null || "".equals(str.trim())) {
23 | return true;
24 | } else {
25 | return false;
26 | }
27 | }
28 |
29 | /**
30 | * 判断是否不是空
31 | *
32 | * @param str
33 | * @return
34 | */
35 | public static boolean isNotEmpty(String str) {
36 | if (str != null && !"".equals(str.trim())) {
37 | return true;
38 | } else {
39 | return false;
40 | }
41 | }
42 |
43 | /**
44 | * 判断是否可转换String为整形
45 | *
46 | * @param str
47 | * @return
48 | */
49 | public static boolean isNumeric(String str) {
50 | Pattern pattern = Pattern.compile("[0-9]*");
51 | Matcher isNum = pattern.matcher(str);
52 | if (!isNum.matches()) {
53 | return false;
54 | }
55 | return true;
56 | }
57 |
58 | /**
59 | * 获取字符串长度
60 | * @param str
61 | * @return
62 | */
63 | public static int getStringLength(String str) {
64 | return str.length();
65 | }
66 |
67 | /**
68 | * 判断是否是一个汉字
69 | * @param c
70 | * @return
71 | */
72 | public static boolean isChineseChar(char c) {
73 | try {
74 | return String.valueOf(c).getBytes("GBK").length > 1;
75 | } catch (UnsupportedEncodingException e) {
76 | return false;
77 | }
78 |
79 | }
80 |
81 | /**
82 | * 获得汉字的长度
83 | * @param s
84 | * @return
85 | */
86 | public static int getChineseCount(String s) {
87 | char c;
88 | int chineseCount = 0;
89 | if (!"".equals("")) {
90 | try {
91 | s = new String(s.getBytes(), "GBK");
92 | } catch (UnsupportedEncodingException e) {
93 | }
94 | }
95 |
96 | for (int i = 0; i < s.length(); i++) {// for循环
97 | c = s.charAt(i); // 获得字符串中的每个字符
98 | if (isChineseChar(c)) {// 调用方法进行判断是否是汉字
99 | chineseCount++; // 等同于chineseCount=chineseCount+1
100 | }
101 | }
102 | return chineseCount; // 返回汉字个数
103 | }
104 |
105 | /**
106 | * 查看字符串里有多少个空格
107 | * @param s
108 | * @return
109 | */
110 | public static int getBlankCount(String s) {
111 | char ch;
112 | int blank = 0;
113 | for (int i = 0; i < s.length(); i++) {
114 | ch = s.charAt(i);
115 | if (ch == ' ')
116 | blank++;
117 | }
118 | return blank;
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/src/tools/Time.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import javax.swing.*;
4 | import java.awt.*;
5 | import java.util.Timer;
6 | import java.util.*;
7 | import java.text.*;
8 | import java.util.Date;
9 |
10 | /**
11 | * 时间工具
12 | * @author 22219
13 | *
14 | */
15 | public class Time {
16 | public static String times = "";
17 |
18 | public String Time() {
19 | TimerTask task = new TimerTask() {
20 | Time time = new Time();
21 |
22 | public void run() {
23 | String sdate;
24 | sdate = (new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"))
25 | .format(new Date());
26 | times = sdate;
27 | }
28 | };
29 | Timer t = new Timer();
30 | t.scheduleAtFixedRate(task, new Date(), 1000);
31 | return times;
32 | }
33 | }
--------------------------------------------------------------------------------
/src/tools/TxtExport.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.FileOutputStream;
7 | import java.io.IOException;
8 | import java.io.InputStreamReader;
9 | import java.io.PrintWriter;
10 |
11 | /**
12 | * 字符流输出文本
13 | * @author 22219
14 | *
15 | */
16 | public class TxtExport {
17 |
18 | private static String path = "C:/";
19 |
20 | private static String filenameTemp;
21 |
22 | public static void main(String[] args) throws IOException {
23 | TxtExport.creatTxtFile("你好");
24 | TxtExport.writeTxtFile("你好");
25 |
26 | }
27 |
28 | /**
29 | * 创建文件
30 | *
31 | * @throws IOException
32 | */
33 | public static boolean creatTxtFile(String name) throws IOException {
34 | boolean flag = false;
35 | filenameTemp = path + name + ".txt";
36 | File filename = new File(filenameTemp);
37 | if (!filename.exists()) {
38 | filename.createNewFile();
39 | flag = true;
40 | }
41 | return flag;
42 | }
43 |
44 | /**
45 | * 写文件
46 | *
47 | * @param newStr
48 | * 新内容
49 | * @throws IOException
50 | */
51 | public static boolean writeTxtFile(String newStr) throws IOException {
52 | // 先读取原有文件内容,然后进行写入操作
53 | boolean flag = false;
54 | String filein = newStr + "\r\n";
55 | String temp = "";
56 |
57 | FileInputStream fis = null;
58 | InputStreamReader isr = null;
59 | BufferedReader br = null;
60 |
61 | FileOutputStream fos = null;
62 | PrintWriter pw = null;
63 | try {
64 | // 文件路径
65 | File file = new File(filenameTemp);
66 | // 将文件读入输入流
67 | fis = new FileInputStream(file);
68 | isr = new InputStreamReader(fis);
69 | br = new BufferedReader(isr);
70 | StringBuffer buf = new StringBuffer();
71 |
72 | // 保存该文件原有的内容
73 | for (int j = 1; (temp = br.readLine()) != null; j++) {
74 | buf = buf.append(temp);
75 | // System.getProperty("line.separator")
76 | // 行与行之间的分隔符 相当于“\n”
77 | buf = buf.append(System.getProperty("line.separator"));
78 | }
79 | buf.append(filein);
80 |
81 | fos = new FileOutputStream(file);
82 | pw = new PrintWriter(fos);
83 | pw.write(buf.toString().toCharArray());
84 | pw.flush();
85 | flag = true;
86 | } catch (IOException e1) {
87 | // TODO 自动生成 catch 块
88 | throw e1;
89 | } finally {
90 | if (pw != null) {
91 | pw.close();
92 | }
93 | if (fos != null) {
94 | fos.close();
95 | }
96 | if (br != null) {
97 | br.close();
98 | }
99 | if (isr != null) {
100 | isr.close();
101 | }
102 | if (fis != null) {
103 | fis.close();
104 | }
105 | }
106 | return flag;
107 | }
108 |
109 | }
--------------------------------------------------------------------------------
/src/view/AddPersonInfoFrame.java:
--------------------------------------------------------------------------------
1 | package view;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.EventQueue;
5 | import java.awt.Font;
6 | import java.awt.HeadlessException;
7 | import java.awt.Image;
8 | import java.awt.Toolkit;
9 | import java.awt.event.ActionEvent;
10 | import java.awt.event.ActionListener;
11 | import java.awt.event.MouseAdapter;
12 | import java.awt.event.MouseEvent;
13 | import java.io.File;
14 | import java.io.FileInputStream;
15 | import java.io.FileOutputStream;
16 | import java.io.InputStream;
17 | import java.io.OutputStream;
18 | import java.net.URL;
19 | import java.text.DateFormat;
20 | import java.text.SimpleDateFormat;
21 | import java.util.Date;
22 | import java.util.List;
23 |
24 | import javax.swing.ButtonGroup;
25 | import javax.swing.ImageIcon;
26 | import javax.swing.JButton;
27 | import javax.swing.JComboBox;
28 | import javax.swing.JFileChooser;
29 | import javax.swing.JFrame;
30 | import javax.swing.JLabel;
31 | import javax.swing.JOptionPane;
32 | import javax.swing.JPanel;
33 | import javax.swing.JRadioButton;
34 | import javax.swing.JTextField;
35 | import javax.swing.SwingConstants;
36 | import javax.swing.border.EmptyBorder;
37 | import javax.swing.border.TitledBorder;
38 |
39 | import model.TbDept;
40 | import model.TbDuty;
41 | import model.TbNativePlace;
42 | import model.TbPerson;
43 | import model.TbRole;
44 | import dao.DeptDao;
45 | import dao.DutyDao;
46 | import dao.NativePlaceDao;
47 | import dao.PersonDao;
48 | import dao.RoleDao;
49 |
50 | public class AddPersonInfoFrame extends JFrame {
51 |
52 | private JPanel contentPane;
53 | private JTextField nameField;
54 | private JTextField birthdayField;
55 | private JTextField idCardField;
56 | private JTextField schoolAgeField;
57 | private JTextField specialtyField;
58 | private JTextField foreignLanguageField;
59 | private JTextField gradeField;
60 | private JTextField stateField;
61 | private JTextField roleField;
62 | private File file;
63 | private JTextField recordNumberField;
64 | private TbPerson person = null;
65 |
66 | public static void main(String[] args) {
67 | EventQueue.invokeLater(new Runnable() {
68 | public void run() {
69 | try {
70 | PersonInfoFrame frame = new PersonInfoFrame();
71 | frame.setVisible(true);
72 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
73 | Dimension frameSize = frame.getSize();
74 | if (frameSize.height > screenSize.height) {
75 | frameSize.height = screenSize.height;
76 | }
77 | if (frameSize.width > screenSize.width) {
78 | frameSize.width = screenSize.width;
79 | }
80 | frame.setLocation((screenSize.width - frameSize.width) / 2,
81 | (screenSize.height - frameSize.height) / 2);
82 |
83 | } catch (Exception e) {
84 | e.printStackTrace();
85 | }
86 | }
87 | });
88 | }
89 |
90 | public AddPersonInfoFrame() {
91 | //初始化时通过前页面传过来的recordNumber查询到这个TbPerson对象,然后初始化表单。
92 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
93 | setResizable(false);
94 | setBounds(100, 100, 896, 611);
95 | setTitle("查看员工信息");
96 | contentPane = new JPanel();
97 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
98 | setContentPane(contentPane);
99 | contentPane.setLayout(null);
100 |
101 | JLabel lblt = new JLabel("员工编号:");
102 | lblt.setFont(new Font("微软雅黑", Font.PLAIN, 18));
103 | lblt.setBounds(36, 32, 98, 41);
104 | contentPane.add(lblt);
105 |
106 | recordNumberField = new JTextField();
107 | recordNumberField.setBounds(140, 32, 138, 41);
108 | recordNumberField.setFont(new Font("微软雅黑", Font.BOLD, 18));
109 | contentPane.add(recordNumberField);
110 | recordNumberField.setColumns(10);
111 |
112 | JLabel photoLabel = new JLabel();
113 | photoLabel.setBounds(665, 65, 120, 166);
114 | contentPane.add(photoLabel);
115 | photoLabel.setHorizontalAlignment(SwingConstants.CENTER);// 设置照片或文字居中显示
116 | photoLabel.setBorder(new TitledBorder(null, "",
117 | TitledBorder.DEFAULT_JUSTIFICATION,
118 | TitledBorder.DEFAULT_POSITION, null, null));// 设置边框
119 | photoLabel.setPreferredSize(new Dimension(120, 166));// 设置显示照片的大小
120 | photoLabel.addMouseListener(new MouseAdapter() {// 添加鼠标监听器
121 | public void mouseClicked(MouseEvent e) {
122 | if (e.getClickCount() == 2) {// 判断是否为双击
123 | JFileChooser fileChooser = new JFileChooser();// 创建文件选取对话框
124 | fileChooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
125 |
126 | @Override
127 | public String getDescription() {
128 | return "图像文件(.jpg;.gif)";
129 | }
130 |
131 | @Override
132 | public boolean accept(File file) {
133 | if (file.isDirectory())// 为文件夹则返回true
134 | return true;
135 | String fileName = file.getName()
136 | .toLowerCase();
137 | if (fileName.endsWith(".jpg") || fileName.endsWith(".gif"))// 为JPG或JIF格式文件则返回true
138 | return true;
139 | return false;// 否则返回false,即不显示在文件选取对话框中
140 | }
141 | });
142 | int i = fileChooser.showOpenDialog(getParent());// 弹出文件选取对话框并接收用户的处理信息
143 | if (i == fileChooser.APPROVE_OPTION) {// 用户选取了照片
144 | file = fileChooser.getSelectedFile();// 获得用户选取的文件对象
145 | if (file != null) {
146 | ImageIcon icon = new ImageIcon(file
147 | .getAbsolutePath());// 创建照片对象
148 | photoLabel.setText(null);// 取消提示文字
149 | photoLabel.setIcon(icon);// 显示照片
150 | }
151 | }
152 | }
153 | }
154 | });
155 |
156 | JPanel deptFramePanel = new JPanel();
157 | deptFramePanel.setBorder(new TitledBorder(null, "所属部门",TitledBorder.DEFAULT_JUSTIFICATION,
158 | TitledBorder.DEFAULT_POSITION, null, null));
159 | deptFramePanel.setBounds(36, 86, 242, 70);
160 | contentPane.add(deptFramePanel);
161 |
162 | JComboBox deptComboBox = new JComboBox();
163 | deptFramePanel.add(deptComboBox);
164 | deptComboBox.setToolTipText("");
165 | List depts = DeptDao.findAllDept();
166 | for (TbDept d:depts) {
167 | deptComboBox.addItem(d.getName());
168 | }
169 |
170 | JPanel dutyFramePanel = new JPanel();
171 | dutyFramePanel.setBorder(new TitledBorder(null, "职位",TitledBorder.DEFAULT_JUSTIFICATION,
172 | TitledBorder.DEFAULT_POSITION, null, null));
173 | dutyFramePanel.setBounds(36, 169, 242, 70);
174 | contentPane.add(dutyFramePanel);
175 |
176 | JComboBox dutyComboBox = new JComboBox();
177 | List dutys = DutyDao.findAllDuty();
178 | for (TbDuty d:dutys) {
179 | dutyComboBox.addItem(d.getName());
180 | }
181 | dutyFramePanel.add(dutyComboBox);
182 |
183 | JLabel nameLabel = new JLabel("姓名:");
184 | nameLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
185 | nameLabel.setBounds(67, 291, 56, 18);
186 | contentPane.add(nameLabel);
187 |
188 | JPanel sexFramePanel = new JPanel();
189 | sexFramePanel.setBounds(302, 32, 242, 70);
190 | sexFramePanel.setBorder(new TitledBorder(null, "性别",
191 | TitledBorder.DEFAULT_JUSTIFICATION,
192 | TitledBorder.DEFAULT_POSITION, null, null));
193 | contentPane.add(sexFramePanel);
194 |
195 |
196 |
197 | JRadioButton nanRadioButton = new JRadioButton("男");
198 | sexFramePanel.add(nanRadioButton);
199 |
200 | JRadioButton nvRadioButton = new JRadioButton("女");
201 | sexFramePanel.add(nvRadioButton);
202 |
203 | ButtonGroup sexGroup=new ButtonGroup();
204 | sexGroup.add(nanRadioButton);
205 | sexGroup.add(nvRadioButton);
206 |
207 | nameField = new JTextField();
208 | nameField.setBounds(122, 286, 156, 30);
209 | contentPane.add(nameField);
210 | nameField.setColumns(10);
211 |
212 | JLabel birthdayLabel = new JLabel("出生日期:");
213 | birthdayLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
214 | birthdayLabel.setBounds(36, 340, 88, 18);
215 | contentPane.add(birthdayLabel);
216 |
217 | birthdayField = new JTextField();
218 | birthdayField.setBounds(122, 336, 156, 30);
219 | contentPane.add(birthdayField);
220 | birthdayField.setColumns(10);
221 |
222 | JLabel idCardLabel = new JLabel("身份证:");
223 | idCardLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
224 | idCardLabel.setBounds(51, 391, 64, 18);
225 | contentPane.add(idCardLabel);
226 |
227 | idCardField = new JTextField();
228 | idCardField.setBounds(122, 386, 156, 30);
229 | contentPane.add(idCardField);
230 | idCardField.setColumns(10);
231 |
232 | JPanel marriagedFramePanel = new JPanel();
233 | marriagedFramePanel.setBorder(new TitledBorder(null, "婚姻状况",
234 |
235 | TitledBorder.DEFAULT_JUSTIFICATION,
236 |
237 | TitledBorder.DEFAULT_POSITION, null, null));
238 | marriagedFramePanel.setBounds(302, 109, 242, 66);
239 | contentPane.add(marriagedFramePanel);
240 |
241 | JRadioButton marrRadioButton = new JRadioButton("已婚");
242 | marriagedFramePanel.add(marrRadioButton);
243 |
244 | JRadioButton noMarrRadioButton = new JRadioButton("未婚");
245 | marriagedFramePanel.add(noMarrRadioButton);
246 |
247 | ButtonGroup marriagedGroup=new ButtonGroup();
248 | marriagedGroup.add(marrRadioButton);
249 | marriagedGroup.add(noMarrRadioButton);
250 |
251 | JPanel nativePlaceFramePanel = new JPanel();
252 | nativePlaceFramePanel.setBorder(new TitledBorder(null, "籍贯",TitledBorder.DEFAULT_JUSTIFICATION,
253 | TitledBorder.DEFAULT_POSITION, null, null));
254 | nativePlaceFramePanel.setBounds(36, 429, 242, 70);
255 | contentPane.add(nativePlaceFramePanel);
256 |
257 | JComboBox nativePlaceComboBox = new JComboBox();
258 | nativePlaceFramePanel.add(nativePlaceComboBox);
259 | List nativePlaces = NativePlaceDao.findAllNativePlace();
260 | for (TbNativePlace np:nativePlaces) {
261 | nativePlaceComboBox.addItem(np.getName());
262 | }
263 |
264 | JPanel partyMemberFramePanel = new JPanel();
265 | partyMemberFramePanel.setBorder(new TitledBorder(null, "是否党员",
266 |
267 |
268 | TitledBorder.DEFAULT_JUSTIFICATION,
269 |
270 |
271 | TitledBorder.DEFAULT_POSITION, null, null));
272 | partyMemberFramePanel.setBounds(302, 188, 242, 66);
273 | contentPane.add(partyMemberFramePanel);
274 |
275 | JRadioButton partyMemberRadioButton = new JRadioButton("是");
276 | partyMemberFramePanel.add(partyMemberRadioButton);
277 |
278 | JRadioButton noPartyMemberRadioButton = new JRadioButton("否");
279 | partyMemberFramePanel.add(noPartyMemberRadioButton);
280 |
281 | ButtonGroup partyMemberGroup=new ButtonGroup();
282 | partyMemberGroup.add(partyMemberRadioButton);
283 | partyMemberGroup.add(noPartyMemberRadioButton);
284 |
285 | JLabel schoolAgeLabel = new JLabel("学历:");
286 | schoolAgeLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
287 | schoolAgeLabel.setBounds(329, 304, 56, 18);
288 | contentPane.add(schoolAgeLabel);
289 |
290 | schoolAgeField = new JTextField();
291 | schoolAgeField.setBounds(388, 298, 156, 30);
292 | contentPane.add(schoolAgeField);
293 | schoolAgeField.setColumns(10);
294 |
295 | JLabel specialtyLabel = new JLabel("专业:");
296 | specialtyLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
297 | specialtyLabel.setBounds(329, 365, 56, 18);
298 | contentPane.add(specialtyLabel);
299 |
300 | specialtyField = new JTextField();
301 | specialtyField.setBounds(388, 360, 156, 30);
302 | contentPane.add(specialtyField);
303 | specialtyField.setColumns(10);
304 |
305 | JLabel foreignLanguageLabel = new JLabel("外语:");
306 | foreignLanguageLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
307 | foreignLanguageLabel.setBounds(329, 424, 56, 18);
308 | contentPane.add(foreignLanguageLabel);
309 |
310 | foreignLanguageField = new JTextField();
311 | foreignLanguageField.setBounds(388, 418, 156, 30);
312 | contentPane.add(foreignLanguageField);
313 | foreignLanguageField.setColumns(10);
314 |
315 | JLabel gradeLabel = new JLabel("外语水平:");
316 | gradeLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
317 | gradeLabel.setBounds(298, 476, 98, 18);
318 | contentPane.add(gradeLabel);
319 |
320 | gradeField = new JTextField();
321 | gradeField.setBounds(388, 469, 156, 30);
322 | contentPane.add(gradeField);
323 | gradeField.setColumns(10);
324 |
325 | JLabel stateLabel = new JLabel("员工状态:");
326 | stateLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
327 | stateLabel.setBounds(601, 322, 98, 18);
328 | contentPane.add(stateLabel);
329 |
330 | stateField = new JTextField();
331 | stateField.setBounds(699, 317, 123, 30);
332 | contentPane.add(stateField);
333 | stateField.setColumns(10);
334 |
335 | JPanel roleFramePanel = new JPanel();
336 | roleFramePanel.setBorder(new TitledBorder(null, "权限",TitledBorder.DEFAULT_JUSTIFICATION,
337 | TitledBorder.DEFAULT_POSITION, null, null));
338 | roleFramePanel.setBounds(586, 366, 236, 66);
339 | contentPane.add(roleFramePanel);
340 |
341 | JComboBox roleComboBox = new JComboBox();
342 | roleFramePanel.add(roleComboBox);
343 | List roles = RoleDao.findAllRole();
344 | for (TbRole r:roles) {
345 | roleComboBox.addItem(r.getName());
346 | }
347 |
348 | JButton addButton = new JButton("添加");
349 | addButton.setBounds(586, 459, 113, 41);
350 | contentPane.add(addButton);
351 |
352 |
353 | JButton exitButton = new JButton("退出");
354 | exitButton.setBounds(709, 459, 113, 41);
355 | contentPane.add(exitButton);
356 |
357 | exitButton.addActionListener(new ActionListener() {
358 | @Override
359 | public void actionPerformed(ActionEvent e) {
360 | dispose();
361 | }
362 | });
363 |
364 | addButton.addActionListener(new ActionListener() {
365 | @Override
366 | public void actionPerformed(ActionEvent e) {
367 | //创建新的TbPerson表对象,查询是否已存在该员工,按逻辑判断所有格式是否正确,set放数据,执行add,成功则提示
368 | TbPerson findPerson = new TbPerson();
369 | person = new TbPerson();
370 | try {
371 | findPerson = PersonDao.findPersonByRecordNumber(recordNumberField.getText().trim());
372 | } catch (Exception e1) {
373 | System.out.println("空结果数据访问异常");
374 | e1.printStackTrace();
375 | }
376 | int finish = 1;//设置检查状态默认为可添加
377 | if(findPerson != null) {//根据员工号判断数据库已存在此员工
378 | JOptionPane.showMessageDialog(null, "已存在员工号"+recordNumberField.getText().trim()+"!");
379 | finish = 0;
380 | }else {
381 | //员工号 所属部门 职位 籍贯 权限
382 | person.setRecordNumber(recordNumberField.getText().trim());
383 | person.setDeptId(deptComboBox.getSelectedIndex()+1);
384 | person.setDutyId(dutyComboBox.getSelectedIndex());
385 | person.setNativePlaceId(nativePlaceComboBox.getSelectedIndex());
386 | person.setRoleId(roleComboBox.getSelectedIndex());
387 |
388 | //姓名 出生日期 身份证 学历 专业 外语 外语水平 状态
389 | person.setName(nameField.getText());
390 |
391 | DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
392 | Date birthdayDate = null;
393 | if(!"".equals(birthdayField.getText())) {
394 | try{
395 | birthdayDate = formatter.parse(birthdayField.getText());
396 | }catch(Exception e3){
397 | JOptionPane.showMessageDialog(null, "日期格式错误!正确例子:yyyy-mm-dd");
398 | System.out.println("日期格式转换出错");
399 | finish = 0;//设置检查状态默认为不可添加
400 | }
401 | }
402 |
403 | person.setBirthday(birthdayDate);
404 |
405 | person.setIdCard(idCardField.getText());
406 | person.setSchoolAge(schoolAgeField.getText());
407 | person.setSpecialty(specialtyField.getText());
408 | person.setForeignLanguage(foreignLanguageField.getText());
409 | person.setGrade(gradeField.getText());
410 | person.setState(stateField.getText());
411 | //性别 婚姻 党员
412 | if(nanRadioButton.isSelected()) {
413 | person.setSex("男");
414 | }else if(nvRadioButton.isSelected()) {
415 | person.setSex("女");
416 | }else {
417 | }
418 |
419 | if(marrRadioButton.isSelected()) {
420 | person.setMarriaged("已婚");
421 | }else if(noMarrRadioButton.isSelected()) {
422 | person.setMarriaged("未婚");
423 | }else {
424 | }
425 |
426 | if(partyMemberRadioButton.isSelected()) {
427 | person.setPartyMember("是");
428 | }else if(noPartyMemberRadioButton.isSelected()) {
429 | person.setPartyMember("否");
430 | }else {
431 | }
432 |
433 | // 保存图片
434 | if(!"".equals(recordNumberField.getText().trim())) {
435 | if("".equals(recordNumberField.getText().trim())) {
436 | JOptionPane.showMessageDialog(null, "请先填写员工ID");
437 | }
438 | if (photoLabel.getIcon() != null) {//如果用户双击添加了图片
439 | try {
440 | //暂不上传,需要获取该图后缀.jpg拼接person名
441 | String newPhotoName = recordNumberField.getText().trim()+""+file.getName().substring(file.getName().lastIndexOf("."));
442 | //在服务器资源目录创建此文件
443 | File file2 =new File(this.getClass().getResource("/").getPath()+"personnel_photo");
444 | if (!file2 .exists() && !file2 .isDirectory()) {
445 | file2 .mkdir();
446 | }
447 | File photo = new File(this.getClass().getResource("/").getPath()+"personnel_photo/"+newPhotoName);
448 | person.setPhoto(newPhotoName);// 将新的图片名称保存到person对象中待上传
449 | if (!photo.exists()) {// 如果文件不存在则创建文件
450 | photo.createNewFile();
451 | }
452 | if(photo.exists()) {//因为是双击添加图,如果存在,就删除重新创建
453 | photo.delete();
454 | }
455 |
456 | InputStream inStream = new FileInputStream(file);// 创建输入流对象
457 | OutputStream outStream = new FileOutputStream(photo);// 创建输出流对象
458 | int readBytes = 0; // 读取字节数
459 | byte[] buffer = new byte[1024]; // 定义缓存数组
460 | while ((readBytes = inStream.read(buffer, 0, 1024)) != -1) { // 从输入流读取数据到缓存数组中
461 | outStream.write(buffer, 0, readBytes); // 将缓存数组中的数据输出到输出流
462 | }
463 | outStream.close();// 关闭输出流对象
464 | inStream.close();// 关闭输入流对象
465 | } catch (Exception e2) {
466 | System.out.println("照片传输IO流异常");
467 | e2.printStackTrace();
468 | }
469 | }
470 | }
471 | if("".equals(recordNumberField.getText().trim())) {
472 | finish = 0;
473 | JOptionPane.showMessageDialog(null, "请先填写员工ID");
474 | }
475 | }
476 |
477 | if(finish == 1) {
478 | //执行add
479 | PersonDao.addPerson(person);
480 | JOptionPane.showMessageDialog(null, "添加成功!");
481 | }
482 | }
483 | });
484 |
485 | photoLabel.setText("双击添加照片");
486 |
487 | }
488 | }
489 |
--------------------------------------------------------------------------------
/src/view/EnrolmentFrame.java:
--------------------------------------------------------------------------------
1 | package view;
2 |
3 | import javax.swing.JFrame;
4 | import javax.swing.JOptionPane;
5 | import javax.swing.JPanel;
6 | import javax.swing.border.EmptyBorder;
7 | import javax.swing.JLabel;
8 |
9 | import java.awt.Toolkit;
10 | import java.awt.Font;
11 |
12 | import javax.swing.JButton;
13 |
14 | import java.awt.event.ActionListener;
15 | import java.awt.event.ActionEvent;
16 | import java.awt.event.WindowAdapter;
17 | import java.awt.event.WindowEvent;
18 |
19 | import javax.swing.JTextField;
20 | import javax.swing.ImageIcon;
21 | import javax.swing.SwingConstants;
22 | import javax.swing.JPasswordField;
23 |
24 | import model.TbPerson;
25 | import dao.PersonDao;
26 | import tools.PwEncryption;
27 | import tools.StringUtil;
28 | import view.LoginFrame;
29 |
30 | /**
31 | * 注册窗体类
32 | * @author 22219
33 | *
34 | */
35 | public class EnrolmentFrame extends JFrame {
36 |
37 | /**
38 | * 串行版本标识serialVersionUID
39 | */
40 | private static final long serialVersionUID = 1L;
41 | public static JPanel contentPane;
42 | private JTextField userNameTxt;
43 | private JPasswordField passwordTxt;
44 | private JPasswordField passwordTxtEnter;
45 | private JLabel label_1;
46 | private JButton btnNewButton_2;
47 |
48 | /**
49 | * Create the frame.
50 | */
51 | public EnrolmentFrame() {
52 |
53 | this.setBounds(0, 0, 500, 400);
54 | this.setLocationRelativeTo(null);
55 | setResizable(false);
56 |
57 | setTitle("\u7528\u6237\u6CE8\u518C/\u4FEE\u6539");
58 | setIconImage(Toolkit.getDefaultToolkit().getImage(EnrolmentFrame.class.getResource("/images/storage_128px.png")));
59 |
60 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
61 | contentPane = new JPanel();
62 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
63 | setContentPane(contentPane);
64 | contentPane.setLayout(null);
65 |
66 | JLabel lblEnrollfrm = new JLabel("\u7528\u6237\u540D\uFF1A");
67 | lblEnrollfrm.setIcon(new ImageIcon(EnrolmentFrame.class.getResource("/images/userName.png")));
68 | lblEnrollfrm.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
69 | lblEnrollfrm.setBounds(14, 62, 99, 35);
70 | contentPane.add(lblEnrollfrm);
71 |
72 | JButton btnNewButton = new JButton("\u6CE8\u518C");
73 | btnNewButton.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
74 | btnNewButton.setIcon(new ImageIcon(EnrolmentFrame.class.getResource("/images/modify.png")));
75 | btnNewButton.addActionListener(new ActionListener() {
76 | public void actionPerformed(ActionEvent e) {
77 | signinValueActionPerformed(e);
78 | }
79 | });
80 |
81 | JLabel label = new JLabel("\u5BC6\u7801\uFF1A");
82 | label.setIcon(new ImageIcon(EnrolmentFrame.class.getResource("/images/password.png")));
83 | label.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
84 | label.setBounds(28, 128, 90, 25);
85 | contentPane.add(label);
86 | btnNewButton.setBounds(95, 252, 90, 40);
87 | contentPane.add(btnNewButton);
88 |
89 | JButton btnNewButton_1 = new JButton("\u8FD4\u56DE");
90 | btnNewButton_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
91 | btnNewButton_1.addActionListener(new ActionListener() {
92 | public void actionPerformed(ActionEvent e) {
93 | returnValueActionPerformed(e);
94 | }
95 | });
96 |
97 | btnNewButton_2 = new JButton("\u4FEE\u6539");
98 | btnNewButton_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
99 | btnNewButton_2.addActionListener(new ActionListener() {
100 | public void actionPerformed(ActionEvent e) {
101 | editValueActionPerformed(e);
102 | }
103 | });
104 |
105 | btnNewButton_2.setIcon(new ImageIcon(EnrolmentFrame.class.getResource("/images/edit.png")));
106 | btnNewButton_2.setBounds(203, 252, 90, 40);
107 | contentPane.add(btnNewButton_2);
108 | btnNewButton_1.setBounds(307, 252, 90, 40);
109 | contentPane.add(btnNewButton_1);
110 |
111 | userNameTxt = new JTextField();
112 | userNameTxt.setHorizontalAlignment(SwingConstants.CENTER);
113 | userNameTxt.setFont(new Font("微软雅黑", Font.BOLD, 20));
114 | userNameTxt.setToolTipText("\u8BF7\u8F93\u5165\u8981\u6CE8\u518C\u6216\u4FEE\u6539\u7684\u8D26\u53F7");
115 | userNameTxt.setBounds(93, 51, 303, 50);
116 | contentPane.add(userNameTxt);
117 | userNameTxt.setColumns(10);
118 |
119 | passwordTxt = new JPasswordField();
120 | passwordTxt.setHorizontalAlignment(SwingConstants.CENTER);
121 | passwordTxt.setToolTipText("\u8F93\u5165\u5BC6\u7801");
122 | passwordTxt.setFont(new Font("微软雅黑", Font.BOLD, 20));
123 | passwordTxt.setBounds(93, 114, 303, 50);
124 | contentPane.add(passwordTxt);
125 |
126 | passwordTxtEnter = new JPasswordField();
127 | passwordTxtEnter.setHorizontalAlignment(SwingConstants.CENTER);
128 | passwordTxtEnter.setToolTipText("\u786E\u8BA4\u5BC6\u7801");
129 | passwordTxtEnter.setFont(new Font("微软雅黑", Font.BOLD, 20));
130 | passwordTxtEnter.setBounds(94, 177, 302, 50);
131 | contentPane.add(passwordTxtEnter);
132 |
133 | label_1 = new JLabel("\u518D\u6B21\u786E\u8BA4\uFF1A");
134 | label_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
135 | label_1.setBounds(18, 192, 84, 18);
136 | contentPane.add(label_1);
137 |
138 | JLabel lbBg = new JLabel(new ImageIcon(this.getClass().getResource("/images/timg.png")));
139 | lbBg.setBounds(0, 0, 500, 400);
140 | this.getContentPane().add(lbBg);
141 | }
142 |
143 | /**
144 | * 返回事件处理
145 | * @param e
146 | */
147 | private void returnValueActionPerformed(ActionEvent e) {
148 | dispose();
149 | LoginFrame frame = new LoginFrame();
150 | frame.setVisible(true);
151 | frame.addWindowListener(new WindowAdapter() {
152 | public void windowClosing(WindowEvent e){
153 | if (JOptionPane.showConfirmDialog(frame, "Are you sure to leave this page?","Warning",JOptionPane.YES_NO_OPTION)==0) {
154 | System.exit(0);
155 | }
156 | else
157 | frame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
158 | }
159 | });
160 |
161 | }
162 |
163 | /**
164 | * 注册事件处理
165 | * @param e
166 | * @throws Exception
167 | */
168 | private void signinValueActionPerformed(ActionEvent e) {
169 | TbPerson p = new TbPerson();
170 | String userName = this.userNameTxt.getText();
171 | String password = new String(this.passwordTxt.getPassword());
172 | String passwordEnter = new String(this.passwordTxtEnter.getPassword());
173 |
174 | if(StringUtil.isEmpty(userName)||StringUtil.isEmpty(password)||StringUtil.isEmpty(passwordEnter)){
175 | JOptionPane.showMessageDialog(this, "请输入完整注册信息!");
176 | return;
177 | }else if (StringUtil.getChineseCount(userName)>=1) {
178 | JOptionPane.showMessageDialog(this, "请勿输入中文!");
179 | return;
180 | }else if (StringUtil.getStringLength(userName)>20|StringUtil.getStringLength(userName)<4) {
181 | JOptionPane.showMessageDialog(this, "用户名需大于等于4位且小于等于20位!");
182 | return;
183 | }else if (StringUtil.getStringLength(password)<6) {
184 | JOptionPane.showMessageDialog(this, "密码需大于等于六位!");
185 | return;
186 | }else if (!password.equals(passwordEnter)) {
187 | JOptionPane.showMessageDialog(this, "密码确认错误!");
188 | return;
189 | }else {
190 | p = PersonDao.findPersonByRecordNumber(userName);//从库中查询指定员工id的记录,若不存在,则返回null
191 | if(p!=null){
192 | JOptionPane.showMessageDialog(this, "已存在该用户!");
193 | }else {
194 | TbPerson person = new TbPerson();
195 | person.setRecordNumber(userName);
196 | person.setPassword(PwEncryption.encrypt(passwordEnter, "key"));
197 | PersonDao.addPerson(person);
198 | JOptionPane.showMessageDialog(this, "注册成功");
199 |
200 | }
201 | }
202 | }
203 |
204 | /**
205 | * 修改事件处理
206 | * @param e
207 | */
208 | private void editValueActionPerformed(ActionEvent e) {
209 | TbPerson p = new TbPerson();
210 | String userName = this.userNameTxt.getText();
211 | String password = new String(this.passwordTxt.getPassword());
212 | String passwordEnter = new String(this.passwordTxtEnter.getPassword());
213 |
214 | if(StringUtil.isEmpty(userName)||StringUtil.isEmpty(password)||StringUtil.isEmpty(passwordEnter)){
215 | JOptionPane.showMessageDialog(this, "请输入完整修改信息!");
216 | return;
217 | }else if (StringUtil.getChineseCount(userName)>=1) {
218 | JOptionPane.showMessageDialog(this, "请勿输入中文!");
219 | return;
220 | }else if (StringUtil.getStringLength(userName)>20|StringUtil.getStringLength(userName)<4) {
221 | JOptionPane.showMessageDialog(this, "用户名需大于等于4位且小于等于20位!");
222 | return;
223 | }else if (StringUtil.getStringLength(password)<6) {
224 | JOptionPane.showMessageDialog(this, "密码需大于等于六位!");
225 | return;
226 | }else if (!password.equals(passwordEnter)) {
227 | JOptionPane.showMessageDialog(this, "密码确认错误!");
228 | return;
229 | }else {
230 | p = PersonDao.findPersonByRecordNumber(userName);//从库中查询指定id的记录,若不存在,则返回null
231 | if(p!=null){
232 | if(p.getRecordNumber().equals("T00001")){
233 | JOptionPane.showMessageDialog(this, "不可修改!");
234 | }else{
235 | TbPerson person = new TbPerson();
236 | person.setRecordNumber(userName);
237 | person.setPassword(PwEncryption.encrypt(passwordEnter, "key"));
238 | PersonDao.updatePersonPassword(person);
239 | JOptionPane.showMessageDialog(this, "修改成功!");
240 | }
241 | }else {
242 | JOptionPane.showMessageDialog(this, "不存在该用户!");
243 | }
244 | }
245 |
246 | }
247 |
248 | /**
249 | * Launch the application.
250 | */
251 | public static void main(String[] args) {
252 | EnrolmentFrame frame = new EnrolmentFrame();
253 | frame.setVisible(true);
254 | }
255 | }
256 |
--------------------------------------------------------------------------------
/src/view/LoginFrame.java:
--------------------------------------------------------------------------------
1 | package view;
2 |
3 | import java.awt.Font;
4 | import java.awt.event.ActionEvent;
5 | import java.awt.event.ActionListener;
6 | import java.awt.event.WindowAdapter;
7 | import java.awt.event.WindowEvent;
8 | import java.awt.Toolkit;
9 | import java.io.IOException;
10 | import java.sql.Connection;
11 | import java.text.SimpleDateFormat;
12 | import java.util.Date;
13 | import java.util.Timer;
14 | import java.util.TimerTask;
15 |
16 | import javax.swing.ImageIcon;
17 | import javax.swing.JButton;
18 | import javax.swing.JFrame;
19 | import javax.swing.JLabel;
20 | import javax.swing.JOptionPane;
21 | import javax.swing.JPanel;
22 | import javax.swing.JPasswordField;
23 | import javax.swing.JTextField;
24 | import javax.swing.UIManager;
25 | import javax.swing.border.EmptyBorder;
26 | import javax.swing.SwingConstants;
27 |
28 | import model.TbPerson;
29 |
30 | import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;
31 |
32 | import dao.PersonDao;
33 | import tools.PwEncryption;
34 | import tools.StringUtil;
35 | import tools.TxtExport;
36 |
37 | /**
38 | * 登陆窗体类,为用户第一窗体
39 | * @author 22219
40 | *
41 | */
42 | public class LoginFrame extends JFrame {
43 |
44 | /**
45 | * 串行版本标识serialVersionUID
46 | */
47 | private static final long serialVersionUID = 1L;
48 |
49 | private JPanel contentPane;
50 | public static JTextField userNameTxt;
51 | private JPasswordField passwordTxt;
52 | public static String time;
53 | public static String userId;
54 |
55 | /**
56 | * 登陆窗体类的构造函数
57 | */
58 | public LoginFrame() {
59 |
60 | this.setBounds(0, 0, 500, 400);
61 | this.setLocationRelativeTo(null);
62 | setResizable(false);
63 | setIconImage(Toolkit.getDefaultToolkit().getImage(LoginFrame.class.getResource("/images/storage_128px.png")));
64 | setTitle("登录");
65 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
66 |
67 | contentPane = new JPanel();
68 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
69 | setContentPane(contentPane);
70 | contentPane.setLayout(null);
71 |
72 | JLabel lblNewLabel = new JLabel("企业人事管理系统");
73 | lblNewLabel.setBounds(96, 29, 300, 48);
74 | lblNewLabel.setFont(new Font("方正粗黑宋简体", Font.BOLD, 27));
75 | lblNewLabel.setIcon(new ImageIcon(LoginFrame.class.getResource("/images/hrm.png")));
76 |
77 | JLabel lblNewLabel_1 = new JLabel("用户名");
78 | lblNewLabel_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
79 | lblNewLabel_1.setBounds(19, 126, 80, 18);
80 | lblNewLabel_1.setIcon(new ImageIcon(LoginFrame.class.getResource("/images/userName.png")));
81 |
82 | JLabel lblNewLabel_2 = new JLabel("密码");
83 | lblNewLabel_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
84 | lblNewLabel_2.setBounds(34, 185, 65, 18);
85 | lblNewLabel_2.setIcon(new ImageIcon(LoginFrame.class.getResource("/images/password.png")));
86 |
87 | userNameTxt = new JTextField();
88 | userNameTxt.setHorizontalAlignment(SwingConstants.CENTER);
89 | userNameTxt.setBounds(96, 110, 308, 46);
90 | userNameTxt.setFont(new Font("微软雅黑", Font.BOLD, 20));
91 | userNameTxt.setToolTipText("输入用户名");
92 | userNameTxt.setColumns(10);
93 |
94 | passwordTxt = new JPasswordField();
95 | passwordTxt.setHorizontalAlignment(SwingConstants.CENTER);
96 | passwordTxt.setBounds(96, 169, 308, 46);
97 | passwordTxt.setFont(new Font("微软雅黑", Font.BOLD, 20));
98 | passwordTxt.setToolTipText("输入密码");
99 |
100 | JButton btnNewButton = new JButton("登录");
101 | btnNewButton.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
102 | btnNewButton.setBounds(97, 252, 90, 40);
103 | this.getRootPane().setDefaultButton(btnNewButton);
104 | btnNewButton.setIcon(new ImageIcon(LoginFrame.class.getResource("/images/login.png")));
105 | btnNewButton.addActionListener(new ActionListener() {
106 | public void actionPerformed(ActionEvent e) {
107 | loginActionPerformed(e);
108 | }
109 | });
110 |
111 |
112 | JButton btnNewButton_1 = new JButton("重置");
113 | btnNewButton_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
114 | btnNewButton_1.setBounds(201, 252, 90, 40);
115 | btnNewButton_1.setIcon(new ImageIcon(LoginFrame.class.getResource("/images/reset.png")));
116 | btnNewButton_1.addActionListener(new ActionListener() {
117 | public void actionPerformed(ActionEvent e) {
118 | resetValueActionPerformed(e);
119 | }
120 | });
121 |
122 |
123 | JButton btnNewButton_2 = new JButton("注/改");
124 | btnNewButton_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
125 | btnNewButton_2.setBounds(305, 252, 90, 40);
126 | btnNewButton_2.setIcon(new ImageIcon(LoginFrame.class.getResource("/images/add.png")));
127 | btnNewButton_2.addActionListener(new ActionListener() {
128 | public void actionPerformed(ActionEvent e) {
129 | enrollValueActionPerformed(e);
130 | }
131 | });
132 |
133 |
134 | contentPane.add(lblNewLabel);
135 | contentPane.add(lblNewLabel_1);
136 | contentPane.add(lblNewLabel_2);
137 | contentPane.add(passwordTxt);
138 | contentPane.add(userNameTxt);
139 | contentPane.add(btnNewButton);
140 | contentPane.add(btnNewButton_1);
141 | contentPane.add(btnNewButton_2);
142 |
143 | this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
144 | this.addWindowListener(new WindowAdapter() {
145 | public void windowClosing(WindowEvent e){
146 | if (JOptionPane.showConfirmDialog(null, "确认退出?","提示",JOptionPane.YES_NO_OPTION)==0) {
147 | System.exit(0);
148 | }
149 | }
150 | });
151 |
152 | //bg------------------------------------------------
153 | JLabel lbBg = new JLabel(new ImageIcon(this.getClass().getResource("/images/timg.png")));
154 | lbBg.setBounds(0, 0, 500, 400);
155 | this.getContentPane().add(lbBg);
156 | //bg------------------------------------------------
157 |
158 | //sj------------------------------------------------
159 | JLabel timeLabel = new JLabel();
160 | timeLabel.setBounds(260, 319, 220, 18);
161 | contentPane.add(timeLabel);
162 |
163 | TimerTask task = new TimerTask() {
164 | public void run() {
165 | String sdate=(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date());
166 | timeLabel.setText(sdate);
167 | }
168 | };
169 | Timer t = new Timer();
170 | t.scheduleAtFixedRate(task, new Date(), 1000);
171 | //sj-------------------------------------------------
172 | }
173 |
174 | /**
175 | * 登陆事件处理
176 | * @param e
177 | */
178 | private void loginActionPerformed(ActionEvent e) {
179 | String userName = this.userNameTxt.getText();
180 | String password = new String(this.passwordTxt.getPassword());
181 | if(StringUtil.isEmpty(userName)){
182 | JOptionPane.showMessageDialog(this, "用户名不能为空!");
183 | return;
184 | }
185 | if(StringUtil.isEmpty(password)){
186 | JOptionPane.showMessageDialog(this, "密码不能为空!");
187 | return;
188 | }
189 |
190 | TbPerson person = new TbPerson(userName,PwEncryption.encrypt(password, "key"));
191 | // TbPerson person = new TbPerson(userName,password);
192 | TbPerson personNew = PersonDao.login(person);
193 | if(personNew!=null){
194 | JOptionPane.showMessageDialog(this, "登陆成功!");
195 | MainFrame mainFrame = new MainFrame(userNameTxt.getText());
196 | mainFrame.frame.setVisible(true);
197 |
198 | //导出登陆日志(用户id+时间)
199 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
200 | time = df.format(new Date());
201 | System.out.println("用户Id:"+userNameTxt.getText()+"\t登陆时间:"+time);
202 |
203 | try {
204 | TxtExport.creatTxtFile("Enterprise Personnel Management System");
205 | TxtExport.writeTxtFile("员工Id:"+userNameTxt.getText()+"\t登陆时间:"+time);
206 | } catch (IOException e1) {
207 | e1.printStackTrace();
208 | }
209 |
210 |
211 |
212 | dispose();//销毁窗体
213 | }else{
214 | JOptionPane.showMessageDialog(this, "用户名或密码错误!");
215 | }
216 | }
217 |
218 | /**
219 | * 重置事件处理
220 | * @param e
221 | */
222 | private void resetValueActionPerformed(ActionEvent evt) {
223 | this.userNameTxt.setText("");
224 | this.passwordTxt.setText("");
225 | userNameTxt.requestFocus();
226 |
227 | }
228 |
229 | /**
230 | * 注册事件处理
231 | * @param e
232 | */
233 | private void enrollValueActionPerformed(ActionEvent e) {
234 |
235 | String str = JOptionPane.showInputDialog(this, "输入超级管理员密码", "KEY",2);
236 | TbPerson p = PersonDao.findPersonByRecordNumber("T00001");
237 | if(str==null){
238 | return;
239 | }else if ("".equals(str)) {
240 | JOptionPane.showMessageDialog(this, "请至少输入一个字符", "", 1);
241 | }else if (p.getPassword().equals(PwEncryption.encrypt(str, "key"))) {
242 | // }else if (str.equals(p.getPassword())) {
243 | this.setVisible(false);
244 | dispose();
245 | EnrolmentFrame enrollFrame = new EnrolmentFrame();
246 | enrollFrame.setVisible(true);
247 | }else{
248 | JOptionPane.showMessageDialog(this, "密码错误", "", 0);
249 | }
250 |
251 | }
252 |
253 | /**
254 | * 登陆窗口
255 | */
256 | public static void main(String[] args) {
257 | }
258 |
259 | }
260 |
--------------------------------------------------------------------------------
/src/view/MainFrame.java:
--------------------------------------------------------------------------------
1 | package view;
2 |
3 | import java.awt.EventQueue;
4 |
5 | import javax.swing.*;
6 |
7 | import java.awt.BorderLayout;
8 | import java.awt.Color;
9 | import java.awt.Dimension;
10 | import java.awt.Event;
11 | import java.awt.Toolkit;
12 |
13 | import java.awt.Font;
14 | import java.awt.event.KeyEvent;
15 | import java.io.*;
16 | import java.text.ParseException;
17 | import java.text.SimpleDateFormat;
18 | import java.util.Date;
19 | import java.util.Iterator;
20 | import java.util.List;
21 |
22 | import javax.swing.border.TitledBorder;
23 | import javax.swing.event.ChangeEvent;
24 | import javax.swing.event.ChangeListener;
25 | import javax.swing.table.DefaultTableCellRenderer;
26 | import javax.swing.table.DefaultTableModel;
27 | import javax.swing.table.JTableHeader;
28 | import javax.swing.table.TableModel;
29 | import javax.swing.table.TableRowSorter;
30 |
31 | import dao.AccountDao;
32 | import dao.DeptDao;
33 | import dao.DutyDao;
34 | import dao.PersonDao;
35 | import dao.NativePlaceDao;
36 | import dao.RoleDao;
37 | import dao.TimecardDao;
38 |
39 | import java.awt.event.ActionListener;
40 | import java.awt.event.ActionEvent;
41 | import java.awt.event.ItemEvent;
42 | import java.awt.event.ItemListener;
43 | import java.awt.event.MouseAdapter;
44 | import java.awt.event.MouseEvent;
45 | import java.awt.event.WindowAdapter;
46 | import java.awt.event.WindowEvent;
47 |
48 | import javafx.stage.FileChooser;
49 | import model.TbAccount;
50 | import model.TbDept;
51 | import model.TbDuty;
52 | import model.TbNativePlace;
53 | import model.TbPerson;
54 | import model.TbRole;
55 | import model.TbTimecard;
56 |
57 | import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;
58 |
59 | import tools.IoUtil;
60 |
61 | public class MainFrame {
62 |
63 | public static JFrame frame;
64 | private JTextField nameOrIdField;
65 | private JTable table;
66 | private DefaultTableModel model;
67 | private DefaultTableModel model2;
68 | private DefaultTableModel model3;
69 | private JComboBox deptComboBox;
70 | private JMenuItem lookMenItem;
71 | private String recordNumber;
72 | private JLabel statusLabel;
73 | private String userId;
74 | private JTextField explainTextField;
75 | private JTextField timecardTimeTextField;
76 |
77 | private JComboBox timecardTypeComboBox;
78 | private JComboBox personIdComboBox;
79 | private JComboBox ratifierIdComboBox;
80 | private JTable table_1;
81 | private JTextField textField;
82 | private JTable table_2;
83 | /**
84 | * Launch the application.
85 | */
86 | public static void main(String[] args) {
87 | EventQueue.invokeLater(new Runnable() {
88 | public void run() {
89 | try {
90 | MainFrame window = new MainFrame(LoginFrame.userNameTxt.getText());
91 | window.frame.setVisible(true);
92 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
93 | Dimension frameSize = window.frame.getSize();
94 | if (frameSize.height > screenSize.height) {
95 | frameSize.height = screenSize.height;
96 | }
97 | if (frameSize.width > screenSize.width) {
98 | frameSize.width = screenSize.width;
99 | }
100 | window.frame.setLocation((screenSize.width - frameSize.width) / 2,
101 | (screenSize.height - frameSize.height) / 2);
102 | window.frame.setVisible(true);
103 | } catch (Exception e) {
104 | e.printStackTrace();
105 | }
106 | }
107 | });
108 | }
109 |
110 | /**
111 | * Create the application.
112 | */
113 | public MainFrame() {
114 | }
115 |
116 | public MainFrame(String uid) {
117 | userId = uid;
118 | initialize();
119 |
120 |
121 | }
122 |
123 | private void initialize() {
124 | frame = new JFrame();
125 | frame.setTitle("企业人事管理系统");
126 | frame.setIconImage(Toolkit.getDefaultToolkit().getImage(
127 | MainFrame.class.getResource("/images/storage_128px.png")));
128 | frame.setBounds(100, 100, 1600, 900);
129 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
130 |
131 | // 关闭窗口监听
132 | frame.setDefaultCloseOperation(frame.DO_NOTHING_ON_CLOSE);
133 | frame.addWindowListener(new WindowAdapter() {
134 | public void windowClosing(WindowEvent e) {
135 | if (JOptionPane.showConfirmDialog(null, "确认退出?", "提示",
136 | JOptionPane.YES_NO_OPTION) == 0) {
137 | System.exit(0);
138 | }
139 | }
140 | });
141 |
142 | JMenuBar menuBar = new JMenuBar();
143 | menuBar.setBackground(Color.WHITE);
144 | frame.getContentPane().add(menuBar, BorderLayout.NORTH);
145 |
146 | JMenu menu = new JMenu("文件");
147 | menu.setIcon(new ImageIcon(MainFrame.class
148 | .getResource("/images/base.png")));
149 | menuBar.add(menu);
150 |
151 |
152 |
153 | JMenuItem menuItem = new JMenuItem("注销");
154 | menuItem.setMnemonic(KeyEvent.VK_A);
155 | menuItem.setIcon(new ImageIcon(MainFrame.class
156 | .getResource("/images/password.png")));
157 | menuItem.setFont(new Font("微软雅黑", Font.PLAIN, 15));
158 | menu.add(menuItem);
159 | menuItem.addActionListener(new ActionListener() {
160 | public void actionPerformed(ActionEvent e) {
161 | if (JOptionPane.showConfirmDialog(null, "确认注销?", "提示",
162 | JOptionPane.YES_NO_OPTION) == 0) {
163 | frame.dispose();
164 | LoginFrame frame2 = new LoginFrame();
165 | frame2.setVisible(true);
166 |
167 | }
168 | }
169 | });
170 |
171 | JMenuItem menuItem_1 = new JMenuItem("退出");
172 | menuItem_1.setMnemonic(KeyEvent.VK_Q);
173 | menuItem_1.setIcon(new ImageIcon(MainFrame.class
174 | .getResource("/images/exit.png")));
175 | menuItem_1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
176 | menu.add(menuItem_1);
177 | menuItem_1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
178 | Event.CTRL_MASK));
179 | menuItem_1.addActionListener(new ActionListener() {
180 | public void actionPerformed(ActionEvent e) {
181 | if (JOptionPane.showConfirmDialog(null, "确认退出?", "提示",
182 | JOptionPane.YES_NO_OPTION) == 0) {
183 | System.exit(0);
184 | }
185 | }
186 | });
187 |
188 |
189 | JMenu viewMenu = new JMenu("主题");
190 | menuBar.add(viewMenu);
191 | viewMenu.setIcon(new ImageIcon(MainFrame.class
192 | .getResource("/images/view.png")));
193 | ButtonGroup group = new ButtonGroup();
194 | JRadioButtonMenuItem v1 = new JRadioButtonMenuItem("Metal", true);
195 | v1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
196 | v1.setIcon(new ImageIcon(MainFrame.class.getResource("/images/edit.png")));
197 | viewMenu.add(v1);
198 | v1.addActionListener(new ActionListener() {
199 | public void actionPerformed(ActionEvent e) {
200 | try {
201 | UIManager
202 | .setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
203 | SwingUtilities.updateComponentTreeUI(frame);
204 | } catch (ClassNotFoundException | InstantiationException
205 | | IllegalAccessException
206 | | UnsupportedLookAndFeelException e1) {
207 | }
208 | }
209 | });
210 | JRadioButtonMenuItem v2 = new JRadioButtonMenuItem("Motif");
211 | v2.setFont(new Font("微软雅黑", Font.PLAIN, 15));
212 | v2.setIcon(new ImageIcon(MainFrame.class.getResource("/images/edit.png")));
213 | viewMenu.add(v2);
214 | v2.addActionListener(new ActionListener() {
215 | public void actionPerformed(ActionEvent e) {
216 | try {
217 | UIManager
218 | .setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
219 | SwingUtilities.updateComponentTreeUI(frame);
220 | } catch (ClassNotFoundException | InstantiationException
221 | | IllegalAccessException
222 | | UnsupportedLookAndFeelException e1) {
223 | }
224 | }
225 | });
226 | JRadioButtonMenuItem v3 = new JRadioButtonMenuItem("Windows");
227 | v3.setFont(new Font("微软雅黑", Font.PLAIN, 15));
228 | v3.setIcon(new ImageIcon(MainFrame.class.getResource("/images/edit.png")));
229 | viewMenu.add(v3);
230 | v3.addActionListener(new ActionListener() {
231 | public void actionPerformed(ActionEvent e) {
232 | try {
233 | UIManager
234 | .setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
235 | SwingUtilities.updateComponentTreeUI(frame);
236 | } catch (ClassNotFoundException | InstantiationException
237 | | IllegalAccessException
238 | | UnsupportedLookAndFeelException e1) {
239 | }
240 | }
241 | });
242 | JRadioButtonMenuItem v4 = new JRadioButtonMenuItem("Nimbus");
243 | v4.setFont(new Font("微软雅黑", Font.PLAIN, 15));
244 | v4.setIcon(new ImageIcon(MainFrame.class.getResource("/images/edit.png")));
245 | viewMenu.add(v4);
246 | v4.addActionListener(new ActionListener() {
247 | public void actionPerformed(ActionEvent e) {
248 | try {
249 | UIManager
250 | .setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
251 | SwingUtilities.updateComponentTreeUI(frame);
252 | } catch (ClassNotFoundException | InstantiationException
253 | | IllegalAccessException
254 | | UnsupportedLookAndFeelException e1) {
255 | }
256 | }
257 | });
258 | JRadioButtonMenuItem v5 = new JRadioButtonMenuItem("beautyeye");
259 | v5.setFont(new Font("微软雅黑", Font.PLAIN, 15));
260 | v5.setIcon(new ImageIcon(MainFrame.class.getResource("/images/edit.png")));
261 | viewMenu.add(v5);
262 | v5.addActionListener(new ActionListener() {
263 | public void actionPerformed(ActionEvent e) {
264 | try {
265 | BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.generalNoTranslucencyShadow;
266 | org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper
267 | .launchBeautyEyeLNF();
268 | UIManager.put("RootPane.setupButtonVisible", false);
269 | SwingUtilities.updateComponentTreeUI(frame);
270 | } catch (Exception e1) {
271 | }
272 | }
273 | });
274 | group.add(v1);
275 | group.add(v2);
276 | group.add(v3);
277 | group.add(v4);
278 | group.add(v5);
279 | viewMenu.add(v1);
280 | viewMenu.add(v2);
281 | viewMenu.add(v3);
282 | viewMenu.add(v4);
283 | viewMenu.add(v5);
284 |
285 |
286 | JMenu menu_3 = new JMenu("关于");
287 | menu_3.setIcon(new ImageIcon(MainFrame.class
288 | .getResource("/images/about.png")));
289 | menuBar.add(menu_3);
290 |
291 | JMenuItem menuItem_5 = new JMenuItem("帮助");
292 | menuItem_5.setMnemonic(KeyEvent.VK_F1);
293 | menuItem_5.setFont(new Font("微软雅黑", Font.PLAIN, 15));
294 | menuItem_5.setIcon(new ImageIcon(MainFrame.class
295 | .getResource("/images/me.png")));
296 | menu_3.add(menuItem_5);
297 | menuItem_5.setMnemonic(KeyEvent.VK_F1);
298 | menuItem_5.setAccelerator(KeyStroke
299 | .getKeyStroke(KeyEvent.VK_F1, 0));
300 | menuItem_5.addActionListener(new ActionListener() {
301 | public void actionPerformed(ActionEvent e) {
302 | JOptionPane.showMessageDialog(null, "人事管理系统:\n"
303 | + "在企业中,人事管理工作是非常重要的一项工作,它负责整个企业的日常人事安排,\n"
304 | + "人员的人事管理等。高效的人事管理可以提高企业的市场竞争力,使企业具有更强的凝\n" + "聚力和活力。"
305 | + "", "关于", 1);
306 | }
307 | });
308 |
309 | JPanel panel6 = new JPanel();
310 | panel6.setLayout(new BorderLayout());
311 |
312 |
313 | JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
314 | frame.getContentPane().add(panel6,BorderLayout.CENTER);
315 | panel6.add(tabbedPane,BorderLayout.CENTER);
316 |
317 |
318 | JToolBar toolBar = new JToolBar();
319 | panel6.add(toolBar, BorderLayout.NORTH);
320 |
321 | JButton btnNewButton_2 = new JButton("导出");
322 | btnNewButton_2.addActionListener(new ActionListener() {
323 | public void actionPerformed(ActionEvent e) {
324 | dealExportbtn();
325 | }
326 |
327 | });
328 | btnNewButton_2.setIcon(new ImageIcon(MainFrame.class.getResource("/images/saveHS.png")));
329 | toolBar.add(btnNewButton_2);
330 |
331 | JButton btnNewButton_3 = new JButton("打印");
332 | btnNewButton_3.addActionListener(new ActionListener() {
333 | public void actionPerformed(ActionEvent e) {
334 |
335 |
336 | }
337 | });
338 | btnNewButton_3.setIcon(new ImageIcon(MainFrame.class.getResource("/images/PrintHS.png")));
339 | toolBar.add(btnNewButton_3);
340 |
341 | JButton btnNewButton_4 = new JButton("打卡");
342 | btnNewButton_4.addActionListener(new ActionListener() {
343 | public void actionPerformed(ActionEvent e) {
344 | // dealTimeCard();
345 | }
346 | });
347 | btnNewButton_4.setIcon(new ImageIcon(MainFrame.class.getResource("/images/TimeCard.png")));
348 | toolBar.add(btnNewButton_4);
349 |
350 | JButton btnNewButton_5 = new JButton("计算器");
351 | btnNewButton_5.addActionListener(new ActionListener() {
352 | public void actionPerformed(ActionEvent e) {
353 | new tools.JCalculator();
354 | }
355 | });
356 | btnNewButton_5.setIcon(new ImageIcon(MainFrame.class.getResource("/images/CalculatorHS.png")));
357 | toolBar.add(btnNewButton_5);
358 |
359 | JButton btnNewButton_6 = new JButton("记事本");
360 | btnNewButton_6.addActionListener(new ActionListener() {
361 | public void actionPerformed(ActionEvent e) {
362 | new tools.JNotepad();
363 | }
364 | });
365 | btnNewButton_6.setIcon(new ImageIcon(MainFrame.class.getResource("/images/edit.png")));
366 | toolBar.add(btnNewButton_6);
367 |
368 | //状态栏
369 | statusLabel = new JLabel("");
370 | statusLabel.setBorder(BorderFactory.createEmptyBorder(5,30,5,5));
371 | statusLabel.setFont(new Font("微软雅黑", Font.PLAIN,15));
372 | toolBar.add(statusLabel);
373 |
374 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
375 | String time = df.format(new Date());
376 | TbPerson tPerson = PersonDao.findPersonByRecordNumber(userId);
377 | int personRoleId = tPerson.getRoleId();
378 | TbRole r = RoleDao.findRoleById(personRoleId);
379 | String personRole = r.getName();
380 | statusLabel.setText("员工ID:"+userId+" "+"用户权限:"+personRole+" "+"登陆时间:"+time);
381 | //tabbedPane, BorderLayout.CENTER
382 |
383 | JPanel panel = new JPanel();
384 | tabbedPane.addTab("员工管理", null, panel, null);
385 | panel.setLayout(new BorderLayout(0, 0));
386 |
387 | JPanel panel_3 = new JPanel();
388 | panel.add(panel_3, BorderLayout.NORTH);
389 |
390 | JButton addPersonButton = new JButton("增加");
391 | addPersonButton.addActionListener(new ActionListener() {
392 | public void actionPerformed(ActionEvent e) {
393 | addPersonButton_Do();
394 | }
395 | });
396 | panel_3.add(addPersonButton);
397 |
398 | JButton delPersonButton = new JButton("删除");
399 | delPersonButton.addActionListener(new ActionListener() {
400 | public void actionPerformed(ActionEvent e) {
401 | delPersonButton_Do();
402 | }
403 | });
404 | panel_3.add(delPersonButton);
405 |
406 | JButton updatePersonButton = new JButton("修改");
407 | updatePersonButton.addActionListener(new ActionListener() {
408 | public void actionPerformed(ActionEvent e) {
409 | updatePersonButton_Do();
410 | }
411 | });
412 | panel_3.add(updatePersonButton);
413 |
414 | JButton refreshPersonButton = new JButton("刷新");
415 | refreshPersonButton.addActionListener(new ActionListener() {
416 | public void actionPerformed(ActionEvent e) {
417 | refreshPersonButton_Do();
418 | }
419 | });
420 | panel_3.add(refreshPersonButton);
421 |
422 | JLabel label = new JLabel(" 行高");
423 | panel_3.add(label);
424 |
425 | JSlider rowHeightSlider = new JSlider(JSlider.HORIZONTAL, 5, 100, 40);
426 | rowHeightSlider.addChangeListener(new ChangeListener() {
427 | public void stateChanged(ChangeEvent e) {
428 | int height = ((JSlider)e.getSource()).getValue();
429 | table.setRowHeight(height);
430 | table.repaint();
431 | }
432 | });
433 | panel_3.add(rowHeightSlider);
434 |
435 | JLabel lblid = new JLabel(" 姓名或ID:");
436 | panel_3.add(lblid);
437 |
438 | nameOrIdField = new JTextField();
439 | panel_3.add(nameOrIdField);
440 | nameOrIdField.setColumns(10);
441 |
442 | JButton searchButton = new JButton("搜索");
443 | searchButton.addActionListener(new ActionListener() {
444 | public void actionPerformed(ActionEvent e) {
445 | searchButton_Do();
446 | }
447 | });
448 | panel_3.add(searchButton);
449 |
450 | JLabel label_1 = new JLabel(" 部门:");
451 | panel_3.add(label_1);
452 |
453 | deptComboBox = new JComboBox();
454 | panel_3.add(deptComboBox);
455 | deptComboBox.addItem("-全体人员-");
456 | List depts = DeptDao.findAllDept();
457 |
458 | for (int i = 1; i < depts.size(); i++) {
459 | TbDept d = depts.get(i);
460 | deptComboBox.addItem(d.getName());
461 | }
462 |
463 |
464 | deptComboBox.addItemListener(new ItemListener() {
465 | @Override
466 | public void itemStateChanged(ItemEvent e) {
467 | deptComboBox_itemStateChanged_Do(e);
468 | }
469 | });
470 |
471 | JScrollPane scrollPane = new JScrollPane();
472 | panel.add(scrollPane, BorderLayout.CENTER);
473 |
474 | table = new JTable(){public boolean isCellEditable(int row, int column) { return false; }};
475 | table.setRowHeight(40);
476 | table.setBorder(BorderFactory.createEtchedBorder());
477 | table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
478 |
479 | //表数据居中
480 | DefaultTableCellRenderer cr = new DefaultTableCellRenderer();
481 | cr.setHorizontalAlignment(JLabel.CENTER);
482 | table.setDefaultRenderer(Object.class, cr);
483 |
484 | //设置表头居中显示
485 | ((DefaultTableCellRenderer)table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(JLabel.CENTER);
486 |
487 | //添加单列排序功能
488 | table.setAutoCreateRowSorter(true);
489 | model = (DefaultTableModel) table.getModel();
490 | model.setColumnIdentifiers(new String[] {"ID","职工号","部门名","职务","姓名","性别","出生日期","身份证号","婚姻状况","籍贯","是否党员","学历","专业","外语","外语水平","状态","权限"});
491 | scrollPane.setViewportView(table);
492 |
493 | List persons = PersonDao.findAllPerson();
494 | for (TbPerson p:persons) {
495 | TbNativePlace np = NativePlaceDao.findNativePlaceById(p.getNativePlaceId());
496 | TbDept dept = DeptDao.findDeptById(p.getDeptId());
497 | TbDuty duty = DutyDao.findDutyById(p.getDutyId());
498 | TbRole role = RoleDao.findRoleById(p.getRoleId());
499 |
500 | String birthday;
501 | try {
502 | birthday = new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthday());
503 | } catch (NullPointerException e1) {
504 | System.out.println("日期格式转换出错");
505 | e1.printStackTrace();
506 | birthday = "";
507 | }
508 | model.addRow(new String[] {String.valueOf(p.getId()),p.getRecordNumber(),dept.getName(),duty.getName(),p.getName(),p.getSex(),birthday,p.getIdCard(),p.getMarriaged(),String.valueOf(np.getName()),p.getPartyMember(),p.getSchoolAge(),p.getSpecialty(),p.getForeignLanguage(),p.getGrade(),p.getState(),role.getName()});
509 | }
510 |
511 | JTableHeader header = table.getTableHeader();
512 | header.setFont(new Font("微软雅黑",Font.PLAIN,15));
513 | header.setPreferredSize(new Dimension(header.getWidth(),25));
514 |
515 | JPanel panel_1 = new JPanel();
516 | tabbedPane.addTab("部门管理", null, panel_1, null);
517 | panel_1.setLayout(new BorderLayout(0, 0));
518 |
519 | JPanel panel_6 = new JPanel();
520 | panel_1.add(panel_6, BorderLayout.NORTH);
521 |
522 | JButton button = new JButton("增加");
523 | button.addActionListener(new ActionListener() {
524 | public void actionPerformed(ActionEvent e) {
525 | addDeptButton_Do();
526 | }
527 | });
528 | panel_6.add(button);
529 |
530 | JButton button_1 = new JButton("删除");
531 | button_1.addActionListener(new ActionListener() {
532 | public void actionPerformed(ActionEvent e) {
533 | delDeptButton_Do();
534 | }
535 | });
536 | panel_6.add(button_1);
537 |
538 | JButton button_2 = new JButton("修改");
539 | button_2.addActionListener(new ActionListener() {
540 | public void actionPerformed(ActionEvent e) {
541 | updateDeptButton_Do();
542 | }
543 | });
544 | panel_6.add(button_2);
545 |
546 | JButton button_3 = new JButton("刷新");
547 | button_3.addActionListener(new ActionListener() {
548 | public void actionPerformed(ActionEvent e) {
549 | refreshDeptButton_Do();
550 | }
551 | });
552 | panel_6.add(button_3);
553 |
554 | JLabel label_6 = new JLabel(" 行高");
555 | panel_6.add(label_6);
556 |
557 | JSlider slider = new JSlider(SwingConstants.HORIZONTAL, 5, 100, 40);
558 | slider.addChangeListener(new ChangeListener() {
559 | public void stateChanged(ChangeEvent e) {
560 | int height = ((JSlider)e.getSource()).getValue();
561 | table_1.setRowHeight(height);
562 | table_1.repaint();
563 | }
564 | });
565 | panel_6.add(slider);
566 |
567 | JScrollPane scrollPane_1 = new JScrollPane();
568 | panel_1.add(scrollPane_1, BorderLayout.CENTER);
569 |
570 | table_1 = new JTable() {public boolean isCellEditable(int row, int column) {return false;}};
571 | table_1.setRowHeight(40);
572 | table_1.setBorder(BorderFactory.createEtchedBorder());
573 | table_1.setAutoCreateRowSorter(true);
574 | table_1.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
575 |
576 | //表数据居中
577 | DefaultTableCellRenderer cr2 = new DefaultTableCellRenderer();
578 | cr2.setHorizontalAlignment(JLabel.CENTER);
579 | table_1.setDefaultRenderer(Object.class, cr2);
580 |
581 | //设置表头居中显示
582 | ((DefaultTableCellRenderer)table_1.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(JLabel.CENTER);
583 |
584 | //添加单列排序功能
585 | table_1.setAutoCreateRowSorter(true);
586 | model2 = (DefaultTableModel) table_1.getModel();
587 | model2.setColumnIdentifiers(new String[] {"ID","部门名"});
588 | scrollPane_1.setViewportView(table_1);
589 |
590 | List deptss = DeptDao.findAllDeptExceptZero();
591 | for (TbDept dept:deptss) {
592 | model2.addRow(new String[] {String.valueOf(dept.getId()),dept.getName()});
593 | }
594 |
595 | JTableHeader header2 = table_1.getTableHeader();
596 | header2.setFont(new Font("微软雅黑",Font.PLAIN,15));
597 | header2.setPreferredSize(new Dimension(header2.getWidth(),25));
598 |
599 |
600 |
601 | JPanel panel_2 = new JPanel();
602 | tabbedPane.addTab("考勤登记", null, panel_2, null);
603 | panel_2.setLayout(null);
604 |
605 | JButton doTimecardButton = new JButton("执行");
606 | doTimecardButton.addActionListener(new ActionListener() {
607 | public void actionPerformed(ActionEvent e) {
608 | addTimecard_action();
609 | }
610 |
611 | });
612 | doTimecardButton.setBounds(428, 434, 266, 44);
613 | panel_2.add(doTimecardButton);
614 |
615 | timecardTypeComboBox = new JComboBox();
616 | timecardTypeComboBox.setBounds(428, 62, 266, 44);
617 | timecardTypeComboBox.setToolTipText("");
618 | List accounts = AccountDao.findAllAccount();
619 | for (TbAccount a:accounts) {
620 | timecardTypeComboBox.addItem(a.getName());
621 | }
622 | panel_2.add(timecardTypeComboBox);
623 |
624 | explainTextField = new JTextField();
625 | explainTextField.setBounds(430, 286, 797, 117);
626 | panel_2.add(explainTextField);
627 | explainTextField.setColumns(10);
628 |
629 | JLabel label_2 = new JLabel("考勤类型:");
630 | label_2.setBounds(319, 77, 99, 18);
631 | panel_2.add(label_2);
632 |
633 | JLabel label_3 = new JLabel("说明:");
634 | label_3.setBounds(342, 301, 72, 18);
635 | panel_2.add(label_3);
636 |
637 | JLabel label_4 = new JLabel("时间:");
638 | label_4.setBounds(873, 75, 72, 18);
639 | panel_2.add(label_4);
640 |
641 | timecardTimeTextField = new JTextField();
642 | timecardTimeTextField.setBounds(961, 62, 266, 44);
643 |
644 | timecardTimeTextField.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
645 | panel_2.add(timecardTimeTextField);
646 | timecardTimeTextField.setColumns(10);
647 |
648 | JLabel label_5 = new JLabel("审批人工号:");
649 | label_5.setBounds(838, 179, 113, 18);
650 | panel_2.add(label_5);
651 |
652 | JLabel lblid_1 = new JLabel("员工编号:");
653 | lblid_1.setBounds(319, 179, 101, 18);
654 | panel_2.add(lblid_1);
655 |
656 | personIdComboBox = new JComboBox();
657 | personIdComboBox.setBounds(428, 166, 266, 44);
658 | List personss = PersonDao.findAllPerson();
659 | for (TbPerson p:personss) {
660 | personIdComboBox.addItem(p.getRecordNumber());
661 | }
662 | panel_2.add(personIdComboBox);
663 |
664 | ratifierIdComboBox = new JComboBox();
665 | ratifierIdComboBox.setBounds(961, 166, 266, 44);
666 | for (TbPerson p:personss) {
667 | ratifierIdComboBox.addItem(p.getRecordNumber());
668 | }
669 | panel_2.add(ratifierIdComboBox);
670 |
671 |
672 | JPanel panel_5 = new JPanel();
673 | tabbedPane.addTab("工资管理", null, panel_5, null);
674 | panel_5.setLayout(new BorderLayout(0, 0));
675 |
676 | JPanel panel_7 = new JPanel();
677 | panel_5.add(panel_7, BorderLayout.NORTH);
678 |
679 | JButton button_7 = new JButton("刷新");
680 | button_7.addActionListener(new ActionListener() {
681 | public void actionPerformed(ActionEvent e) {
682 | model3.setRowCount(0);
683 | List personssss = PersonDao.findAllPerson();
684 | for (TbPerson p:personssss) {
685 | TbDept dept = DeptDao.findDeptById(p.getDeptId());
686 | int a1 = TimecardDao.findTimecardCountByPersonId(1,p.getRecordNumber());
687 | int a2 = TimecardDao.findTimecardCountByPersonId(2,p.getRecordNumber());
688 | int a3 = TimecardDao.findTimecardCountByPersonId(3,p.getRecordNumber());
689 | int a4 = TimecardDao.findTimecardCountByPersonId(4,p.getRecordNumber());
690 | String money1 = String.valueOf(a1 * Integer.valueOf(AccountDao.findAccountMoneyById(1)));
691 | String money2 = String.valueOf(a2 * Integer.valueOf(AccountDao.findAccountMoneyById(2)));
692 | String money3 = String.valueOf(a3 * Integer.valueOf(AccountDao.findAccountMoneyById(3)));
693 | String money4 = String.valueOf(a4 * Integer.valueOf(AccountDao.findAccountMoneyById(4)));
694 | int count = 3000 + Integer.parseInt(money1) - Integer.parseInt(money2) - Integer.parseInt(money3) + Integer.parseInt(money4);
695 | String count1 = String.valueOf(count);
696 | model3.addRow(new String[] {p.getRecordNumber(),p.getName(),dept.getName(),"3000",money1,money4,money2,money3,count1});
697 | }
698 | }
699 | });
700 | panel_7.add(button_7);
701 |
702 | JLabel label_7 = new JLabel(" 行高");
703 | panel_7.add(label_7);
704 |
705 | JSlider slider_1 = new JSlider(SwingConstants.HORIZONTAL, 5, 100, 40);
706 | slider_1.addChangeListener(new ChangeListener() {
707 | public void stateChanged(ChangeEvent e) {
708 | int height = ((JSlider)e.getSource()).getValue();
709 | table_2.setRowHeight(height);
710 | table_2.repaint();
711 | }
712 | });
713 | panel_7.add(slider_1);
714 |
715 | JLabel label_8 = new JLabel(" 姓名或ID:");
716 | panel_7.add(label_8);
717 |
718 | textField = new JTextField();
719 | textField.setColumns(10);
720 | panel_7.add(textField);
721 |
722 | JButton button_8 = new JButton("搜索");
723 | button_8.addActionListener(new ActionListener() {
724 | public void actionPerformed(ActionEvent e) {
725 | //判断nameOrIdField只包含字母和数字就根据recordNumber查找
726 | Boolean isLetterDigit = textField.getText().matches("^[a-z0-9A-Z]+$");
727 | if(isLetterDigit==true) {
728 | model3.setRowCount(0);
729 | List personss = PersonDao.likePersonByRecordNumber(textField.getText().trim());
730 | for (TbPerson p:personss) {
731 | TbDept dept = DeptDao.findDeptById(p.getDeptId());
732 | int a1 = TimecardDao.findTimecardCountByPersonId(1,p.getRecordNumber());
733 | int a2 = TimecardDao.findTimecardCountByPersonId(2,p.getRecordNumber());
734 | int a3 = TimecardDao.findTimecardCountByPersonId(3,p.getRecordNumber());
735 | int a4 = TimecardDao.findTimecardCountByPersonId(4,p.getRecordNumber());
736 | String money1 = String.valueOf(a1 * Integer.valueOf(AccountDao.findAccountMoneyById(1)));
737 | String money2 = String.valueOf(a2 * Integer.valueOf(AccountDao.findAccountMoneyById(2)));
738 | String money3 = String.valueOf(a3 * Integer.valueOf(AccountDao.findAccountMoneyById(3)));
739 | String money4 = String.valueOf(a4 * Integer.valueOf(AccountDao.findAccountMoneyById(4)));
740 | int count = 3000 + Integer.parseInt(money1) - Integer.parseInt(money2) - Integer.parseInt(money3) + Integer.parseInt(money4);
741 | String count1 = String.valueOf(count);
742 | model3.addRow(new String[] {p.getRecordNumber(),p.getName(),dept.getName(),"3000",money1,money4,money2,money3,count1});
743 | }
744 | }
745 | }
746 | });
747 | panel_7.add(button_8);
748 |
749 | JScrollPane scrollPane_2 = new JScrollPane();
750 | panel_5.add(scrollPane_2, BorderLayout.CENTER);
751 |
752 | table_2 = new JTable() {public boolean isCellEditable(int row, int column) {return false;}};
753 | table_2.setRowHeight(40);
754 | table_2.setBorder(BorderFactory.createEtchedBorder());
755 | table_2.setAutoCreateRowSorter(true);
756 | scrollPane_2.setViewportView(table_2);
757 |
758 | table_2.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
759 |
760 | //表数据居中
761 | DefaultTableCellRenderer cr3 = new DefaultTableCellRenderer();
762 | cr3.setHorizontalAlignment(JLabel.CENTER);
763 | table_2.setDefaultRenderer(Object.class, cr3);
764 |
765 | //设置表头居中显示
766 | ((DefaultTableCellRenderer)table_2.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(JLabel.CENTER);
767 |
768 | //添加单列排序功能
769 | table_2.setAutoCreateRowSorter(true);
770 | model3 = (DefaultTableModel) table_2.getModel();
771 | model3.setColumnIdentifiers(new String[] {"员工编号","姓名","部门","基本工资","加班","值班","迟到","早退","总工资"});
772 |
773 | List personssss = PersonDao.findAllPerson();
774 | for (TbPerson p:personssss) {
775 | TbDept dept = DeptDao.findDeptById(p.getDeptId());
776 | int a1 = TimecardDao.findTimecardCountByPersonId(1,p.getRecordNumber());
777 | int a2 = TimecardDao.findTimecardCountByPersonId(2,p.getRecordNumber());
778 | int a3 = TimecardDao.findTimecardCountByPersonId(3,p.getRecordNumber());
779 | int a4 = TimecardDao.findTimecardCountByPersonId(4,p.getRecordNumber());
780 | String money1 = String.valueOf(a1 * Integer.valueOf(AccountDao.findAccountMoneyById(1)));
781 | String money2 = String.valueOf(a2 * Integer.valueOf(AccountDao.findAccountMoneyById(2)));
782 | String money3 = String.valueOf(a3 * Integer.valueOf(AccountDao.findAccountMoneyById(3)));
783 | String money4 = String.valueOf(a4 * Integer.valueOf(AccountDao.findAccountMoneyById(4)));
784 | int count = 3000 + Integer.parseInt(money1) - Integer.parseInt(money2) - Integer.parseInt(money3) + Integer.parseInt(money4);
785 | String count1 = String.valueOf(count);
786 | model3.addRow(new String[] {p.getRecordNumber(),p.getName(),dept.getName(),"3000",money1,money4,money2,money3,count1});
787 | }
788 |
789 | JTableHeader header3 = table_2.getTableHeader();
790 | header3.setFont(new Font("微软雅黑",Font.PLAIN,15));
791 | header3.setPreferredSize(new Dimension(header3.getWidth(),25));
792 |
793 |
794 |
795 |
796 |
797 | // panel_5.add(table_2, BorderLayout.WEST);
798 |
799 | JPanel panel_4 = new JPanel();
800 | tabbedPane.addTab("系统管理", null, panel_4, null);
801 |
802 | JPopupMenu m_popupMenu = new JPopupMenu();
803 | JMenuItem refreshMenItem = new JMenuItem(" 刷新 ");
804 | refreshMenItem.setIcon(new ImageIcon(MainFrame.class.getResource("/images/refresh.png")));
805 | refreshMenItem.setMnemonic(KeyEvent.VK_F5);
806 | refreshMenItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
807 | refreshMenItem.addActionListener(new java.awt.event.ActionListener() {
808 | public void actionPerformed(java.awt.event.ActionEvent evt) {
809 | refreshPersonButton_Do();
810 | }
811 | });
812 | lookMenItem = new JMenuItem(" 查看 ");
813 | lookMenItem.setIcon(new ImageIcon(MainFrame.class.getResource("/images/ActualSizeHS.png")));
814 | lookMenItem.addActionListener(new java.awt.event.ActionListener() {
815 | public void actionPerformed(ActionEvent evt) {
816 | PersonInfoFrame pl = new PersonInfoFrame(recordNumber);
817 | pl.setVisible(true);
818 | }
819 | });
820 |
821 | JMenuItem deleteMenItem = new JMenuItem(" 删除 ");
822 | deleteMenItem.setIcon(new ImageIcon(MainFrame.class.getResource("/images/delete.png")));
823 | deleteMenItem.addActionListener(new java.awt.event.ActionListener() {
824 | public void actionPerformed(java.awt.event.ActionEvent evt) {
825 | delPersonButton_Do();
826 | }
827 | });
828 |
829 | m_popupMenu.add(refreshMenItem);
830 | m_popupMenu.add(lookMenItem);
831 | m_popupMenu.add(deleteMenItem);
832 |
833 |
834 | table.addMouseListener(new MouseAdapter(){
835 | public void mouseClicked(MouseEvent e){
836 | if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
837 | int focusedRowIndex = table.rowAtPoint(e.getPoint());
838 | if (focusedRowIndex == -1) {
839 | return;
840 | }
841 | //将表格所选项设为当前右键点击的行
842 | table.setRowSelectionInterval(focusedRowIndex, focusedRowIndex);
843 | int row = table.getSelectedRow();
844 | recordNumber = (String)table.getValueAt(row,1);
845 | //弹出菜单
846 | m_popupMenu.show(table, e.getX(), e.getY());
847 | }
848 | if(e.getClickCount()==2 && e.getButton() == MouseEvent.BUTTON1){
849 | int focusedRowIndex = table.rowAtPoint(e.getPoint());
850 | if (focusedRowIndex == -1) {
851 | return;
852 | }
853 | table.setRowSelectionInterval(focusedRowIndex, focusedRowIndex);
854 | int row = table.getSelectedRow();
855 | recordNumber = (String)table.getValueAt(row,1);
856 | PersonInfoFrame pl = new PersonInfoFrame(recordNumber);
857 | pl.setVisible(true);
858 |
859 | }
860 | }
861 | });
862 | }
863 |
864 | private void addPersonButton_Do() {
865 | AddPersonInfoFrame addPersonInfoFrame = new AddPersonInfoFrame();
866 | addPersonInfoFrame.setVisible(true);
867 | }
868 |
869 | private void addDeptButton_Do() {
870 | String inputValue = JOptionPane.showInputDialog("请输入部门名");
871 | TbDept d = DeptDao.findDeptByName(inputValue.trim());
872 | if(d!=null){
873 | JOptionPane.showMessageDialog(null, "已存在该部门!");
874 | }else{
875 | TbDept d2 = new TbDept();
876 | d2.setName(inputValue);
877 | DeptDao.addDept(d2);
878 | JOptionPane.showMessageDialog(null, "添加成功!");
879 | refreshDeptButton_Do();
880 | }
881 | }
882 |
883 | private void delPersonButton_Do() {
884 | int row = table.getSelectedRow();
885 | if(row == -1) {
886 | JOptionPane.showMessageDialog(null, "请先从表格中选中一行员工信息!");
887 | }else {
888 | recordNumber = (String)table.getValueAt(row,1);
889 | int value = JOptionPane.showConfirmDialog(null,"你确认删除选中员工吗?","",JOptionPane.YES_NO_OPTION);
890 | if (value==JOptionPane.YES_OPTION) {
891 | PersonDao.deletePersonByrecordNumber(recordNumber);
892 | refreshPersonButton_Do();
893 | }else {
894 | }
895 | }
896 |
897 | }
898 |
899 | private void delDeptButton_Do() {
900 | int row = table_1.getSelectedRow();
901 | if(row == -1) {
902 | JOptionPane.showMessageDialog(null, "请先从表格中选中一行部门信息!");
903 | }else {
904 | int id = Integer.parseInt((String)table_1.getValueAt(row,0));
905 | int value = JOptionPane.showConfirmDialog(null,"你确认删除选中部门吗?","",JOptionPane.YES_NO_OPTION);
906 | if (value==JOptionPane.YES_OPTION) {
907 | DeptDao.deleteDeptById(id);
908 | refreshDeptButton_Do();
909 | }else {
910 | }
911 | }
912 |
913 | }
914 |
915 | private void updatePersonButton_Do() {
916 | int row = table.getSelectedRow();
917 | if(row == -1) {
918 | JOptionPane.showMessageDialog(null, "请先从表格中选中一行员工信息!");
919 | }else {
920 | recordNumber = (String)table.getValueAt(row,1);
921 | PersonInfoFrame pl = new PersonInfoFrame(recordNumber);
922 | pl.setVisible(true);
923 | }
924 | }
925 |
926 | private void updateDeptButton_Do() {
927 | int row = table_1.getSelectedRow();
928 | if(row == -1) {
929 | JOptionPane.showMessageDialog(null, "请先从表格中选中一行员工信息!");
930 | }else {
931 | String input = JOptionPane.showInputDialog("请输入修改后的部门名");
932 | if (input == null) {
933 |
934 | } else {
935 | int id = Integer.parseInt((String)table_1.getValueAt(row,0));
936 | DeptDao.updateDept(id,input);
937 | JOptionPane.showMessageDialog(null, "修改成功!");
938 | refreshDeptButton_Do();
939 | }
940 |
941 | }
942 | }
943 |
944 | private void refreshPersonButton_Do() {
945 | deptComboBox.setSelectedIndex(0);
946 | model.setRowCount(0);
947 | List personss = PersonDao.findAllPerson();
948 | for (TbPerson p:personss) {
949 | TbNativePlace np = NativePlaceDao.findNativePlaceById(p.getNativePlaceId());
950 | TbDept dept = DeptDao.findDeptById(p.getDeptId());
951 | TbDuty duty = DutyDao.findDutyById(p.getDutyId());
952 | TbRole role = RoleDao.findRoleById(p.getRoleId());
953 | String birthday;
954 | try {
955 | birthday = new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthday());
956 | } catch (Exception e) {
957 | System.out.println("日期格式转换出错");
958 | birthday = "";
959 | e.printStackTrace();
960 | }
961 | model.addRow(new String[] {String.valueOf(p.getId()),p.getRecordNumber(),dept.getName(),duty.getName(),p.getName(),p.getSex(),birthday,p.getIdCard(),p.getMarriaged(),String.valueOf(np.getName()),p.getPartyMember(),p.getSchoolAge(),p.getSpecialty(),p.getForeignLanguage(),p.getGrade(),p.getState(),role.getName()});
962 | }
963 | }
964 |
965 | private void searchButton_Do() {
966 | //判断nameOrIdField只包含字母和数字就根据recordNumber查找
967 | Boolean isLetterDigit = nameOrIdField.getText().matches("^[a-z0-9A-Z]+$");
968 | if(isLetterDigit==true) {
969 | model.setRowCount(0);
970 | List personss = PersonDao.likePersonByRecordNumber(nameOrIdField.getText().trim());
971 | for (TbPerson p:personss) {
972 | TbNativePlace np = NativePlaceDao.findNativePlaceById(p.getNativePlaceId());
973 | TbDept dept = DeptDao.findDeptById(p.getDeptId());
974 | TbDuty duty = DutyDao.findDutyById(p.getDutyId());
975 | TbRole role = RoleDao.findRoleById(p.getRoleId());
976 | String birthday;
977 | try {
978 | birthday = new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthday());
979 | } catch (Exception e) {
980 | System.out.println("日期格式转换出错");
981 | birthday = "";
982 | e.printStackTrace();
983 | }
984 | model.addRow(new String[] {String.valueOf(p.getId()),p.getRecordNumber(),dept.getName(),duty.getName(),p.getName(),p.getSex(),birthday,p.getIdCard(),p.getMarriaged(),String.valueOf(np.getName()),p.getPartyMember(),p.getSchoolAge(),p.getSpecialty(),p.getForeignLanguage(),p.getGrade(),p.getState(),role.getName()});
985 | }
986 | }else {
987 | model.setRowCount(0);
988 | List personss = PersonDao.likePersonByName(nameOrIdField.getText().trim());
989 | for (TbPerson p:personss) {
990 | TbNativePlace np = NativePlaceDao.findNativePlaceById(p.getNativePlaceId());
991 | TbDept dept = DeptDao.findDeptById(p.getDeptId());
992 | TbDuty duty = DutyDao.findDutyById(p.getDutyId());
993 | TbRole role = RoleDao.findRoleById(p.getRoleId());
994 | String birthday;
995 | try {
996 | birthday = new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthday());
997 | } catch (Exception e) {
998 | System.out.println("日期格式转换出错");
999 | birthday = "";
1000 | e.printStackTrace();
1001 | }
1002 | model.addRow(new String[] {String.valueOf(p.getId()),p.getRecordNumber(),dept.getName(),duty.getName(),p.getName(),p.getSex(),birthday,p.getIdCard(),p.getMarriaged(),String.valueOf(np.getName()),p.getPartyMember(),p.getSchoolAge(),p.getSpecialty(),p.getForeignLanguage(),p.getGrade(),p.getState(),role.getName()});
1003 | }
1004 | }
1005 | }
1006 |
1007 | private void deptComboBox_itemStateChanged_Do(ItemEvent e) {
1008 | if (e.getStateChange() == ItemEvent.SELECTED) {
1009 | System.out.println(e.getItem());
1010 | //如果deptComboBox.selectvalue为-全体人员-那么查找所有人
1011 | if("-全体人员-".equals(e.getItem())) {
1012 | model.setRowCount(0);
1013 | List personss = PersonDao.findAllPerson();
1014 | for (TbPerson p:personss) {
1015 | TbNativePlace np = NativePlaceDao.findNativePlaceById(p.getNativePlaceId());
1016 | TbDept dept = DeptDao.findDeptById(p.getDeptId());
1017 | TbDuty duty = DutyDao.findDutyById(p.getDutyId());
1018 | TbRole role = RoleDao.findRoleById(p.getRoleId());
1019 | String birthday;
1020 | try {
1021 | birthday = new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthday());
1022 | } catch (Exception e2) {
1023 | System.out.println("日期格式转换出错");
1024 | birthday = "";
1025 | e2.printStackTrace();
1026 | }
1027 | model.addRow(new String[] {String.valueOf(p.getId()),p.getRecordNumber(),dept.getName(),duty.getName(),p.getName(),p.getSex(),birthday,p.getIdCard(),p.getMarriaged(),String.valueOf(np.getName()),p.getPartyMember(),p.getSchoolAge(),p.getSpecialty(),p.getForeignLanguage(),p.getGrade(),p.getState(),role.getName()});
1028 | }
1029 | }else {
1030 | model.setRowCount(0);
1031 | List personss = PersonDao.findPersonByDeptId(deptComboBox.getSelectedIndex());
1032 | for (TbPerson p:personss) {
1033 | TbNativePlace np = NativePlaceDao.findNativePlaceById(p.getNativePlaceId());
1034 | TbDept dept = DeptDao.findDeptById(p.getDeptId());
1035 | TbDuty duty = DutyDao.findDutyById(p.getDutyId());
1036 | TbRole role = RoleDao.findRoleById(p.getRoleId());
1037 | model.addRow(new String[] {String.valueOf(p.getId()),p.getRecordNumber(),dept.getName(),duty.getName(),p.getName(),p.getSex(),new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthday()),p.getIdCard(),p.getMarriaged(),String.valueOf(np.getName()),p.getPartyMember(),p.getSchoolAge(),p.getSpecialty(),p.getForeignLanguage(),p.getGrade(),p.getState(),role.getName()});
1038 | }
1039 | }
1040 |
1041 | }
1042 | }
1043 |
1044 | private void refreshDeptButton_Do() {
1045 | model2.setRowCount(0);
1046 | List deptss = DeptDao.findAllDeptExceptZero();
1047 | for (TbDept dept:deptss) {
1048 | model2.addRow(new String[] {String.valueOf(dept.getId()),dept.getName()});
1049 | }
1050 | }
1051 |
1052 |
1053 | //考勤登记
1054 | private void addTimecard_action() {
1055 | int type = timecardTypeComboBox.getSelectedIndex()+1;
1056 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
1057 | Date timecardDate;
1058 | try {
1059 | timecardDate = sdf.parse(timecardTimeTextField.getText());
1060 | String personId = (String) personIdComboBox.getSelectedItem();
1061 | String raId = (String) ratifierIdComboBox.getSelectedItem();
1062 | String explain = explainTextField.getText();
1063 | System.out.println(type +" "+timecardDate+" "+personId+" "+raId+" "+explain);
1064 | TbTimecard tc = new TbTimecard(type,personId,timecardDate,raId,explain);
1065 | TimecardDao.addTimecard(tc);
1066 | JOptionPane.showMessageDialog(null, "执行成功!");
1067 |
1068 | } catch (ParseException e) {
1069 | JOptionPane.showMessageDialog(null, "日期格式出错");
1070 | e.printStackTrace();
1071 | }
1072 | }
1073 |
1074 | //导出
1075 | protected void dealExportbtn() {
1076 | // try {
1077 | // SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
1078 | // String time = df.format(new Date());
1079 | // String str = JOptionPane.showInputDialog(null, "输入导出路径(不包含文件名),路径之间用\\\\标识:", "KEY",2);
1080 | // if(str==null){
1081 | // return;
1082 | // }else{
1083 | // tools.IoUtil.exportTable(table,new File(str+"EmployeeTable-"+time+".xls"));
1084 | // JOptionPane.showMessageDialog(null, "成功导出文件:"+str+"EmployeeTable-"+time+".xls");
1085 | // }
1086 | // } catch (IOException e) {
1087 | // e.printStackTrace();
1088 | // JOptionPane.showMessageDialog(null, "导出表格文件出错!");
1089 | // }
1090 |
1091 | try {
1092 |
1093 | JFileChooser fileChooser = new JFileChooser();
1094 | fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
1095 | fileChooser.showSaveDialog(frame);//显示保存对话框
1096 | String fi = fileChooser.getSelectedFile().getAbsolutePath()+".xls";
1097 | System.out.println(fi);
1098 | // FileWriter out = new FileWriter(fi);//新建输出
1099 | BufferedWriter writer = new BufferedWriter (new OutputStreamWriter(new FileOutputStream (fi,true),"GBK"));
1100 | for (int i = 0; i < table.getColumnCount(); i++) {
1101 | writer.write(table.getColumnName(i) + "\t");
1102 | }
1103 | writer.write("\n");
1104 | for (int i = 0; i < table.getRowCount(); i++) {
1105 | for (int j = 0; j < table.getColumnCount(); j++) {
1106 | try {
1107 | writer.write(table.getValueAt(i, j).toString() + "\t");
1108 | // System.out.println(table.getValueAt(i, j).toString());
1109 | } catch (NullPointerException e) {
1110 | writer.write(""+"\t");
1111 | e.printStackTrace();
1112 | }
1113 | }
1114 | writer.write("\n");
1115 | }
1116 | writer.close();
1117 | JOptionPane.showMessageDialog(null, "文件导出成功");
1118 | } catch (Exception ee) {
1119 | ee.printStackTrace();
1120 | }
1121 |
1122 | }
1123 | }
1124 |
--------------------------------------------------------------------------------
/src/view/PersonInfoFrame.java:
--------------------------------------------------------------------------------
1 | package view;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.EventQueue;
5 | import java.awt.Font;
6 | import java.awt.Image;
7 | import java.awt.Toolkit;
8 | import java.awt.event.ActionEvent;
9 | import java.awt.event.ActionListener;
10 | import java.awt.event.KeyEvent;
11 | import java.awt.event.KeyListener;
12 | import java.awt.event.MouseAdapter;
13 | import java.awt.event.MouseEvent;
14 | import java.io.File;
15 | import java.io.FileInputStream;
16 | import java.io.FileOutputStream;
17 | import java.io.InputStream;
18 | import java.io.OutputStream;
19 | import java.net.URL;
20 | import java.text.DateFormat;
21 | import java.text.SimpleDateFormat;
22 | import java.util.Date;
23 | import java.util.List;
24 |
25 | import javax.swing.ButtonGroup;
26 | import javax.swing.ImageIcon;
27 | import javax.swing.JButton;
28 | import javax.swing.JComboBox;
29 | import javax.swing.JComponent;
30 | import javax.swing.JFileChooser;
31 | import javax.swing.JFrame;
32 | import javax.swing.JLabel;
33 | import javax.swing.JOptionPane;
34 | import javax.swing.JPanel;
35 | import javax.swing.JRadioButton;
36 | import javax.swing.JTextField;
37 | import javax.swing.KeyStroke;
38 | import javax.swing.SwingConstants;
39 | import javax.swing.border.EmptyBorder;
40 | import javax.swing.border.TitledBorder;
41 |
42 | import model.TbDept;
43 | import model.TbDuty;
44 | import model.TbNativePlace;
45 | import model.TbPerson;
46 | import model.TbRole;
47 | import dao.DeptDao;
48 | import dao.DutyDao;
49 | import dao.NativePlaceDao;
50 | import dao.PersonDao;
51 | import dao.RoleDao;
52 |
53 | public class PersonInfoFrame extends JFrame {
54 |
55 | private JPanel contentPane;
56 | private JTextField nameField;
57 | private JTextField birthdayField;
58 | private JTextField idCardField;
59 | private JTextField schoolAgeField;
60 | private JTextField specialtyField;
61 | private JTextField foreignLanguageField;
62 | private JTextField gradeField;
63 | private JTextField stateField;
64 | private JTextField roleField;
65 | private File file;
66 | private int selectPhotoFlag = 0;
67 |
68 | public static void main(String[] args) {
69 | EventQueue.invokeLater(new Runnable() {
70 | public void run() {
71 | try {
72 | PersonInfoFrame frame = new PersonInfoFrame();
73 | frame.setVisible(true);
74 |
75 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
76 | Dimension frameSize = frame.getSize();
77 | if (frameSize.height > screenSize.height) {
78 | frameSize.height = screenSize.height;
79 | }
80 | if (frameSize.width > screenSize.width) {
81 | frameSize.width = screenSize.width;
82 | }
83 | frame.setLocation((screenSize.width - frameSize.width) / 2,
84 | (screenSize.height - frameSize.height) / 2);
85 |
86 | } catch (Exception e) {
87 | e.printStackTrace();
88 | }
89 | }
90 | });
91 | }
92 |
93 | public PersonInfoFrame() {
94 | }
95 |
96 | public PersonInfoFrame(String recordNumber) {
97 | //初始化时通过前页面传过来的recordNumber查询到这个TbPerson对象,然后初始化表单。
98 | TbPerson p = PersonDao.queryRecordByNum(recordNumber);
99 | setResizable(false);
100 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
101 | setBounds(100, 100, 896, 611);
102 | setTitle("查看/修改员工信息");
103 | contentPane = new JPanel();
104 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
105 | setContentPane(contentPane);
106 | contentPane.setLayout(null);
107 |
108 | JLabel lblt = new JLabel("员工编号:");
109 | lblt.setFont(new Font("微软雅黑", Font.PLAIN, 18));
110 | lblt.setBounds(36, 32, 98, 41);
111 | contentPane.add(lblt);
112 |
113 | JLabel recordNumberLabel = new JLabel();
114 | recordNumberLabel.setText(recordNumber);
115 | recordNumberLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
116 | recordNumberLabel.setBounds(140, 32, 138, 41);
117 | contentPane.add(recordNumberLabel);
118 |
119 | JLabel photoLabel = new JLabel();
120 | photoLabel.setBounds(665, 65, 120, 166);
121 | contentPane.add(photoLabel);
122 | photoLabel.setHorizontalAlignment(SwingConstants.CENTER);// 设置照片或文字居中显示
123 | photoLabel.setBorder(new TitledBorder(null, "",
124 | TitledBorder.DEFAULT_JUSTIFICATION,
125 | TitledBorder.DEFAULT_POSITION, null, null));// 设置边框
126 | photoLabel.setPreferredSize(new Dimension(120, 166));// 设置显示照片的大小
127 | photoLabel.addMouseListener(new MouseAdapter() {// 添加鼠标监听器
128 | public void mouseClicked(MouseEvent e) {
129 | if (e.getClickCount() == 2) {// 判断是否为双击
130 | JFileChooser fileChooser = new JFileChooser();// 创建文件选取对话框
131 | fileChooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
132 |
133 | @Override
134 | public String getDescription() {
135 | return "图像文件(.jpg;.gif)";
136 | }
137 |
138 | @Override
139 | public boolean accept(File file) {
140 | if (file.isDirectory())// 为文件夹则返回true
141 | return true;
142 | String fileName = file.getName()
143 | .toLowerCase();
144 | if (fileName.endsWith(".jpg") || fileName.endsWith(".gif"))// 为JPG或JIF格式文件则返回true
145 | return true;
146 | return false;// 否则返回false,即不显示在文件选取对话框中
147 | }
148 | });
149 | int i = fileChooser.showOpenDialog(getParent());// 弹出文件选取对话框并接收用户的处理信息
150 | if (i == fileChooser.APPROVE_OPTION) {// 用户选取了照片
151 | file = fileChooser.getSelectedFile();// 获得用户选取的文件对象
152 | selectPhotoFlag = 1;
153 | if (file != null) {
154 | ImageIcon icon = new ImageIcon(file
155 | .getAbsolutePath());// 创建照片对象
156 | photoLabel.setText(null);// 取消提示文字
157 | photoLabel.setIcon(icon);// 显示照片
158 | }
159 | }
160 | }
161 | }
162 | });
163 |
164 | JPanel deptFramePanel = new JPanel();
165 | deptFramePanel.setBorder(new TitledBorder(null, "所属部门",
166 |
167 |
168 | TitledBorder.DEFAULT_JUSTIFICATION,
169 |
170 |
171 | TitledBorder.DEFAULT_POSITION, null, null));
172 | deptFramePanel.setBounds(36, 86, 242, 70);
173 | contentPane.add(deptFramePanel);
174 |
175 | JComboBox deptComboBox = new JComboBox();
176 | deptFramePanel.add(deptComboBox);
177 | deptComboBox.setToolTipText("");
178 | List depts = DeptDao.findAllDept();
179 | for (TbDept d:depts) {
180 | deptComboBox.addItem(d.getName());
181 | }
182 |
183 | JPanel dutyFramePanel = new JPanel();
184 | dutyFramePanel.setBorder(new TitledBorder(null, "职位",TitledBorder.DEFAULT_JUSTIFICATION,
185 | TitledBorder.DEFAULT_POSITION, null, null));
186 | dutyFramePanel.setBounds(36, 169, 242, 70);
187 | contentPane.add(dutyFramePanel);
188 |
189 | JComboBox dutyComboBox = new JComboBox();
190 | List dutys = DutyDao.findAllDuty();
191 | for (TbDuty d:dutys) {
192 | dutyComboBox.addItem(d.getName());
193 | }
194 | dutyFramePanel.add(dutyComboBox);
195 |
196 | JLabel nameLabel = new JLabel("姓名:");
197 | nameLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
198 | nameLabel.setBounds(67, 291, 56, 18);
199 | contentPane.add(nameLabel);
200 |
201 | JPanel sexFramePanel = new JPanel();
202 | sexFramePanel.setBounds(302, 32, 242, 70);
203 | sexFramePanel.setBorder(new TitledBorder(null, "性别",
204 | TitledBorder.DEFAULT_JUSTIFICATION,
205 | TitledBorder.DEFAULT_POSITION, null, null));
206 | contentPane.add(sexFramePanel);
207 |
208 |
209 |
210 | JRadioButton nanRadioButton = new JRadioButton("男");
211 | sexFramePanel.add(nanRadioButton);
212 |
213 | JRadioButton nvRadioButton = new JRadioButton("女");
214 | sexFramePanel.add(nvRadioButton);
215 |
216 | ButtonGroup sexGroup=new ButtonGroup();
217 | sexGroup.add(nanRadioButton);
218 | sexGroup.add(nvRadioButton);
219 |
220 | nameField = new JTextField();
221 | nameField.setBounds(122, 286, 156, 30);
222 | contentPane.add(nameField);
223 | nameField.setColumns(10);
224 |
225 | JLabel birthdayLabel = new JLabel("出生日期:");
226 | birthdayLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
227 | birthdayLabel.setBounds(36, 340, 88, 18);
228 | contentPane.add(birthdayLabel);
229 |
230 | birthdayField = new JTextField();
231 | birthdayField.setBounds(122, 336, 156, 30);
232 | contentPane.add(birthdayField);
233 | birthdayField.setColumns(10);
234 |
235 | JLabel idCardLabel = new JLabel("身份证:");
236 | idCardLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
237 | idCardLabel.setBounds(51, 391, 64, 18);
238 | contentPane.add(idCardLabel);
239 |
240 | idCardField = new JTextField();
241 | idCardField.setBounds(122, 386, 156, 30);
242 | contentPane.add(idCardField);
243 | idCardField.setColumns(10);
244 |
245 | JPanel marriagedFramePanel = new JPanel();
246 | marriagedFramePanel.setBorder(new TitledBorder(null, "婚姻状况",
247 |
248 | TitledBorder.DEFAULT_JUSTIFICATION,
249 |
250 | TitledBorder.DEFAULT_POSITION, null, null));
251 | marriagedFramePanel.setBounds(302, 109, 242, 66);
252 | contentPane.add(marriagedFramePanel);
253 |
254 | JRadioButton marrRadioButton = new JRadioButton("已婚");
255 | marriagedFramePanel.add(marrRadioButton);
256 |
257 | JRadioButton noMarrRadioButton = new JRadioButton("未婚");
258 | marriagedFramePanel.add(noMarrRadioButton);
259 |
260 | ButtonGroup marriagedGroup=new ButtonGroup();
261 | marriagedGroup.add(marrRadioButton);
262 | marriagedGroup.add(noMarrRadioButton);
263 |
264 | JPanel nativePlaceFramePanel = new JPanel();
265 | nativePlaceFramePanel.setBorder(new TitledBorder(null, "籍贯",TitledBorder.DEFAULT_JUSTIFICATION,
266 | TitledBorder.DEFAULT_POSITION, null, null));
267 | nativePlaceFramePanel.setBounds(36, 429, 242, 70);
268 | contentPane.add(nativePlaceFramePanel);
269 |
270 | JComboBox nativePlaceComboBox = new JComboBox();
271 | nativePlaceFramePanel.add(nativePlaceComboBox);
272 | List nativePlaces = NativePlaceDao.findAllNativePlace();
273 | for (TbNativePlace np:nativePlaces) {
274 | nativePlaceComboBox.addItem(np.getName());
275 | }
276 |
277 | JPanel partyMemberFramePanel = new JPanel();
278 | partyMemberFramePanel.setBorder(new TitledBorder(null, "是否党员",
279 |
280 |
281 | TitledBorder.DEFAULT_JUSTIFICATION,
282 |
283 |
284 | TitledBorder.DEFAULT_POSITION, null, null));
285 | partyMemberFramePanel.setBounds(302, 188, 242, 66);
286 | contentPane.add(partyMemberFramePanel);
287 |
288 | JRadioButton partyMemberRadioButton = new JRadioButton("是");
289 | partyMemberFramePanel.add(partyMemberRadioButton);
290 |
291 | JRadioButton noPartyMemberRadioButton = new JRadioButton("否");
292 | partyMemberFramePanel.add(noPartyMemberRadioButton);
293 |
294 | ButtonGroup partyMemberGroup=new ButtonGroup();
295 | partyMemberGroup.add(partyMemberRadioButton);
296 | partyMemberGroup.add(noPartyMemberRadioButton);
297 |
298 | JLabel schoolAgeLabel = new JLabel("学历:");
299 | schoolAgeLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
300 | schoolAgeLabel.setBounds(329, 304, 56, 18);
301 | contentPane.add(schoolAgeLabel);
302 |
303 | schoolAgeField = new JTextField();
304 | schoolAgeField.setBounds(388, 298, 156, 30);
305 | contentPane.add(schoolAgeField);
306 | schoolAgeField.setColumns(10);
307 |
308 | JLabel specialtyLabel = new JLabel("专业:");
309 | specialtyLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
310 | specialtyLabel.setBounds(329, 365, 56, 18);
311 | contentPane.add(specialtyLabel);
312 |
313 | specialtyField = new JTextField();
314 | specialtyField.setBounds(388, 360, 156, 30);
315 | contentPane.add(specialtyField);
316 | specialtyField.setColumns(10);
317 |
318 | JLabel foreignLanguageLabel = new JLabel("外语:");
319 | foreignLanguageLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
320 | foreignLanguageLabel.setBounds(329, 424, 56, 18);
321 | contentPane.add(foreignLanguageLabel);
322 |
323 | foreignLanguageField = new JTextField();
324 | foreignLanguageField.setBounds(388, 418, 156, 30);
325 | contentPane.add(foreignLanguageField);
326 | foreignLanguageField.setColumns(10);
327 |
328 | JLabel gradeLabel = new JLabel("外语水平:");
329 | gradeLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
330 | gradeLabel.setBounds(298, 476, 98, 18);
331 | contentPane.add(gradeLabel);
332 |
333 | gradeField = new JTextField();
334 | gradeField.setBounds(388, 469, 156, 30);
335 | contentPane.add(gradeField);
336 | gradeField.setColumns(10);
337 |
338 | JLabel stateLabel = new JLabel("员工状态:");
339 | stateLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
340 | stateLabel.setBounds(601, 322, 98, 18);
341 | contentPane.add(stateLabel);
342 |
343 | stateField = new JTextField();
344 | stateField.setBounds(699, 317, 123, 30);
345 | contentPane.add(stateField);
346 | stateField.setColumns(10);
347 |
348 | JPanel roleFramePanel = new JPanel();
349 | roleFramePanel.setBorder(new TitledBorder(null, "权限",TitledBorder.DEFAULT_JUSTIFICATION,
350 | TitledBorder.DEFAULT_POSITION, null, null));
351 | roleFramePanel.setBounds(586, 366, 236, 66);
352 | contentPane.add(roleFramePanel);
353 |
354 | JComboBox roleComboBox = new JComboBox();
355 | roleFramePanel.add(roleComboBox);
356 | List roles = RoleDao.findAllRole();
357 | for (TbRole r:roles) {
358 | roleComboBox.addItem(r.getName());
359 | }
360 |
361 | JButton saveButton = new JButton("保存");
362 | saveButton.setBounds(586, 459, 113, 41);
363 | contentPane.add(saveButton);
364 |
365 |
366 | JButton exitButton = new JButton("退出");
367 | exitButton.setBounds(709, 459, 113, 41);
368 | contentPane.add(exitButton);
369 |
370 | exitButton.addActionListener(new ActionListener() {
371 | @Override
372 | public void actionPerformed(ActionEvent e) {
373 | dispose();
374 | }
375 | });
376 |
377 | saveButton.addActionListener(new ActionListener() {
378 | @Override
379 | public void actionPerformed(ActionEvent e) {
380 | //创建新的TbPerson表对象,按逻辑判断所有格式是否正确,set放数据,执行update,成功则提示
381 | TbPerson person = new TbPerson();
382 | int finish = 1;
383 | person.setRecordNumber(recordNumber);
384 |
385 | //所属部门 职位 籍贯 权限
386 | person.setDeptId(deptComboBox.getSelectedIndex());
387 | person.setDutyId(dutyComboBox.getSelectedIndex());
388 | person.setNativePlaceId(nativePlaceComboBox.getSelectedIndex());
389 | person.setRoleId(roleComboBox.getSelectedIndex());
390 |
391 | //姓名 出生日期 身份证 学历 专业 外语 外语水平 状态
392 | person.setName(nameField.getText());
393 |
394 | DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
395 | Date birthdayDate = null;
396 | try{
397 | birthdayDate = formatter.parse(birthdayField.getText());
398 | System.out.print("格式正确!");
399 | }catch(Exception e3){
400 | JOptionPane.showMessageDialog(null, "日期格式错误!正确例子:yyyy-mm-dd");
401 | finish = 0;
402 | }
403 | person.setBirthday(birthdayDate);
404 |
405 | person.setIdCard(idCardField.getText());
406 | person.setSchoolAge(schoolAgeField.getText());
407 | person.setSpecialty(specialtyField.getText());
408 | person.setForeignLanguage(foreignLanguageField.getText());
409 | person.setGrade(gradeField.getText());
410 | person.setState(stateField.getText());
411 | //性别 婚姻 党员
412 | if(nanRadioButton.isSelected()) {
413 | person.setSex("男");
414 | }else if(nvRadioButton.isSelected()) {
415 | person.setSex("女");
416 | }else {
417 | }
418 |
419 | if(marrRadioButton.isSelected()) {
420 | person.setMarriaged("已婚");
421 | }else if(noMarrRadioButton.isSelected()) {
422 | person.setMarriaged("未婚");
423 | }else {
424 | }
425 |
426 | if(partyMemberRadioButton.isSelected()) {
427 | person.setPartyMember("是");
428 | }else if(noPartyMemberRadioButton.isSelected()) {
429 | person.setPartyMember("否");
430 | }else {
431 | }
432 |
433 | // 保存图片
434 | if (photoLabel.getIcon() != null) {// 数据库图片已存在或者刚完成添加照片
435 | if(selectPhotoFlag == 1) {//如果用户双击添加了图片
436 | try {
437 | //暂不上传,需要获取该图后缀.jpg拼接person名
438 | String newPhotoName = recordNumber+""+file.getName().substring(file.getName().lastIndexOf("."));
439 | //在服务器资源目录创建此文件
440 | File file2 =new File(this.getClass().getResource("/").getPath()+"personnel_photo");
441 | if (!file2 .exists() && !file2 .isDirectory()) {
442 | file2 .mkdir();
443 | }
444 | File photo = new File(this.getClass().getResource("/").getPath()+"personnel_photo/"+newPhotoName);
445 | person.setPhoto(newPhotoName);// 将新的图片名称保存到person对象中待上传
446 | if (!photo.exists()) {// 如果文件不存在则创建文件
447 | photo.createNewFile();
448 | }
449 | if(photo.exists()) {//因为是双击添加图,如果存在,就删除重新创建
450 | photo.delete();
451 | }
452 |
453 | InputStream inStream = new FileInputStream(file);// 创建输入流对象
454 | OutputStream outStream = new FileOutputStream(photo);// 创建输出流对象
455 | int readBytes = 0; // 读取字节数
456 | byte[] buffer = new byte[1024]; // 定义缓存数组
457 | while ((readBytes = inStream.read(buffer, 0, 1024)) != -1) { // 从输入流读取数据到缓存数组中
458 | outStream.write(buffer, 0, readBytes); // 将缓存数组中的数据输出到输出流
459 | }
460 | outStream.close();// 关闭输出流对象
461 | inStream.close();// 关闭输入流对象
462 | } catch (Exception e2) {
463 | e2.printStackTrace();
464 | }
465 | }else {//没有选择上传图片也有icon说明数据库已经存在
466 | //要更新信息则需要查数据库找到图片再传入一次图片信息
467 | TbPerson tbPerson = new TbPerson();
468 | tbPerson = PersonDao.findPersonByRecordNumber(recordNumber);
469 | person.setPhoto(tbPerson.getPhoto());
470 | }
471 |
472 | }
473 | if(finish == 1) {
474 | //执行update
475 | PersonDao.updatePerson(person);
476 | JOptionPane.showMessageDialog(null, "保存成功!");
477 | }
478 | }
479 | });
480 |
481 |
482 | if (p == null || p.getPhoto() == null) {// 新建档案或未上传照片
483 | photoLabel.setText("双击添加照片");// 显示文字提示
484 | } else {
485 | // 修改档案并且已上传照片
486 | File file2 =new File(this.getClass().getResource("/").getPath()+"personnel_photo");
487 | if (!file2 .exists() && !file2 .isDirectory()) {
488 | file2 .mkdir();
489 | }
490 | String photo = this.getClass().getResource("/").getPath()+"personnel_photo/"+p.getPhoto();// 组织员工照片的存放路径
491 | System.out.println("加载时照片位置:"+photo);
492 |
493 | Image img = Toolkit.getDefaultToolkit().createImage(photo);
494 |
495 | photoLabel.setIcon(new ImageIcon(img));// 创建照片对象并显示
496 |
497 |
498 | }
499 | deptComboBox.setSelectedIndex(p.getDeptId());
500 | dutyComboBox.setSelectedIndex(p.getDutyId());
501 | nativePlaceComboBox.setSelectedIndex(p.getNativePlaceId());
502 | roleComboBox.setSelectedIndex(p.getRoleId());
503 | nameField.setText(p.getName());
504 | String birthday="";
505 | try {
506 | birthday = new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthday());
507 | } catch (Exception e1) {
508 | e1.printStackTrace();
509 | birthday = "";
510 | }
511 | birthdayField.setText(birthday);
512 |
513 | idCardField.setText(p.getIdCard());
514 | schoolAgeField.setText(p.getSchoolAge());
515 | specialtyField.setText(p.getSpecialty());
516 | foreignLanguageField.setText(p.getForeignLanguage());
517 | gradeField.setText(p.getGrade());
518 | stateField.setText(p.getState());
519 | String sex = p.getSex();
520 | String marriaged = p.getMarriaged();
521 | String partyMember = p.getPartyMember();
522 | if("男".equals(sex)) {
523 | nanRadioButton.setSelected(true);
524 | }else if("女".equals(sex)) {
525 | nvRadioButton.setSelected(true);
526 | }else{
527 | }
528 |
529 | if("已婚".equals(marriaged)) {
530 | marrRadioButton.setSelected(true);
531 | }else if("未婚".equals(marriaged)) {
532 | noMarrRadioButton.setSelected(true);
533 | }else{
534 | }
535 |
536 | if("是".equals(partyMember)) {
537 | partyMemberRadioButton.setSelected(true);
538 | }else if("否".equals(partyMember)) {
539 | noPartyMemberRadioButton.setSelected(true);
540 | }else{
541 | }
542 | }
543 | }
544 |
--------------------------------------------------------------------------------
/src/view/PersonInfoFrame2.java:
--------------------------------------------------------------------------------
1 | package view;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.Color;
5 | import java.awt.Dimension;
6 | import java.awt.EventQueue;
7 | import java.awt.Toolkit;
8 |
9 | import javax.swing.ImageIcon;
10 | import javax.swing.JFrame;
11 | import javax.swing.JPanel;
12 | import javax.swing.SwingConstants;
13 | import javax.swing.border.EmptyBorder;
14 | import javax.swing.border.TitledBorder;
15 | import javax.swing.JLabel;
16 | import javax.swing.JComboBox;
17 | import javax.swing.JRadioButton;
18 | import javax.swing.JTextField;
19 |
20 | import java.awt.Font;
21 |
22 | import javax.swing.JButton;
23 |
24 | import model.TbPerson;
25 |
26 | public class PersonInfoFrame2 extends JFrame {
27 |
28 | private JPanel contentPane;
29 | private JTextField nameField;
30 | private JTextField birthdayField;
31 | private JTextField idCardField;
32 | private JTextField schoolAgeField;
33 | private JTextField specialtyField;
34 | private JTextField foreignLanguageField;
35 | private JTextField gradeField;
36 | private JTextField stateField;
37 |
38 | /**
39 | * Launch the application.
40 | */
41 | public static void main(String[] args) {
42 | EventQueue.invokeLater(new Runnable() {
43 | public void run() {
44 | try {
45 | PersonInfoFrame frame = new PersonInfoFrame();
46 | frame.setVisible(true);
47 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
48 | Dimension frameSize = frame.getSize();
49 | if (frameSize.height > screenSize.height) {
50 | frameSize.height = screenSize.height;
51 | }
52 | if (frameSize.width > screenSize.width) {
53 | frameSize.width = screenSize.width;
54 | }
55 | frame.setLocation((screenSize.width - frameSize.width) / 2,
56 | (screenSize.height - frameSize.height) / 2);
57 |
58 | } catch (Exception e) {
59 | e.printStackTrace();
60 | }
61 | }
62 | });
63 | }
64 |
65 | /**
66 | * Create the frame.
67 | */
68 | public PersonInfoFrame2(String recordNumber) {
69 | System.out.println("recordNumber"+recordNumber);
70 |
71 | }
72 |
73 | public PersonInfoFrame2() {
74 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
75 | setBounds(100, 100, 896, 611);
76 | setTitle("查看员工信息");
77 | contentPane = new JPanel();
78 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
79 | setContentPane(contentPane);
80 | contentPane.setLayout(null);
81 |
82 | JLabel lblt = new JLabel("员工编号:");
83 | lblt.setFont(new Font("微软雅黑", Font.PLAIN, 18));
84 | lblt.setBounds(36, 32, 98, 41);
85 | contentPane.add(lblt);
86 |
87 | JLabel recordNumberLabel = new JLabel("T0000");
88 | recordNumberLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
89 | recordNumberLabel.setBounds(140, 32, 138, 41);
90 | contentPane.add(recordNumberLabel);
91 |
92 | JLabel photoLabel = new JLabel("New label");
93 | photoLabel.setBounds(665, 65, 120, 166);
94 | contentPane.add(photoLabel);
95 | photoLabel.setHorizontalAlignment(SwingConstants.CENTER);// 设置照片或文字居中显示
96 | photoLabel.setBorder(new TitledBorder(null, "",
97 | TitledBorder.DEFAULT_JUSTIFICATION,
98 | TitledBorder.DEFAULT_POSITION, null, null));// 设置边框
99 | photoLabel.setPreferredSize(new Dimension(120, 166));// 设置显示照片的大小
100 |
101 | JPanel deptFramePanel = new JPanel();
102 | deptFramePanel.setBorder(new TitledBorder(null, "所属部门",
103 | TitledBorder.DEFAULT_JUSTIFICATION,
104 | TitledBorder.DEFAULT_POSITION, null, null));
105 | deptFramePanel.setBounds(36, 86, 242, 70);
106 | contentPane.add(deptFramePanel);
107 |
108 | JComboBox deptComboBox = new JComboBox();
109 | deptFramePanel.add(deptComboBox);
110 | deptComboBox.setToolTipText("");
111 |
112 | JPanel dutyFramePanel = new JPanel();
113 | dutyFramePanel.setBorder(new TitledBorder(null, "职位",
114 | TitledBorder.DEFAULT_JUSTIFICATION,
115 | TitledBorder.DEFAULT_POSITION, null, null));
116 | dutyFramePanel.setBounds(36, 169, 242, 70);
117 | contentPane.add(dutyFramePanel);
118 |
119 | JComboBox dutyComboBox = new JComboBox();
120 | dutyFramePanel.add(dutyComboBox);
121 |
122 | JLabel nameLabel = new JLabel("姓名:");
123 | nameLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
124 | nameLabel.setBounds(67, 291, 56, 18);
125 | contentPane.add(nameLabel);
126 |
127 | JPanel sexFramePanel = new JPanel();
128 | sexFramePanel.setBounds(302, 32, 242, 70);
129 | sexFramePanel.setBorder(new TitledBorder(null, "性别",
130 | TitledBorder.DEFAULT_JUSTIFICATION,
131 | TitledBorder.DEFAULT_POSITION, null, null));
132 | contentPane.add(sexFramePanel);
133 |
134 |
135 |
136 | JRadioButton nanRadioButton = new JRadioButton("男");
137 | sexFramePanel.add(nanRadioButton);
138 |
139 | JRadioButton nvRadioButton = new JRadioButton("女");
140 | sexFramePanel.add(nvRadioButton);
141 |
142 | nameField = new JTextField();
143 | nameField.setBounds(122, 286, 156, 30);
144 | contentPane.add(nameField);
145 | nameField.setColumns(10);
146 |
147 | JLabel birthdayLabel = new JLabel("出生日期:");
148 | birthdayLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
149 | birthdayLabel.setBounds(36, 340, 88, 18);
150 | contentPane.add(birthdayLabel);
151 |
152 | birthdayField = new JTextField();
153 | birthdayField.setBounds(122, 336, 156, 30);
154 | contentPane.add(birthdayField);
155 | birthdayField.setColumns(10);
156 |
157 | JLabel idCardLabel = new JLabel("身份证:");
158 | idCardLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
159 | idCardLabel.setBounds(51, 391, 64, 18);
160 | contentPane.add(idCardLabel);
161 |
162 | idCardField = new JTextField();
163 | idCardField.setBounds(122, 386, 156, 30);
164 | contentPane.add(idCardField);
165 | idCardField.setColumns(10);
166 |
167 | JPanel marriagedFramePanel = new JPanel();
168 | marriagedFramePanel.setBorder(new TitledBorder(null, "婚姻状况",
169 | TitledBorder.DEFAULT_JUSTIFICATION,
170 | TitledBorder.DEFAULT_POSITION, null, null));
171 | marriagedFramePanel.setBounds(302, 109, 242, 66);
172 | contentPane.add(marriagedFramePanel);
173 |
174 | JRadioButton marrRadioButton = new JRadioButton("未婚");
175 | marriagedFramePanel.add(marrRadioButton);
176 |
177 | JRadioButton noMarrRadioButton = new JRadioButton("已婚");
178 | marriagedFramePanel.add(noMarrRadioButton);
179 |
180 | JPanel nativePlaceFramePanel = new JPanel();
181 | nativePlaceFramePanel.setBorder(new TitledBorder(null, "籍贯",
182 | TitledBorder.DEFAULT_JUSTIFICATION,
183 | TitledBorder.DEFAULT_POSITION, null, null));
184 | nativePlaceFramePanel.setBounds(36, 429, 242, 70);
185 | contentPane.add(nativePlaceFramePanel);
186 |
187 | JComboBox nativePlaceComboBox = new JComboBox();
188 | nativePlaceFramePanel.add(nativePlaceComboBox);
189 | nativePlaceComboBox.addItem("福建省");
190 |
191 | JPanel partyMemberFramePanel = new JPanel();
192 | partyMemberFramePanel.setBorder(new TitledBorder(null, "是否党员",
193 | TitledBorder.DEFAULT_JUSTIFICATION,
194 | TitledBorder.DEFAULT_POSITION, null, null));
195 | partyMemberFramePanel.setBounds(302, 188, 242, 66);
196 | contentPane.add(partyMemberFramePanel);
197 |
198 | JRadioButton partMemberRadioButton = new JRadioButton("党员");
199 | partyMemberFramePanel.add(partMemberRadioButton);
200 |
201 | JRadioButton noPartMemberRadioButton = new JRadioButton("非党员");
202 | partyMemberFramePanel.add(noPartMemberRadioButton);
203 |
204 | JLabel schoolAgeLabel = new JLabel("学历:");
205 | schoolAgeLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
206 | schoolAgeLabel.setBounds(329, 304, 56, 18);
207 | contentPane.add(schoolAgeLabel);
208 |
209 | schoolAgeField = new JTextField();
210 | schoolAgeField.setBounds(388, 298, 156, 30);
211 | contentPane.add(schoolAgeField);
212 | schoolAgeField.setColumns(10);
213 |
214 | JLabel specialtyLabel = new JLabel("专业:");
215 | specialtyLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
216 | specialtyLabel.setBounds(329, 365, 56, 18);
217 | contentPane.add(specialtyLabel);
218 |
219 | specialtyField = new JTextField();
220 | specialtyField.setBounds(388, 360, 156, 30);
221 | contentPane.add(specialtyField);
222 | specialtyField.setColumns(10);
223 |
224 | JLabel foreignLanguageLabel = new JLabel("外语:");
225 | foreignLanguageLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
226 | foreignLanguageLabel.setBounds(329, 424, 56, 18);
227 | contentPane.add(foreignLanguageLabel);
228 |
229 | foreignLanguageField = new JTextField();
230 | foreignLanguageField.setBounds(388, 418, 156, 30);
231 | contentPane.add(foreignLanguageField);
232 | foreignLanguageField.setColumns(10);
233 |
234 | JLabel gradeLabel = new JLabel("外语水平:");
235 | gradeLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
236 | gradeLabel.setBounds(298, 476, 98, 18);
237 | contentPane.add(gradeLabel);
238 |
239 | gradeField = new JTextField();
240 | gradeField.setBounds(388, 469, 156, 30);
241 | contentPane.add(gradeField);
242 | gradeField.setColumns(10);
243 |
244 | JLabel stateLabel = new JLabel("员工状态:");
245 | stateLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
246 | stateLabel.setBounds(601, 322, 98, 18);
247 | contentPane.add(stateLabel);
248 |
249 | stateField = new JTextField();
250 | stateField.setBounds(699, 317, 123, 30);
251 | contentPane.add(stateField);
252 | stateField.setColumns(10);
253 |
254 | JButton saveButton = new JButton("保存");
255 | saveButton.setBounds(586, 459, 113, 41);
256 | contentPane.add(saveButton);
257 |
258 | JButton exitButton = new JButton("退出");
259 | exitButton.setBounds(709, 459, 113, 41);
260 | contentPane.add(exitButton);
261 |
262 | JPanel panel = new JPanel();
263 | panel.setBorder(new TitledBorder(null, "权限",
264 | TitledBorder.DEFAULT_JUSTIFICATION,
265 | TitledBorder.DEFAULT_POSITION, null, null));
266 | panel.setBounds(586, 366, 236, 66);
267 | contentPane.add(panel);
268 |
269 | JComboBox comboBox = new JComboBox();
270 | panel.add(comboBox);
271 | TbPerson t = null;
272 | if (t == null || t.getPhoto() == null) {// 新建档案或未上传照片
273 | photoLabel.setText("双击添加照片");// 显示文字提示
274 | } else {
275 | }
276 | }
277 | }
278 |
--------------------------------------------------------------------------------