基于Java Swing + Mysql 人事管理系统

一、项目概要:

基于Java Swing + Mysql 人事管理系统,包含登录、人员管理、部门管理、人员考核三个模块。

二、获取方式

如有需要的可以直接点击 下载

若有技术需要咨询可以加 QQ:571328502

三、页面展示:

1.登录页面

2.主页页面:

3.人员管理:

4.部门管理:

5.人员考核:

 四、主要代码

 1.登录:

package System;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import com.mysql.cj.protocol.Resultset;

import Content.PersonChange;
import Content.Staffadd;
import Content.deptManage;
import DB.SqlBean;

import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import javax.swing.SwingConstants;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.image.DataBuffer;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.ForkJoinPool.ManagedBlocker;
import java.awt.event.ActionEvent;
import javax.swing.UIManager;
import java.awt.SystemColor;

public class login extends JFrame {

	private JPanel contentPane;
	private JTextField user_id;
	private JPasswordField user_password;
	static login frame = null;
	static Regedit regedit = null;
	static Main main = null;
	static Staffadd staffadd = null;
	static PersonChange change = null;
	static deptManage dept = null;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					frame = new login();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public login() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 754, 474);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("\u4EBA\u4E8B\u7BA1\u7406\u7CFB\u7EDF\u767B\u9646\u754C\u9762");
		lblNewLabel.setForeground(Color.RED);
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel.setFont(new Font("黑体", Font.BOLD, 22));
		lblNewLabel.setBounds(10, 0, 720, 110);
		contentPane.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("\u5E10\u53F7\uFF1A");
		lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel_1.setFont(new Font("黑体", Font.PLAIN, 20));
		lblNewLabel_1.setBounds(93, 96, 158, 56);
		contentPane.add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("\u5BC6\u7801\uFF1A");
		lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel_2.setFont(new Font("黑体", Font.PLAIN, 20));
		lblNewLabel_2.setBounds(93, 190, 158, 56);
		contentPane.add(lblNewLabel_2);
		
		user_id = new JTextField();
		user_id.setBounds(219, 96, 308, 41);
		contentPane.add(user_id);
		user_id.setColumns(10);
		
		user_password = new JPasswordField();
		user_password.setBounds(219, 190, 308, 41);
		contentPane.add(user_password);
		
		JButton btnNewButton = new JButton("\u767B\u5F55");
		btnNewButton.setBackground(Color.WHITE);
		btnNewButton.setForeground(SystemColor.desktop);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String id =	 user_id.getText();
				String password = user_password.getText();			
				if(id.equals("") || password.equals("")) {
					JOptionPane.showMessageDialog(null, "账号和密码不能为空!");
				}
				SqlBean db = new SqlBean();
				String sql = "select * from e_user where user_id='"+id+"' and user_password='"+password+"'";
				try {
					if(db.login(sql)) {
						Main main = new Main();
						main.setVisible(true);
						frame.setVisible(false);
					}
					else {
						JOptionPane.showMessageDialog(null, "该用户不存在");
					}
				} catch (Exception e2) {
					// TODO: handle exception
					e2.printStackTrace();
				}
				db.close();
				}
			});
		btnNewButton.setFont(new Font("黑体", Font.PLAIN, 18));
		btnNewButton.setBounds(95, 316, 132, 47);
		contentPane.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("\u91CD\u7F6E");
		btnNewButton_1.setBackground(Color.WHITE);
		btnNewButton_1.setForeground(SystemColor.desktop);
		btnNewButton_1.setFont(new Font("黑体", Font.PLAIN, 18));
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				user_id.setText("");
				user_password.setText("");
			}
		});
		btnNewButton_1.setBounds(301, 316, 126, 47);
		contentPane.add(btnNewButton_1);
		
		JButton btnNewButton_2 = new JButton("\u6CE8\u518C");
		btnNewButton_2.setForeground(SystemColor.desktop);
		btnNewButton_2.setBackground(Color.WHITE);
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Regedit regedit = new Regedit();
				regedit.setVisible(true);
				frame.setVisible(false);
			}
		});
		btnNewButton_2.setFont(new Font("黑体", Font.PLAIN, 18));
		btnNewButton_2.setBounds(500, 316, 126, 47);
		contentPane.add(btnNewButton_2);
		setTitle("人事管理系统");
		setLocationRelativeTo(null);
	}
}

2.部门管理

package Content;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;

import com.mysql.cj.xdevapi.DbDoc;

import DB.SqlBean;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;

public class deptManage extends JFrame {

	private JPanel contentPane;
	private JTextField d_dept;
	private JTextField d_dname;
	private JTextField delete_dept;

	/**
	 * Launch the application.
	 */
	
	/*
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					deptManage frame = new deptManage();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	*/
	

	/**
	 * Create the frame.
	 */
	public deptManage() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 834, 462);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnNewButton = new JButton("\u67E5\u8BE2\u73B0\u6709\u90E8\u95E8");
		btnNewButton.setFont(new Font("宋体", Font.BOLD, 15));
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String [] tableHead;
				String [] [] content;
				JTable table;
				JFrame win = new JFrame();
				Query findRecord = new Query();
				findRecord.setSQL("select * from dept");
				content = findRecord.getRecord();	//返回查询的数据,二维数组
				System.out.println(content);
				tableHead = findRecord.getColumnName();	//返回字段名
				table = new JTable(content,tableHead);
				win.getContentPane().add(new JScrollPane(table));
				win.setBounds(12,100,600,500);
				win.setVisible(true);
				win.setDefaultCloseOperation(HIDE_ON_CLOSE);
				win.setLocationRelativeTo(null);
			}
		});
		btnNewButton.setBounds(90, 119, 135, 30);
		contentPane.add(btnNewButton);
		
		JLabel lblNewLabel = new JLabel("\u90E8\u95E8\u4FE1\u606F");
		lblNewLabel.setFont(new Font("宋体", Font.BOLD, 20));
		lblNewLabel.setBounds(90, 47, 203, 45);
		contentPane.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("\u6DFB\u52A0\u90E8\u95E8");
		lblNewLabel_1.setFont(new Font("宋体", Font.BOLD, 20));
		lblNewLabel_1.setBounds(90, 191, 203, 45);
		contentPane.add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("\u90E8\u95E8\u7F16\u53F7");
		lblNewLabel_2.setFont(new Font("宋体", Font.BOLD, 17));
		lblNewLabel_2.setBounds(90, 263, 88, 30);
		contentPane.add(lblNewLabel_2);
		
		d_dept = new JTextField();
		d_dept.setBounds(173, 263, 135, 27);
		contentPane.add(d_dept);
		d_dept.setColumns(10);
		
		d_dname = new JTextField();
		d_dname.setBounds(173, 326, 135, 27);
		contentPane.add(d_dname);
		d_dname.setColumns(10);
		
		JLabel lblNewLabel_3 = new JLabel("\u90E8\u95E8\u540D\u79F0");
		lblNewLabel_3.setFont(new Font("宋体", Font.BOLD, 17));
		lblNewLabel_3.setBounds(90, 323, 88, 30);
		contentPane.add(lblNewLabel_3);
		
		JButton btnNewButton_1 = new JButton("\u6DFB\u52A0\u4FE1\u606F");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SqlBean db = new SqlBean();
				String dname = d_dname.getText();
				String dept = d_dept.getText();
				if(dept.equals("")) {
					JOptionPane.showMessageDialog(null, "部门编号不能为空!");
					return;
				}
				if(dname.equals("")) {
					JOptionPane.showMessageDialog(null, "部门名称不能为空!");
					return;
				}
				String dept_sql = "select * from dept where d_dept='"+dept+"'";
				if(db.login(dept_sql)) {
					JOptionPane.showMessageDialog(null, "部门编号已存在!");
					return;
				}
				String dname_sql = "select * from dept where d_dname='"+dname+"'";
				if(db.login(dname_sql)) {
					JOptionPane.showMessageDialog(null, "部门名称已存在!");
					return;
				}		
				try {
					String update_sql = "insert into dept(d_dept,d_dname) values('"+dept+"','"+dname+"')";
					boolean a = db.executeUpdate(update_sql);
					if(a) {
						JOptionPane.showMessageDialog(null, "添加部门成功!");
						return;
					}
					else {
						JOptionPane.showMessageDialog(null, "添加部门失败");
						return;
					}	
				} catch (Exception e2) {
					// TODO: handle exception
				}
			db.close();
			}
		});
		btnNewButton_1.setFont(new Font("宋体", Font.BOLD, 17));
		btnNewButton_1.setBounds(124, 379, 129, 24);
		contentPane.add(btnNewButton_1);
		
		JLabel lblNewLabel_4 = new JLabel("\u5220\u9664\u90E8\u95E8");
		lblNewLabel_4.setFont(new Font("宋体", Font.BOLD, 20));
		lblNewLabel_4.setBounds(442, 191, 203, 45);
		contentPane.add(lblNewLabel_4);
		
		delete_dept = new JTextField();
		delete_dept.setBounds(552, 263, 135, 27);
		contentPane.add(delete_dept);
		delete_dept.setColumns(10);
		
		JLabel lblNewLabel_5 = new JLabel("\u90E8\u95E8\u7F16\u53F7");
		lblNewLabel_5.setFont(new Font("宋体", Font.BOLD, 17));
		lblNewLabel_5.setBounds(442, 260, 88, 30);
		contentPane.add(lblNewLabel_5);
		
		JButton btnNewButton_2 = new JButton("\u5220\u9664\u90E8\u95E8");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SqlBean db = new SqlBean();
				String deletedept = delete_dept.getText();
				if(deletedept.equals("")) {
					JOptionPane.showMessageDialog(null, "请先填写需要删除部门的编号!");
					return;
				}
				String dept_sql = "select * from dept";
				if(db.login(dept_sql)) {
					String delete_sql = "delete from dept where d_dept='"+deletedept+"'";
					boolean a = db.executeUpdate(delete_sql);
					if(a) {
						JOptionPane.showMessageDialog(null, "部门删除成功!");
						return;
					}
					else {
						JOptionPane.showMessageDialog(null, "部门不存在!");
						return;
					}
				}
				db.close();
			}
		});
		btnNewButton_2.setFont(new Font("宋体", Font.BOLD, 17));
		btnNewButton_2.setBounds(487, 326, 129, 24);
		contentPane.add(btnNewButton_2);
		setTitle("部门管理");
		setDefaultCloseOperation(HIDE_ON_CLOSE);
	}
}

五、其它项目

基于Java Swing 的通讯录管理系统

基于Java Swing记事本管理系统

基于java Swing 宿舍管理系统

基于java Swing 图书管理系统

基于Java Swing 成绩管理系统

六、心灵寄语:

想要赢,就一定不能怕输。不怕输结果未必能赢,但是怕输,结果则是一定输。

PS:如有侵权,联系我删除

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飞鱼点点

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值