Eclipse+Java+Swing+Mysql实现员工信息管理系统
Posted 水坚石青
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Eclipse+Java+Swing+Mysql实现员工信息管理系统相关的知识,希望对你有一定的参考价值。
目录
一、系统介绍
1.开发环境
开发工具:Eclipse2021
JDK版本:jdk1.8
mysql版本:8.0.13
2.技术选型
Java+Swing+Mysql
3.系统功能
1.管理员登录系统;
2.管理员查询员工信息,增加员工信息,修改员工信息,删除员工信息;
3.管理员查询部门信息,增加部门信息,修改部门信息,删除部门信息;
4.管理员查询职务信息,增加职务信息,修改职务信息,删除职务信息;
4.数据库
/*
Navicat Premium Data Transfer
Source Server : MySQL
Source Server Type : MySQL
Source Server Version : 80013
Source Host : 127.0.0.1:3306
Source Schema : swing_staff_management
Target Server Type : MySQL
Target Server Version : 80013
File Encoding : 65001
Date: 07/01/2022 21:39:20
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for dept
-- ----------------------------
DROP TABLE IF EXISTS `dept`;
CREATE TABLE `dept` (
`num` int(11) NULL DEFAULT NULL,
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部门名称',
`address` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of dept
-- ----------------------------
INSERT INTO `dept` VALUES (101, '大数据部', '一楼');
INSERT INTO `dept` VALUES (102, '人力行政部', '二楼');
INSERT INTO `dept` VALUES (103, '后勤部', '三楼');
-- ----------------------------
-- Table structure for duty
-- ----------------------------
DROP TABLE IF EXISTS `duty`;
CREATE TABLE `duty` (
`num` int(4) NOT NULL COMMENT '职务名称',
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`low` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`high` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of duty
-- ----------------------------
INSERT INTO `duty` VALUES (111, '职员', '10000', '20000');
INSERT INTO `duty` VALUES (112, '科长', '20000', '40000');
INSERT INTO `duty` VALUES (113, '部长', '40000', '60000');
INSERT INTO `duty` VALUES (114, '总监', '60000', '80000');
INSERT INTO `duty` VALUES (115, '总经理', '100000', '150000');
-- ----------------------------
-- Table structure for login
-- ----------------------------
DROP TABLE IF EXISTS `login`;
CREATE TABLE `login` (
`id` decimal(4, 0) NOT NULL,
`username` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`password` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of login
-- ----------------------------
INSERT INTO `login` VALUES (1, 'admin', 'admin');
-- ----------------------------
-- Table structure for staff
-- ----------------------------
DROP TABLE IF EXISTS `staff`;
CREATE TABLE `staff` (
`num` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`sex` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`salary` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`phone` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`dept` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`duty` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`num`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of staff
-- ----------------------------
INSERT INTO `staff` VALUES ('1001', '张三', '男', '50000', '13332259632', '大数据部', '部长');
INSERT INTO `staff` VALUES ('1002', '李四', '男', '30000', '13332259632', '大数据部', '科长');
INSERT INTO `staff` VALUES ('1003', '王五', '男', '20000', '13332259632', '后勤部', '职员');
SET FOREIGN_KEY_CHECKS = 1;
二、系统展示
1.登录系统
2.主页面
3.部门管理
4.职位管理
5.员工管理
三、部分代码
AdminDao.java
package dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import utils.DBUtil;
import vo.Admin;
public class AdminDao
// 判断有无此用户
public static boolean isUser(Admin admin)
String sql = "select * from login where username=? and password = ?";
ResultSet rs;
// 定义数组用来存放账号和密码
String[] adminString = new String[] admin.getUserName(), admin.getPassword();
try
rs = DBUtil.execQuery(sql, adminString);
if (rs.next())
return true;
else
return false;
catch (SQLException e)
e.printStackTrace();
return false;
finally
DBUtil.close();
// 测试
public static void main(String[] args)
Admin admin = new Admin();
admin.setUserName("admin");
admin.setPassword("admin");
boolean flag = isUser(admin);
System.out.println(flag);
DeptDao.java
package dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import utils.DBUtil;
import utils.SqlHelper;
import vo.Dept;
/**
*
* 部门管理
*
*/
public class DeptDao
static public int update(Dept dept, int flag) throws SQLException
int result = -1;
String sqlCondition[] = null;
try
switch (flag)
case SqlHelper.INSERT:
sqlCondition = new String[] dept.getNum(), dept.getName(), dept.getAddress() ;
break;
case SqlHelper.DELETE:
sqlCondition = new String[] dept.getNum() ;
break;
case SqlHelper.UPDATE:
sqlCondition = new String[] dept.getName(), dept.getAddress(), dept.getNum() ;
break;
result = DBUtil.execUpdate(SqlHelper.DeptSqls[flag], sqlCondition);
return result;
catch (SQLException e)
finally
DBUtil.close();
return result;
static public Dept query(final Dept dept) throws SQLException
ResultSet rs;
try
rs = DBUtil.execQuery("select * from dept where num=?", new String[] dept.getNum() );
if (rs.next())
dept.setName(rs.getString("name"));
dept.setAddress(rs.getString("address"));
System.out.println("查到该数据");
else
System.out.println("没有查到该数据");
return null;
catch (SQLException e)
// TODO Auto-generated catch block
e.printStackTrace();
return null;
finally
DBUtil.close();
return dept;
DutyDao.java
package dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import utils.DBUtil;
import utils.SqlHelper;
import vo.Duty;
/**
*
* 职务管理
*
*/
public class DutyDao
static public int update(Duty duty, int flag) throws SQLException
int result = -1;
String sqlCondition[] = null;
try
switch (flag)
case SqlHelper.INSERT:
sqlCondition = new String[] duty.getNum(), duty.getName(), duty.getLow(), duty.getHigh() ;
break;
case SqlHelper.DELETE:
sqlCondition = new String[] duty.getNum() ;
break;
case SqlHelper.UPDATE:
sqlCondition = new String[] duty.getName(), duty.getLow(), duty.getHigh(), duty.getNum() ;
break;
result = DBUtil.execUpdate(SqlHelper.DutySqls[flag], sqlCondition);
return result;
catch (SQLException e)
finally
DBUtil.close();
return result;
static public Duty query(final Duty duty) throws SQLException
ResultSet rs;
try
rs = DBUtil.execQuery("select * from duty where num=?", new String[] duty.getNum() );
if (rs.next())
duty.setNum(rs.getString("num"));
duty.setName(rs.getString("name"));
duty.setLow(rs.getString("low"));
duty.setHigh(rs.getString("high"));
System.out.println("查到该数据");
else
System.out.println("没有查到该数据");
return null;
catch (SQLException e)
// TODO Auto-generated catch block
e.printStackTrace();
return null;
finally
DBUtil.close();
return duty;
StaffDao.java
package dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import utils.DBUtil;
import utils.SqlHelper;
import vo.Staff;
/**
*
* 职员管理
*
*/
public class StaffDao
static public int update(Staff staff, int flag) throws SQLException
int result = -1;
String sqlCondition[] = null;
try
switch (flag)
case SqlHelper.INSERT:
sqlCondition = new String[] staff.getNum(), staff.getName(),
staff.getSex(), staff.getSalary(), staff.getPhone(),
staff.getDept(), staff.getDuty() ;
break;
case SqlHelper.DELETE:
sqlCondition = new String[] staff.getNum() ;
break;
case SqlHelper.UPDATE:
sqlCondition = new String[] staff.getName(), staff.getSex(),
staff.getSalary(), staff.getPhone(), staff.getDept(),
staff.getDuty(), staff.getNum() ;
break;
result = DBUtil.execUpdate(SqlHelper.StaffSqls[flag],
sqlCondition);
return result;
catch (SQLException e)
finally
DBUtil.close();
return result;
static public Staff query(final Staff staff) throws SQLException
ResultSet rs;
try
rs = DBUtil.execQuery("select * from staff where num=?",
new String[] staff.getNum() );
if (rs.next())
staff.setNum(rs.getString("num"));
staff.setName(rs.getString("name"));
staff.setSex(rs.getString("sex"));
staff.setSalary(rs.getString("salary"));
staff.setPhone(rs.getString("phone"));
staff.setDept(rs.getString("dept"));
staff.setDuty(rs.getString("duty"));
System.out.println("查到该数据" + staff.getNum());
else
System.out.println("没有查到该数据");
return null;
catch (SQLException e)
e.printStackTrace();
return null;
finally
DBUtil.close();
return staff;
static public ResultSet checkSalary(Staff staff)
ResultSet dutyRs = null;
try
dutyRs = DBUtil.execQuery("select * from duty where name=?",
new String[] staff.getDuty() );
catch (SQLException e)
e.printStackTrace();
return dutyRs;
static public ResultSet checkDept(Staff staff)
ResultSet dutyRs = null;
try
dutyRs = DBUtil.execQuery("select name from dept where name=?",
new String[] staff.getDept() );
catch (SQLException e)
e.printStackTrace();
return dutyRs;
static public ResultSet checkDuty(Staff staff)
ResultSet dutyRs = null;
try
dutyRs = DBUtil.execQuery("select name from duty where name=?",
new String[] staff.getDuty() );
catch (SQLException e)
e.printStackTrace();
return dutyRs;
四、其他
1.更多系统
JavaSwing系统系列实现
Java+JSP系统系列实现
Java+Servlet系统系列实现
Java+SSM系统系列实现
Java+SSH系统系列实现
Java+Springboot系统系列实现
Java+Springboot+H-ui+Maven实现营销管理系统
Java+Springboot+Bootstrap+Maven实现网上商城系统
Java+Springboot+Bootstrap+Maven实现景区旅游管理系统
1.更多JavaWeb系统请关注专栏。
https://blog.csdn.net/helongqiang/category_10020130.htmlhttps://blog.csdn.net/helongqiang/category_10020130.html
2.更多JavaSwing系统请关注专栏。
2.源码下载
3.运行项目
注意员工编号为4位数,职务和部门编号为3位数。管理员账号和密码都为admin。
请点击以下链接,部署你的项目。
4.备注
如有侵权请联系我删除。
5.支持博主
如果您觉得此文对您有帮助,请点赞加关注加收藏。祝您生活愉快!
以上是关于Eclipse+Java+Swing+Mysql实现员工信息管理系统的主要内容,如果未能解决你的问题,请参考以下文章
Eclipse+Java+Swing+Mysql实现超市管理系统
Eclipse+Java+Swing+Mysql实现酒店管理系统
Eclipse+Java+Swing+Mysql实现学生信息管理系统
Eclipse+Java+Swing+Mysql实现进销存管理系统建议收藏