Eclipse+Java+Swing+Mysql实现员工工资管理系统

Posted 水坚石青

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Eclipse+Java+Swing+Mysql实现员工工资管理系统相关的知识,希望对你有一定的参考价值。

目录

一、系统介绍

1.开发环境

2.技术选型

3.系统功能

4.数据库

二、系统展示

1.登录系统

2.用户-登录系统

3.用户-查看工资

4.管理员-主界面

5.管理员-添加员工信息

6.管理员-修改员工信息

7.管理员-删除员工信息

8.管理员-添加部门信息

9.管理员-修改部门信息

10.管理员-删除部门信息

11.管理员-工资设定

12.管理员-工资查询

13.管理员-工资一览

三、部分代码

Login.java

MainFrame.java

DBConn.java

AddDepartment.java

AddEmployee.java

四、其他

1.更多系统

JavaSwing系统系列实现

Java+JSP系统系列实现

Java+Servlet系统系列实现

Java+SSM系统系列实现

Java+SSH系统系列实现

Java+Springboot系统系列实现

2.源码下载

3.运行项目

4.备注

5.支持博主


一、系统介绍

1.开发环境

开发工具:Eclipse2021

JDK版本:jdk1.8

mysql版本:8.0.13

2.技术选型

Java+Swing+Mysql

3.系统功能

1.用户匿名登录系统,查询工资信息;

2.管理员登录登出系统;

3.管理员增加员工信息,修改员工信息,删除员工信息;

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_salary_management

 Target Server Type    : MySQL
 Target Server Version : 80013
 File Encoding         : 65001

 Date: 23/12/2021 21:19:54
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for department
-- ----------------------------
DROP TABLE IF EXISTS `department`;
CREATE TABLE `department`  (
  `ID` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `Name` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `Director` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `Number` int(16) NOT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of department
-- ----------------------------
INSERT INTO `department` VALUES ('ks001', '经理室', '赢政', 10);
INSERT INTO `department` VALUES ('ks002', '财务室', '刘邦', 6);
INSERT INTO `department` VALUES ('ks003', '军机部', '李鸿章', 6);
INSERT INTO `department` VALUES ('ks004', '外交部', '张仪', 8);
INSERT INTO `department` VALUES ('ks005', '技术科', '朱元璋', 10);
INSERT INTO `department` VALUES ('ks006', '董事会', '李世民', 10);

-- ----------------------------
-- Table structure for employee
-- ----------------------------
DROP TABLE IF EXISTS `employee`;
CREATE TABLE `employee`  (
  `ID` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `name` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sex` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `age` int(6) NOT NULL,
  `department` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `position` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `phone` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
  `time` datetime(0) NULL DEFAULT NULL,
  `address` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of employee
-- ----------------------------
INSERT INTO `employee` VALUES ('0001', '赢政', '男', 37, '经理室', '经理', '10086', '0201-01-01 00:00:00', '咸阳');
INSERT INTO `employee` VALUES ('0002', '刘邦', '男', 40, '技术科', '技术长', '10087910', '2001-05-06 00:00:00', '长安');
INSERT INTO `employee` VALUES ('0003', '武则天', '女', 30, '财务室', '经理', '10088', '1999-08-07 00:00:00', '长安');
INSERT INTO `employee` VALUES ('0004', '刘秀', '男', 46, '军机部', '副部长', '123548788', '2013-05-07 00:00:00', '桂林');
INSERT INTO `employee` VALUES ('0005', '西施', '女', 23, '财务室', '会计', '10089', '2001-02-03 00:00:00', '越国');
INSERT INTO `employee` VALUES ('0006', '李清照', '女', 25, '财务室', '出纳', '125478', '2012-03-04 00:00:00', '宋国');
INSERT INTO `employee` VALUES ('0007', '杨玉环', '女', 29, '财务室', '会计', '125478', '2010-02-04 00:00:00', '长安');
INSERT INTO `employee` VALUES ('0008', '孙权', '男', 35, '外交部', '部长', '150478', '2005-05-04 00:00:00', '江东');
INSERT INTO `employee` VALUES ('0009', '李世民', '男', 54, '董事会', '会长', '100865', '1998-05-08 00:00:00', '西安');
INSERT INTO `employee` VALUES ('0010', '项羽', '男', 40, '经理室', '副经理', '1008670', '2000-02-05 00:00:00', '彭城');
INSERT INTO `employee` VALUES ('0011', '李鸿章', '男', 52, '军机部', '部长', '1008699', '2001-05-08 00:00:00', '北京');
INSERT INTO `employee` VALUES ('0012', '张仪', '男', 44, '外交部', '部长', '10089', '2002-02-04 00:00:00', '魏国');
INSERT INTO `employee` VALUES ('0013', '朱元璋', '男', 35, '技术科', '部长', '100896', '2013-05-07 00:00:00', '南京');
INSERT INTO `employee` VALUES ('0014', '貂蝉', '女', 25, '经理室', '助理', '10086972', '2005-05-04 00:00:00', '洛阳');
INSERT INTO `employee` VALUES ('0015', '李渊', '男', 55, '董事会', '董事', '25897', '2001-02-05 00:00:00', '长安');
INSERT INTO `employee` VALUES ('0016', '1', '男', 1, '经理室', '1', '1', '2001-02-05 00:00:00', '2');

-- ----------------------------
-- Table structure for salary
-- ----------------------------
DROP TABLE IF EXISTS `salary`;
CREATE TABLE `salary`  (
  `salaryID` int(4) NOT NULL AUTO_INCREMENT,
  `ID` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `name` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
  `basepay` int(10) NULL DEFAULT NULL,
  `welfare` int(10) NULL DEFAULT NULL,
  `reward` int(10) NULL DEFAULT NULL,
  `insurance` int(10) NULL DEFAULT NULL,
  `funds` int(10) NULL DEFAULT NULL,
  `month` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `remark` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`salaryID`, `ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of salary
-- ----------------------------
INSERT INTO `salary` VALUES (1, '0001', '赢政', 3000, 100, 100, 100, 500, '1月', '未结算');
INSERT INTO `salary` VALUES (13, '0002', '刘邦', 3000, 200, 100, 100, 400, '1月', '未结算');
INSERT INTO `salary` VALUES (15, '0003', '武则天', 2500, 100, 200, 100, 300, '1月', '未结算');
INSERT INTO `salary` VALUES (16, '0004', '刘秀', 2900, 100, 150, 250, 200, '1月', '未结算');
INSERT INTO `salary` VALUES (17, '0005', '西施', 2800, 100, 100, 100, 300, '1月', '未结算');
INSERT INTO `salary` VALUES (18, '0006', '李清照', 2700, 120, 150, 100, 300, '1月', '未结算');
INSERT INTO `salary` VALUES (19, '0007', '杨玉环', 2680, 200, 150, 100, 300, '1月', '未结算');
INSERT INTO `salary` VALUES (20, '0008', '孙权', 2900, 100, 200, 100, 500, '1月', '未结算');
INSERT INTO `salary` VALUES (21, '0009', '李世民', 2870, 200, 100, 100, 300, '1月', '未结算');
INSERT INTO `salary` VALUES (22, '0010', '项羽', 2600, 200, 100, 100, 300, '1月', '未结算');
INSERT INTO `salary` VALUES (23, '0011', '李鸿章', 2800, 200, 100, 100, 300, '1月', '未结算');
INSERT INTO `salary` VALUES (24, '0012', '张仪', 2900, 200, 150, 100, 500, '1月', '未结算');
INSERT INTO `salary` VALUES (25, '0013', '朱元璋', 2600, 250, 200, 100, 400, '1月', '未结算');
INSERT INTO `salary` VALUES (26, '0001', '赢政', 3000, 100, 200, 100, 300, '2月', '未结算');
INSERT INTO `salary` VALUES (27, '0001', '赢政', 3000, 250, 200, 100, 400, '3月', '未结算');
INSERT INTO `salary` VALUES (28, '0002', '刘邦', 3000, 250, 150, 100, 400, '2月', '未结算');
INSERT INTO `salary` VALUES (29, '0002', '刘邦', 3000, 300, 150, 100, 500, '3月', '未结算');
INSERT INTO `salary` VALUES (30, '0003', '武则天', 2900, 200, 150, 100, 300, '2月', '未结算');
INSERT INTO `salary` VALUES (31, '0003', '武则天', 2800, 250, 120, 100, 500, '3月', '未结算');
INSERT INTO `salary` VALUES (33, '0004', '刘秀', 2580, 500, 200, 100, 300, '2月', '未结算');
INSERT INTO `salary` VALUES (35, '0004', '刘秀', 2900, 200, 150, 100, 300, '3月', '未结算');
INSERT INTO `salary` VALUES (37, '0005', '西施', 2900, 200, 100, 100, 300, '2月', '未结算');
INSERT INTO `salary` VALUES (39, '0005', '西施', 2800, 200, 150, 100, 300, '3月', '未结算');
INSERT INTO `salary` VALUES (40, '0006', '李清照', 2900, 200, 100, 100, 300, '2月', '未结算');
INSERT INTO `salary` VALUES (41, '0006', '李清照', 2900, 200, 100, 100, 300, '3月', '未结算');

-- ----------------------------
-- Table structure for userlist
-- ----------------------------
DROP TABLE IF EXISTS `userlist`;
CREATE TABLE `userlist`  (
  `status` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `username` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`username`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of userlist
-- ----------------------------
INSERT INTO `userlist` VALUES ('管理员', 'admin', 'admin');

-- ----------------------------
-- Table structure for view_salary
-- ----------------------------
DROP TABLE IF EXISTS `view_salary`;
CREATE TABLE `view_salary`  (
  `ID` int(10) NOT NULL AUTO_INCREMENT,
  `工号` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `姓名` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
  `部门` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
  `职位` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
  `总工资` int(10) NULL DEFAULT NULL,
  `月份` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `备注` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of view_salary
-- ----------------------------
INSERT INTO `view_salary` VALUES (1, '0001', '赢政', '经理室', '经理', 2600, '1月', '未结算');
INSERT INTO `view_salary` VALUES (9, '0002', '刘邦', '技术室', '技术长', 2800, '1月', '未结算');
INSERT INTO `view_salary` VALUES (11, '0003', '武则天', '财务室', '经理', 2400, '1月', '未结算');
INSERT INTO `view_salary` VALUES (12, '0004', '刘秀', '军机部', '大王', 2700, '1月', '未结算');
INSERT INTO `view_salary` VALUES (13, '0005', '西施', '财务室', '会计', 2600, '1月', '未结算');
INSERT INTO `view_salary` VALUES (14, '0006', '李清照', '财务室', '出纳', 2570, '1月', '未结算');
INSERT INTO `view_salary` VALUES (15, '0007', '杨玉环', '财务室', '会计', 2630, '1月', '未结算');
INSERT INTO `view_salary` VALUES (16, '0008', '孙权', '外交部', '部长', 2600, '1月', '未结算');
INSERT INTO `view_salary` VALUES (17, '0009', '李世民', '董事会', '会长', 2770, '1月', '未结算');
INSERT INTO `view_salary` VALUES (18, '0010', '项羽', '经理室', '副经理', 2500, '1月', '未结算');
INSERT INTO `view_salary` VALUES (19, '0011', '李鸿章', '军机部', '部长', 2700, '1月', '未结算');
INSERT INTO `view_salary` VALUES (20, '0012', '张仪', '外交部', '部长', 2650, '1月', '未结算');
INSERT INTO `view_salary` VALUES (21, '0013', '朱元璋', '技术科', '部长', 2550, '1月', '未结算');
INSERT INTO `view_salary` VALUES (22, '0001', '赢政', '经理室', '经理', 2900, '2月', '未结算');
INSERT INTO `view_salary` VALUES (23, '0001', '赢政', '经理室', '经理', 2950, '3月', '未结算');
INSERT INTO `view_salary` VALUES (24, '0002', '刘邦', '技术室', '技术长', 2900, '2月', '未结算');
INSERT INTO `view_salary` VALUES (25, '0002', '刘邦', '技术室', '技术长', 2850, '3月', '未结算');
INSERT INTO `view_salary` VALUES (26, '0003', '武则天', '财务室', '经理', 2850, '2月', '未结算');
INSERT INTO `view_salary` VALUES (27, '0003', '武则天', '财务室', '经理', 2570, '3月', '未结算');
INSERT INTO `view_salary` VALUES (35, '0004', '刘秀', '军机部', '副部长', 2850, '3月', '未结算');
INSERT INTO `view_salary` VALUES (36, '0004', '刘秀', '军机部', '副部长', 2750, '2月', '未结算');
INSERT INTO `view_salary` VALUES (37, '0005', '西施', '财务室', '会计', 2800, '2月', '未结算');
INSERT INTO `view_salary` VALUES (39, '0005', '西施', '财务室', '会计', 2750, '3月', '未结算');
INSERT INTO `view_salary` VALUES (40, '0006', '李清照', '财务室', '出纳', 2800, '2月', '未结算');
INSERT INTO `view_salary` VALUES (41, '0006', '李清照', '财务室', '出纳', 2800, '3月', '未结算');
INSERT INTO `view_salary` VALUES (42, '0001', '赢政', '经理室', '经理', 1, '1月', '未结算');

SET FOREIGN_KEY_CHECKS = 1;

二、系统展示

1.登录系统

2.用户-登录系统

3.用户-查看工资

4.管理员-主界面

5.管理员-添加员工信息

6.管理员-修改员工信息

7.管理员-删除员工信息

8.管理员-添加部门信息

9.管理员-修改部门信息

10.管理员-删除部门信息

11.管理员-工资设定

12.管理员-工资查询

13.管理员-工资一览

三、部分代码

Login.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Login.java
 *
 * Created on 2013-6-16, 21:34:00
 */

package com.sjsq;

import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class Login extends javax.swing.JFrame 

	static String status;
	static String name;

	private Toolkit tk = Toolkit.getDefaultToolkit();
	int x = tk.getScreenSize().width / 2 - 180;
	int y = tk.getScreenSize().height / 2 - 180;

	/** Creates new form Login */
	public Login() 
		initComponents();
		setLocation(x, y);
		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
	

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated
	// Code">//GEN-BEGIN:initComponents
	private void initComponents() 

		jComboBox1 = new javax.swing.JComboBox();
		username = new javax.swing.JTextField();
		jPasswordField1 = new javax.swing.JPasswordField();
		jLabel1 = new javax.swing.JLabel();
		jLabel2 = new javax.swing.JLabel();
		jLabel3 = new javax.swing.JLabel();
		jButton1 = new javax.swing.JButton();
		jButton2 = new javax.swing.JButton();
		jLabel4 = new javax.swing.JLabel();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("登录界面");

		jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[]  "管理员", "员工" ));
		jComboBox1.addItemListener(new ItemListener() 

			@Override
			public void itemStateChanged(ItemEvent e) 
				// TODO Auto-generated method stub
				if (e.getStateChange() == ItemEvent.SELECTED) 
					if ("员工".equals(e.getItem())) 
						jButton1.setText("查询工资");
						jLabel2.hide();
						username.hide();
						jPasswordField1.hide();
						jLabel3.hide();
						jPasswordField1.hide();
					 else 
						jButton1.setText("登录");
						jLabel2.show();
						username.show();
						jPasswordField1.show();
						jLabel3.show();
						jPasswordField1.show();
					

				
			
		);
		// username.setText("quan");

		jLabel1.setText("身份:");

		jLabel2.setText("账号:");

		jLabel3.setText("密码:");

		jButton1.setText("登录");
		jButton1.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jButton1ActionPerformed(evt);
			
		);

		jButton2.setText("退出");
		jButton2.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jButton2ActionPerformed(evt);
			
		);

		jLabel4.setForeground(new java.awt.Color(255, 0, 0));
		jLabel4.setText("注:员工可以匿名登录");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
				.createSequentialGroup()
				.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
						.createSequentialGroup().addGap(80, 80, 80)
						.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
								.addComponent(jLabel1).addComponent(jLabel3).addComponent(jLabel2))
						.addGap(18, 18, 18)
						.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 92,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addGroup(layout.createSequentialGroup()
										.addGroup(layout
												.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
												.addComponent(username, javax.swing.GroupLayout.Alignment.LEADING)
												.addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.LEADING, 0,
														javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
										.addGap(18, 18, 18).addComponent(jLabel4))))
						.addGroup(layout.createSequentialGroup().addGap(110, 110, 110).addComponent(jButton1)
								.addGap(39, 39, 39).addComponent(jButton2)))
				.addContainerGap(54, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup().addGap(65, 65, 65)
						.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
								.addComponent(jLabel1).addComponent(jLabel4))
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
								.addComponent(jLabel2))
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(jLabel3).addComponent(jPasswordField1,
										javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
										javax.swing.GroupLayout.PREFERRED_SIZE))
						.addGap(35, 35, 35)
						.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(jButton1).addComponent(jButton2))
						.addContainerGap(102, Short.MAX_VALUE)));

		pack();
	// </editor-fold>//GEN-END:initComponents

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jButton1ActionPerformed
		// TODO add your handling code here:

		status = (String) jComboBox1.getSelectedItem();
		name = username.getText();
		String password = jPasswordField1.getText();

		if (status.equals("管理员")) 
			if (name.equals("")) 
				JOptionPane.showMessageDialog(null, "用户名不能为空!!");
			 else if (password.equals("")) 
				JOptionPane.showMessageDialog(null, "密码不能为空!!");
			 else 
				String sql = "select username from userlist where status = '" + status + "' and username = '" + name
						+ "' and password = '" + password + "'";
				// String sql = "select * from userlist";
				System.out.println(sql);
				DBConn db = new DBConn();
				if (db.Check(sql) != 0) 
					new MainFrame().setVisible(true);
					this.hide();
				 else 
					JOptionPane.showMessageDialog(null, "用户名与密码不对!!");
				
			
		 else 
			new SalarySearch().setVisible(true);
		
	// GEN-LAST:event_jButton1ActionPerformed

	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jButton2ActionPerformed
		// TODO add your handling code here:
		int selection = JOptionPane.showConfirmDialog(this, "是否退出?", "退出提示", JOptionPane.OK_CANCEL_OPTION,
				JOptionPane.WARNING_MESSAGE);
		if (selection == JOptionPane.OK_OPTION) 
			System.exit(0);
		
	// GEN-LAST:event_jButton2ActionPerformed

	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[]) 
		java.awt.EventQueue.invokeLater(new Runnable() 
			public void run() 
				new Login().setVisible(true);
			
		);
	

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton jButton1;
	private javax.swing.JButton jButton2;
	private javax.swing.JComboBox jComboBox1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JPasswordField jPasswordField1;
	private javax.swing.JTextField username;
	// End of variables declaration//GEN-END:variables



MainFrame.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFrame.java
 *
 * Created on 2013-6-18, 22:12:20
 */

package com.sjsq;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class MainFrame extends javax.swing.JFrame 

	/** Creates new form MainFrame */
	private Toolkit tk = Toolkit.getDefaultToolkit();
	int x = tk.getScreenSize().width / 2 - 250;
	int y = tk.getScreenSize().height / 2 - 250;

	public MainFrame() 
		setTitle("工资管理系统");
		setLocation(x, y);
		initComponents();
		// this.setDefaultCloseOperation(MainFrame.DO_NOTHING_ON_CLOSE);
	

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated
	// Code">//GEN-BEGIN:initComponents
	private void initComponents() 

		jColorChooser1 = new javax.swing.JColorChooser();
		jPanel1 = new javax.swing.JPanel() 
			protected void paintComponent(Graphics g) 
				super.paintComponent(g);
				Image img = Toolkit.getDefaultToolkit().getImage("src/resource/009.jpg");
				Graphics gg = g.create();
				gg.drawImage(img, 0, 0, getWidth(), getHeight(), this);
				gg.dispose();
			
		;
		jMenuBar1 = new javax.swing.JMenuBar();
		jMenu1 = new javax.swing.JMenu();
		jMenuItem1 = new javax.swing.JMenuItem();
		jMenuItem2 = new javax.swing.JMenuItem();
		jMenuItem3 = new javax.swing.JMenuItem();
		jMenu2 = new javax.swing.JMenu();
		jMenuItem4 = new javax.swing.JMenuItem();
		jMenuItem5 = new javax.swing.JMenuItem();
		jMenuItem6 = new javax.swing.JMenuItem();
		jMenu3 = new javax.swing.JMenu();
		jMenuItem7 = new javax.swing.JMenuItem();
		jMenuItem8 = new javax.swing.JMenuItem();
		jMenuItem12 = new javax.swing.JMenuItem();
		jMenu4 = new javax.swing.JMenu();
		jMenuItem9 = new javax.swing.JMenuItem();
		jMenuItem10 = new javax.swing.JMenuItem();
		jMenuItem13 = new javax.swing.JMenuItem();
		jMenu5 = new javax.swing.JMenu();
		jMenuItem11 = new javax.swing.JMenuItem();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

		jPanel1.addAncestorListener(new javax.swing.event.AncestorListener() 
			public void ancestorMoved(javax.swing.event.AncestorEvent evt) 
			

			public void ancestorAdded(javax.swing.event.AncestorEvent evt) 
				jPanel1AncestorAdded(evt);
			

			public void ancestorRemoved(javax.swing.event.AncestorEvent evt) 
			
		);

		javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGap(0, 637, Short.MAX_VALUE));
		jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGap(0, 365, Short.MAX_VALUE));

		jMenu1.setText("员工信息管理");
		jMenu1.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenu1ActionPerformed(evt);
			
		);

		jMenuItem1.setAccelerator(
				javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem1.setText("添加员工信息");
		jMenuItem1.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem1ActionPerformed(evt);
			
		);
		jMenu1.add(jMenuItem1);

		jMenuItem2.setAccelerator(
				javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem2.setText("修改员工信息");
		jMenuItem2.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem2ActionPerformed(evt);
			
		);
		jMenu1.add(jMenuItem2);

		jMenuItem3.setAccelerator(
				javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem3.setText("删除员工信息");
		jMenuItem3.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem3ActionPerformed(evt);
			
		);
		jMenu1.add(jMenuItem3);

		jMenuBar1.add(jMenu1);

		jMenu2.setText("部门信息管理");

		jMenuItem4.setText("新增部门信息");
		jMenuItem4.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem4ActionPerformed(evt);
			
		);
		jMenu2.add(jMenuItem4);

		jMenuItem5.setText("修改部门信息");
		jMenuItem5.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem5ActionPerformed(evt);
			
		);
		jMenu2.add(jMenuItem5);

		jMenuItem6.setText("删除部门信息");
		jMenuItem6.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem6ActionPerformed(evt);
			
		);
		jMenu2.add(jMenuItem6);

		jMenuBar1.add(jMenu2);

		jMenu3.setText("员工工资设定");

		jMenuItem7.setText("工资设定");
		jMenuItem7.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem7ActionPerformed(evt);
			
		);
		jMenu3.add(jMenuItem7);

		jMenuItem8.setText("工资查询");
		jMenuItem8.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem8ActionPerformed(evt);
			
		);
		jMenu3.add(jMenuItem8);

		jMenuItem12.setText("工资一览表");
		jMenuItem12.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem12ActionPerformed(evt);
			
		);
		jMenu3.add(jMenuItem12);

		jMenuBar1.add(jMenu3);

		jMenu4.setText("系统设置");

		jMenuItem9.setText("信息统计");
		jMenuItem9.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem9ActionPerformed(evt);
			
		);
		jMenu4.add(jMenuItem9);

		jMenuItem10.setText("修改密码");
		jMenuItem10.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem10ActionPerformed(evt);
			
		);
		jMenu4.add(jMenuItem10);

		jMenuItem13.setText("添加管理员");
		jMenuItem13.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem13ActionPerformed(evt);
			
		);
		jMenu4.add(jMenuItem13);

		jMenuBar1.add(jMenu4);

		jMenu5.setText("退出系统");
		jMenu5.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenu5ActionPerformed(evt);
			
		);

		jMenuItem11.setText("退出本系统");
		jMenuItem11.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jMenuItem11ActionPerformed(evt);
			
		);
		jMenu5.add(jMenuItem11);

		jMenuBar1.add(jMenu5);

		setJMenuBar(jMenuBar1);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE,
				javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
		layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));

		pack();
	// </editor-fold>//GEN-END:initComponents

	private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem1ActionPerformed
		// TODO add your handling code here:
		new AddEmployee().setVisible(true);
	// GEN-LAST:event_jMenuItem1ActionPerformed

	private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem2ActionPerformed
		// TODO add your handling code here:
		new ModifyEmployee().setVisible(true);
	// GEN-LAST:event_jMenuItem2ActionPerformed

	private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem3ActionPerformed
		// TODO add your handling code here:
		new DeleteEmployee().setVisible(true);
	// GEN-LAST:event_jMenuItem3ActionPerformed

	private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem4ActionPerformed
		// TODO add your handling code here:
		new AddDepartment().setVisible(true);
	// GEN-LAST:event_jMenuItem4ActionPerformed

	private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem5ActionPerformed
		// TODO add your handling code here:
		new ModifyDepartment().setVisible(true);
	// GEN-LAST:event_jMenuItem5ActionPerformed

	private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem6ActionPerformed
		// TODO add your handling code here:
		new DeleteDepartment().setVisible(true);
	// GEN-LAST:event_jMenuItem6ActionPerformed

	private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem7ActionPerformed
		// TODO add your handling code here:
		new SalarySetting().setVisible(true);
	// GEN-LAST:event_jMenuItem7ActionPerformed

	private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem8ActionPerformed
		// TODO add your handling code here:
		new SalarySearch().setVisible(true);
	// GEN-LAST:event_jMenuItem8ActionPerformed

	private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem9ActionPerformed
		// TODO add your handling code here:
		new Statistics().setVisible(true);
	// GEN-LAST:event_jMenuItem9ActionPerformed

	private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem10ActionPerformed
		// TODO add your handling code here:
		new ModifyPassWord().setVisible(true);
	// GEN-LAST:event_jMenuItem10ActionPerformed

	private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem11ActionPerformed
		// TODO add your handling code here:
		int option = JOptionPane.showConfirmDialog(null, "确定要退出本系统?", "系统提示", JOptionPane.YES_NO_OPTION);
		if (option == JOptionPane.YES_OPTION)
			System.exit(0);
		else
			this.setDefaultCloseOperation(MainFrame.DO_NOTHING_ON_CLOSE);
	// GEN-LAST:event_jMenuItem11ActionPerformed

	private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem12ActionPerformed
		// TODO add your handling code here:
		new SalaryShow().setVisible(true);
	// GEN-LAST:event_jMenuItem12ActionPerformed

	private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItem13ActionPerformed
		// TODO add your handling code here:
		new NewManager().setVisible(true);
	// GEN-LAST:event_jMenuItem13ActionPerformed

	private void jMenu5ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenu5ActionPerformed
		// TODO add your handling code here:
	// GEN-LAST:event_jMenu5ActionPerformed

	private void jPanel1AncestorAdded(javax.swing.event.AncestorEvent evt) // GEN-FIRST:event_jPanel1AncestorAdded
		// TODO add your handling code here:
	// GEN-LAST:event_jPanel1AncestorAdded

	private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenu1ActionPerformed
		// TODO add your handling code here:
	// GEN-LAST:event_jMenu1ActionPerformed

	/**
	 * @param args the command line arguments
	 */
	/*
	 * public static void main(String args[])  java.awt.EventQueue.invokeLater(new
	 * Runnable()  public void run()  new MainFrame().setVisible(true);  ); 
	 */
	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JColorChooser jColorChooser1;
	private javax.swing.JMenu jMenu1;
	private javax.swing.JMenu jMenu2;
	private javax.swing.JMenu jMenu3;
	private javax.swing.JMenu jMenu4;
	private javax.swing.JMenu jMenu5;
	private javax.swing.JMenuBar jMenuBar1;
	private javax.swing.JMenuItem jMenuItem1;
	private javax.swing.JMenuItem jMenuItem10;
	private javax.swing.JMenuItem jMenuItem11;
	private javax.swing.JMenuItem jMenuItem12;
	private javax.swing.JMenuItem jMenuItem13;
	private javax.swing.JMenuItem jMenuItem2;
	private javax.swing.JMenuItem jMenuItem3;
	private javax.swing.JMenuItem jMenuItem4;
	private javax.swing.JMenuItem jMenuItem5;
	private javax.swing.JMenuItem jMenuItem6;
	private javax.swing.JMenuItem jMenuItem7;
	private javax.swing.JMenuItem jMenuItem8;
	private javax.swing.JMenuItem jMenuItem9;
	private javax.swing.JPanel jPanel1;
	// End of variables declaration//GEN-END:variables



DBConn.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sjsq;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class DBConn 

	private Connection conn = null;
	private Statement stmt = null;
	private ResultSet rs = null;
	String url = "jdbc:mysql://localhost/swing_salary_management?serverTimezone=UTC";
	String username = "root";
	String password = "admin";

	public DBConn()  // 构造方法

		try 
			Class.forName("com.mysql.cj.jdbc.Driver");
			// conn = DriverManager.getConnection(url,username,password);
		 catch (java.lang.ClassNotFoundException e) 
			System.err.println(e.getMessage());
		 // catch (SQLException ex) 
			// Logger.getLogger(DBConn.class.getName()).log(Level.SEVERE, null, ex);
			// 
	

	public int Check(String sql) 
		// int result = 0;
		try 
			conn = DriverManager.getConnection(url, username, password);
			stmt = conn.createStatement();
			rs = stmt.executeQuery(sql);
			if (rs.next()) 
				return 1;
			
		 catch (SQLException e) 
			e.printStackTrace();
		
		return 0;
	

	public ResultSet Search(String sql)  // 建立查询

		try 
			conn = DriverManager.getConnection(url, username, password);
			stmt = conn.createStatement();
			rs = stmt.executeQuery(sql);
		 catch (SQLException ex) 
			System.err.println(ex.getMessage());
		
		return rs;
	

	public int Update(String sql)  // 操作数据库

		int result = 0;
		try 
			conn = DriverManager.getConnection(url, username, password);
			stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
			result = stmt.executeUpdate(sql);
		 catch (SQLException ex) 
			result = 0;
		
		return result;
	

	/**
	 * 关闭数据库连接
	 */
	public void close() 
		try 
			if (rs != null) 
				rs.close();
			
		 catch (Exception e) 
			e.printStackTrace(System.err);
		

		try 
			if (stmt != null) 
				stmt.close();
			
		 catch (Exception e) 
			e.printStackTrace(System.err);
		

		try 
			if (conn != null) 
				conn.close();
			
		 catch (Exception e) 
			e.printStackTrace(System.err);
		
	



AddDepartment.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AddDepartment.java
 *
 * Created on 2013-6-22, 12:14:44
 */

package com.sjsq;

//import SQLConnection.DBConn;
import java.awt.Toolkit;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class AddDepartment extends javax.swing.JFrame 

	/** Creates new form AddDepartment */
	private Toolkit tk = Toolkit.getDefaultToolkit();
	int x = tk.getScreenSize().width / 2 - 100;
	int y = tk.getScreenSize().height / 2 - 100;

	public AddDepartment() 
		initComponents();
		setTitle("添加部门信息");
		setLocation(x, y);
		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
	

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated
	// Code">//GEN-BEGIN:initComponents
	private void initComponents() 

		jPanel1 = new javax.swing.JPanel();
		jLabel1 = new javax.swing.JLabel();
		jLabel2 = new javax.swing.JLabel();
		jLabel3 = new javax.swing.JLabel();
		jLabel4 = new javax.swing.JLabel();
		jTextField1 = new javax.swing.JTextField();
		jTextField2 = new javax.swing.JTextField();
		jTextField3 = new javax.swing.JTextField();
		jTextField4 = new javax.swing.JTextField();
		jButton1 = new javax.swing.JButton();
		jButton2 = new javax.swing.JButton();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("部门信息"));

		jLabel1.setText("部门编号:");

		jLabel2.setText("部门名称:");

		jLabel3.setText("负责人:");

		jLabel4.setText("总人数:");

		jTextField1.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jTextField1ActionPerformed(evt);
			
		);

		jTextField2.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jTextField2ActionPerformed(evt);
			
		);

		jTextField3.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jTextField3ActionPerformed(evt);
			
		);

		jTextField4.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jTextField4ActionPerformed(evt);
			
		);

		jButton1.setText("添加");
		jButton1.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jButton1ActionPerformed(evt);
			
		);

		jButton2.setText("取消");
		jButton2.addActionListener(new java.awt.event.ActionListener() 
			public void actionPerformed(java.awt.event.ActionEvent evt) 
				jButton2ActionPerformed(evt);
			
		);

		javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout
						.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
								.addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel1)
										.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 70,
												javax.swing.GroupLayout.PREFERRED_SIZE))
								.addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel2)
										.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(jTextField2))
								.addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel3).addGap(18, 18, 18)
										.addComponent(jTextField3)))
						.addGroup(jPanel1Layout.createSequentialGroup().addComponent(jButton1).addGap(18, 18, 18)
								.addComponent(jButton2))
						.addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel4).addGap(18, 18, 18)
								.addComponent(jTextField4)))
						.addContainerGap(16, Short.MAX_VALUE)));
		jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
						.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(jLabel1).addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
						.addGap(18, 18, 18)
						.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(jLabel2).addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
						.addGap(18, 18, 18)
						.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(jLabel3).addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(jLabel4).addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
						.addGap(18, 18, 18)
						.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(jButton1).addComponent(jButton2))
						.addContainerGap(18, Short.MAX_VALUE)));

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup().addGap(79, 79, 79)
						.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
								javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(145, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup().addGap(22, 22, 22)
						.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
								javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(54, Short.MAX_VALUE)));

		pack();
	// </editor-fold>//GEN-END:initComponents

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jButton1ActionPerformed
		// TODO add your handling code here:
		String strID = jTextField1.getText(); // 部门编号
		String strName = jTextField2.getText(); // 部门姓名
		String strDirector = jTextField3.getText(); // 负责人
		String strNumber = jTextField4.getText(); // 总人数

		if (strID.equals("")) 
			JOptionPane.showMessageDialog(null, "部门编号不能为空!");
		 else if (strName.equals("")) 
			JOptionPane.showMessageDialog(null, "部门名称不能为空!");
		 else if (strDirector.equals("")) 
			JOptionPane.showMessageDialog(null, "部门负责人不能为空!");
		 else 

			// int ID = Integer.parseInt(strID);
			int Number = Integer.parseInt(strNumber);
			String checksql = "select id from department where id = '" + strID + " '";
			System.out.println(checksql);
			DBConn db = new DBConn();

			if (db.Check(checksql) != 0) 
				JOptionPane.showMessageDialog(null, "该号已存在!!!");
			 else 
				String sql = "insert into department values('" + strID + "','" + strName + "','" + strDirector + "','"
						+ Number + "')";
				int result = db.Update(sql);
				if (result != 0) 
					JOptionPane.showMessageDialog(null, "部门添加成功!!!");
				 else 
					JOptionPane.showMessageDialog(null, "部门添加失败,请重新添加!");
				
			
		
		jTextField1.setText("");
		jTextField2.setText("");
		jTextField3.setText("");
		jTextField4.setText("");
	// GEN-LAST:event_jButton1ActionPerformed

	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jButton2ActionPerformed
		// TODO add your handling code here:
		jTextField1.setText("");
		jTextField2.setText("");
		jTextField3.setText("");
		jTextField4.setText("");
	// GEN-LAST:event_jButton2ActionPerformed

	private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jTextField1ActionPerformed
		// TODO add your handling code here:
	// GEN-LAST:event_jTextField1ActionPerformed

	private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) // GEN-FIRST:event_jTextField2ActionPerformed
		// TODO add you

以上是关于Eclipse+Java+Swing+Mysql实现员工工资管理系统的主要内容,如果未能解决你的问题,请参考以下文章

Eclipse+Java+Swing+Mysql实现超市管理系统

Eclipse+Java+Swing+Mysql实现酒店管理系统

Eclipse+Java+Swing+Mysql实现学生信息管理系统

Eclipse+Java+Swing+Mysql实现进销存管理系统建议收藏

Eclipse+Java+Swing+Mysql实现自助存取款机(ATM)系统

Eclipse+Java+Swing+Mysql实现仓库管理系统