Eclipse+Java+Swing+Mysql realizes employee information management system

content

1. System introduction

1. Development environment

2. Technical selection

3. System function

4. Database

2. System display

1. Log in to the system

2. Main page

3. Department management

4. Position management

5. Staff management

3. Part of the code

AdminDao.java

DeptDao.java

DutyDao.java

StaffDao.java

 4. Other

1. More systems

JavaSwing system series implementation

Java+JSP system series implementation

Java+Servlet system series implementation

Java+SSM system series implementation

Java+SSH system series implementation

Java+Springboot system series implementation

2. Source code download

3. Run the project

4. Remarks

5. Support Bloggers


1. System introduction

1. Development environment

Development tools: Eclipse2021

JDK version: jdk1.8

Mysql version: 8.0.13

2. Technical selection

Java+Swing+Mysql

3. System function

1. The administrator logs in to the system;

2. The administrator can query employee information, add employee information, modify employee information, and delete employee information;

3. The administrator queries department information, adds department information, modifies department information, and deletes department information;

4. The administrator inquires about job information, adds job information, modifies job information, and deletes job information;

4. Database

/*
 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;

2. System display

1. Log in to the system

2. Main page

3. Department management

4. Position management

5. Staff management

3. Part of the code

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;
	}
}

 4. Other

1. More systems

JavaSwing system series implementation

Java+Swing implements Doudizhu game

Java+Swing realizes book management system

Java+Swing realizes hospital management system

Java+Swing realizes examination management system

Java+Swing realizes hotel management system

Java+Swing realizes supermarket management system

Java+Swing realizes movie ticketing system

Java+Swing implements warehouse management system-1

Java+Swing implements warehouse management system-2

Java+Swing implements invoicing management system

Java+Swing realizes automatic teller machine system

Java+Swing implements address book management system

Java+Swing realizes parking lot management system

Java+Swing Realization of Student Information Management System

Java+Swing implements employee salary management system

Java+Swing realizes student dormitory management system

Java+Swing implements student course selection management system

Java+Swing realizes student achievement management system

Java+Swing realizes school textbook management system

Java+Swing realizes school education management system

Java+Swing realizes enterprise personnel management system

Java+Swing realizes electronic album management system

Java+Swing realizes supermarket management system-TXT storage data

Java+Swing realizes self-service teller system-TXT storage data

Java+Swing realizes pet store management system-TXT storage data

Java+JSP system series implementation

Java+JSP Realization of Student Book Management System

Java+JSP Realization of Student Information Management System

Java+JSP Realization of User Information Management System

Java+Servlet system series implementation

Java+Servlet+JSP Realization of Airline Booking System

Java+Servlet+JSP Realization of News Release System

Java+Servlet+JSP Student Dormitory Management System

Java+Servlet+JSP Realization of Book Management System

Java+Servlet+JSP Realization of Parking Lot Management System

Java+Servlet+JSP Realization of Housing Rental Management System

Java+Servlet+JSP Realization of Student Information Management System

Java+Servlet+JSP to realize student course selection management system

Java+Servlet+JSPl realizes the student's course selection and sign-in system

Java+Servlet+JSP realizes pet clinic management system

Java+Servlet+JSP realizes student achievement management system-1

Java+Servlet+JSP realizes student achievement management system-2

Java+SSM system series implementation

Java+SSM+JSP Realization of Book Management System

Java+SSM+JSP to realize supermarket order system

Java+SSM+JSP to realize online examination system

Java+SSM+JSP to realize pet mall system

Java+SSM+Layui realizes student achievement management system

Java+SSM+Bootstrap realizes student information management system

Java+SSH system series implementation

Java+SSH+JSP Realization of Online Exam System

Java+SSH+JSP Realization of Hospital Online Registration System

Java+Springboot system series implementation

Java+Springboot+H-ui+Maven to realize marketing management system

Java+Springboot+Bootstrap+Maven to realize online mall system

Java+Springboot+Bootstrap+Maven realizes scenic tourism management system

1. For more JavaWeb systems, please pay attention to the column.

https://blog.csdn.net/helongqiang/category_10020130.htmlhttps://blog.csdn.net/helongqiang/category_10020130.html

2. For more JavaSwing systems, please pay attention to the column.

https://blog.csdn.net/helongqiang/category_6229101.htmlhttps://blog.csdn.net/helongqiang/category_6229101.html

2. Source code download

Java+Swing+Mysql realizes employee information management system

3. Run the project

Note that the employee number is 4 digits, and the job and department numbers are 3 digits. The administrator account and password are both admin.

Please click the link below to deploy your project.

Eclipse how to import JavaSwing project super detailed graphic tutorial

How to import JavaSwing project in Eclipse with super detailed video tutorial

4. Remarks

If there is any infringement, please contact me to delete it.

5. Support Bloggers

If you think this article is helpful to you, please like, follow and favorite. wish you a happy life!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324188097&siteId=291194637