基于java的Swing+MySQL人力管理系统(java+gui)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

430123052402

基于java的Swing+MySQL人力管理系统(java+gui)

功能介绍:

角色员工、管理员,员工信息表,查询、更新,修改,移除、添加

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
		System.out.println("jCBSelectQueryFieldTransfer(). InputStr = " + InputStr);

if (InputStr.equals("学号")) {
outputStr = "sNo";
} else if (InputStr.equals("姓名")) {
outputStr = "sName";
} else if (InputStr.equals("性别")) {
outputStr = "sSex";
} else if (InputStr.equals("年龄")) {
outputStr = "sAge";
} else if (InputStr.equals("专业")) {
outputStr = "sSpecialty";
} else if (InputStr.equals("住址")) {
outputStr = "sAddress";
}
System.out.println("jCBSelectQueryFieldTransfer(). outputStr = " + outputStr);
return outputStr;
}
}
package dao;


public class employee_view extends JFrame implements ActionListener {// 通过文本框是否可编辑来操控用户更新权限
// 定义组件
JButton jBQuery = null;// 查询个人信息
JButton jBUpdate = null;// 更新
JPanel jP1, jP2, jP3, jP4, jP5, jP6, jP7, jP8, jP9, jP10, jP11, jP12, jP13, jP14, jP15, jP16;

static JTextField jTFID = new JTextField(10); // 员工号
static JTextField jTFPassword = new JTextField(10); // 密码
static JTextField jTFAuthority = new JTextField(10); // 用户权限
static JTextField jTFName = new JTextField(10); // 姓名
static JTextField jTFSex = new JTextField(10); // 性别
static JTextField jTFBirthday = new JTextField(10); // 生日
static JTextField jTFDepartment = new JTextField(10); // 所在部门
static JTextField jTFJob = new JTextField(10); // 职务
static JTextField jTFEdu_Level = new JTextField(10); // 受教育程度
static JTextField jTFSpcialty = new JTextField(10); // 专业技能
static JTextField jTFAddress = new JTextField(10); // 家庭住址
static JTextField jTFTEL = new JTextField(10); // 联系电话
static JTextField jTFEmail = new JTextField(10); // 电子邮箱
static JTextField jTFState = new JTextField(10); // 当前状态(T-员工、F-非员工)
static JTextField jTFRemark = new JTextField(10); // 备注

private static DbProcess dbProcess;

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
			v.add(rs.getString("sSpecialty"));
v.add(rs.getString("sAddress"));
studentVector.add(v);
}

studentJTable.updateUI();

dbProcess.disconnect();
} catch (SQLException sqle) {
System.out.println("sqle = " + sqle);
JOptionPane.showMessageDialog(null, "数据操作错误", "错误", JOptionPane.ERROR_MESSAGE);
}
}

public void insertProcess() {
String sNo = jTFSNo.getText().trim();
String sName = jTFSName.getText().trim();
String sSex = jTFSSex.getText().trim();
String sAge = jTFSAge.getText().trim();
String sSpecialty = jTFSSpecialty.getText().trim();
String sAddress = jTFSAddress.getText().trim();

// 建立插入条件
String sql = "insert into student values('";
sql = sql + sNo + "','";
sql = sql + sName + "','";
sql = sql + sSex + "',";
sql = sql + sAge + ",'";
sql = sql + sSpecialty + "','";
sql = sql + sAddress + "');";

System.out.println("insertProcess(). sql = " + sql);
try {
if (dbProcess.executeUpdate(sql) < 1) {
System.out.println("insertProcess(). insert database failed.");
}
} catch (Exception e) {
System.out.println("e = " + e);
JOptionPane.showMessageDialog(null, "数据操作错误", "错误", JOptionPane.ERROR_MESSAGE);
}
queryAllProcess();
}
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
jTFID = new JTextField(10); // 员工号
jTFPassword = new JTextField(10); // 密码
jTFAuthority = new JTextField(10); // 用户权限
jTFName = new JTextField(10); // 姓名
jTFSex = new JTextField(10); // 性别
jTFBirthday = new JTextField(10); // 生日
jTFDepartment = new JTextField(10); // 所在部门
jTFJob = new JTextField(10); // 职务
jTFEdu_Level = new JTextField(10); // 受教育程度
jTFSpcialty = new JTextField(10); // 专业技能
jTFAddress = new JTextField(10); // 家庭住址
jTFTEL = new JTextField(10); // 联系电话
jTFEmail = new JTextField(10); // 电子邮箱
jTFState = new JTextField(10); // 当前状态(T-员工、F-非员工)
jTFRemark = new JTextField(10); // 备注

jBQuery = new JButton("查询个人信息");
jBUpdate = new JButton("更新");
// 设置监听
// this关键字代指类DatabaseCourseDesigned,实现了ActionListener接口
jBQuery.addActionListener(this);
jBUpdate.addActionListener(this);

jTFID = new JTextField(10); // 员工号
jTFID.setEditable(false);// 员工号不可改
jTFPassword = new JTextField(10); // 密码
jTFAuthority = new JTextField(10); // 用户权限
jTFAuthority.setEditable(false);// 用户权限不可改
jTFName = new JTextField(10); // 姓名
jTFSex = new JTextField(10); // 性别
jTFBirthday = new JTextField(10); // 生日
jTFDepartment = new JTextField(10); // 所在部门
jTFDepartment.setEditable(false);// 所在部门不可改
jTFJob = new JTextField(10); // 职务
jTFJob.setEditable(false);// 职务不可改
jTFEdu_Level = new JTextField(10); // 受教育程度
jTFSpcialty = new JTextField(10); // 专业技能
jTFAddress = new JTextField(10); // 家庭住址
jTFTEL = new JTextField(10); // 联系电话
jTFEmail = new JTextField(10); // 电子邮箱
jTFState = new JTextField(10); // 当前状态(T-员工、F-非员工)
jTFRemark = new JTextField(10); // 备注

jP1 = new JPanel();
jP2 = new JPanel();
jP3 = new JPanel();
jP4 = new JPanel();
jP5 = new JPanel();
jP6 = new JPanel();
jP7 = new JPanel();
jP8 = new JPanel();
jP9 = new JPanel();
jP10 = new JPanel();
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
		} else if (InputStr.equals("备注")) {
outputStr = "REMARK";
}
System.out.println("jCBSelectQueryFieldTransfer(). outputStr = " + outputStr);
return outputStr;
}

}
package db;




public class DatabaseCourseDesign extends JFrame implements ActionListener {
// 定义组件
// 此定义方法先记住
JLabel jLStudentInfoTable = null;// 学生信息表
JLabel jLSelectQueryField = null;// 选择查询字段
JLabel jLEqual = null;// =
JLabel jLSNo = null;// 学号
JLabel jLSName = null;// 姓名
JLabel jLSSex = null;// 性别
JLabel jLSAge = null;// 年龄
JLabel jLSSpecialty = null;// 专业
JLabel jLSAddress = null;// 住址

JTextField jTFQueryField = null;// 查询字段
JTextField jTFSNo = null;// 学号
JTextField jTFSName = null;// 姓名
JTextField jTFSSex = null;// 性别
JTextField jTFSAge = null;// 年龄
JTextField jTFSSpecialty = null;// 专业
JTextField jTFSAddress = null;// 住址

JButton jBQuery = null;// 查询
JButton jBQueryAll = null;// 查询所有记录
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

public void deleteCurrentRecordProcess() {
String sNo = jTFSNo.getText().trim();

// 建立删除条件
String sql = "delete from student where sNo = '" + sNo + "';";
System.out.println("deleteCurrentRecordProcess(). sql = " + sql);
try {
if (dbProcess.executeUpdate(sql) < 1) {
System.out.println("deleteCurrentRecordProcess(). delete database failed.");
}
} catch (Exception e) {
System.out.println("e = " + e);
JOptionPane.showMessageDialog(null, "数据操作错误", "错误", JOptionPane.ERROR_MESSAGE);
}
queryAllProcess();
}

public void deleteAllRecordsProcess() {
// 建立删除条件
String sql = "delete from student;";
System.out.println("deleteAllRecordsProcess(). sql = " + sql);
try {
if (dbProcess.executeUpdate(sql) < 1) {
System.out.println("deleteAllRecordsProcess(). delete database failed.");
}
} catch (Exception e) {
System.out.println("e = " + e);
JOptionPane.showMessageDialog(null, "数据操作错误", "错误", JOptionPane.ERROR_MESSAGE);
}
queryAllProcess();
}

public String jCBSelectQueryFieldTransfer(String InputStr) {// 翻译查询依据,比如"学号"="sNo"
String outputStr = "";
System.out.println("jCBSelectQueryFieldTransfer(). InputStr = " + InputStr);

if (InputStr.equals("学号")) {
outputStr = "sNo";
} else if (InputStr.equals("姓名")) {
outputStr = "sName";
} else if (InputStr.equals("性别")) {
outputStr = "sSex";
} else if (InputStr.equals("年龄")) {
outputStr = "sAge";
} else if (InputStr.equals("专业")) {
outputStr = "sSpecialty";
} else if (InputStr.equals("住址")) {
outputStr = "sAddress";
}
System.out.println("jCBSelectQueryFieldTransfer(). outputStr = " + outputStr);
return outputStr;


项目链接:
https://javayms.github.io?id=441222052008200vm
https://javayms.pages.dev?id=441222052008200vm