Eclipse+Java+Swing实现企业人事管理系统(上)

简介: Eclipse+Java+Swing实现企业人事管理系统

一、系统介绍


本系统实现的功能:用户登录、员工信息的增删改查、导出Execl、计算器、记事本、信息排序。采用AES加密算法,数据库使用Mysql8.0.13,界面良好。


二、系统展示


1.登录页


2020122121301829.jpg


2.主页面


20201221213041903.jpg


3.添加员工信息


20201221213111221.jpg


4.修改员工信息


20201221213131335.jpg


5.计算器


20201221213148786.jpg


6.记事本


20201221213208483.jpg


7.导出Execl


20201221213233939.jpg


三、系统实现


AccountDao.java

package com.sjsq.dao;
import java.util.List;
import com.sjsq.model.TbAccount;
import com.sjsq.model.TbDept;
import com.sjsq.model.TbPerson;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import com.sjsq.tools.JDBCUtils;
public class AccountDao {
  private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
  public static List<TbAccount> findAllAccount() {
    try {
      String sql = "select * from tb_account";
      List<TbAccount> a = template.query(sql, new BeanPropertyRowMapper<TbAccount>(TbAccount.class));
      return a;
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
  public static String findAccountMoneyById(int i) {
    try {
      String sql = "select * from tb_account where timecard_id=?";
      TbAccount tbAccount = template.queryForObject(sql, new BeanPropertyRowMapper<TbAccount>(TbAccount.class),
          i);
      return tbAccount.getMoney();
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
}

DeptDao.java

package com.sjsq.dao;
import java.util.List;
import com.sjsq.model.TbDept;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import com.sjsq.tools.JDBCUtils;
public class DeptDao {
  private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
  public static TbDept findDeptById(int deptId) {
    String sql = "select * from tb_dept where id=?";
    TbDept dept = template.queryForObject(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class), deptId);
    return dept;
  }
  public static List<TbDept> findAllDept() {
    try {
      String sql = "select * from tb_dept";
      List<TbDept> tbDept = template.query(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class));
      return tbDept;
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
  public static int findDeptIdByName(String item) {
    String sql = "select * from tb_dept where name=?";
    TbDept dept = template.queryForObject(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class), item);
    return dept.getId();
  }
  public static List<TbDept> findAllDeptExceptZero() {
    try {
      String sql = "select * from tb_dept where id<>0";
      List<TbDept> tbDept = template.query(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class));
      return tbDept;
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
  public static TbDept findDeptByName(String name) {
    try {
      String sql = "select * from tb_dept where name=?";
      TbDept dept = template.queryForObject(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class), name);
      return dept;
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
  public static void addDept(TbDept d2) {
    try {
      String sql = "insert into tb_dept(name) values (?)";
      template.update(sql, d2.getName());
    } catch (DataAccessException e) {
      e.printStackTrace();
    }
  }
  public static void deleteDeptById(int id) {
    try {
      String sql = "delete from tb_dept where id=?";
      template.update(sql, id);
    } catch (DataAccessException e) {
      e.printStackTrace();
    }
  }
  public static void updateDept(int id, String input) {
    try {
      String sql = "update tb_dept set name = ? where id = ?";
      template.update(sql, input, id);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

PersonDao.java

package com.sjsq.dao;
import java.util.List;
import com.sjsq.model.TbPerson;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import com.sjsq.tools.JDBCUtils;
import com.sjsq.tools.PwEncryption;
public class PersonDao {
  private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
  public static TbPerson queryRecordByNum(String num) {
    try {
      String sql = "select * from tb_person where record_number=?";
      TbPerson tbRecord = template.queryForObject(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class), num);
      return tbRecord;
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
  public static List<TbPerson> findAllPerson() {
    try {
      String sql = "select * from tb_person";
      List<TbPerson> tbPerson = template.query(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class));
      return tbPerson;
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
  public static List<TbPerson> likePersonByRecordNumber(String recordNumber) {
    try {
      String sql = "select * from tb_person where record_number like '%' ? '%'";
      List<TbPerson> tbPerson = template.query(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class),
          recordNumber);
      return tbPerson;
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
  public static List<TbPerson> findPersonByDeptId(int i) {
    try {
      String sql = "select * from tb_person where dept_id=?";
      List<TbPerson> tbPerson = template.query(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class), i);
      return tbPerson;
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
  public static TbPerson findPersonByRecordNumber(String recordNumber) {
    try {
      String sql = "select * from tb_person where record_number=?";
      TbPerson tbPerson = template.queryForObject(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class),
          recordNumber);
      return tbPerson;
    } catch (DataAccessException e) {
      System.out.println("查找员工为空数据");
      e.printStackTrace();
      return null;
    }
  }
  public static void updatePerson(TbPerson person) {
    try {
      String sql = "update tb_person set dept_id=?,duty_id=?,name=?,sex=?,"
          + "birthday=?,photo=?,id_card=?,marriaged=?,native_place_id=?,"
          + "party_member=?,school_age=?,specialty=?,foreign_language=?,"
          + "grade=?,state=?,role_id=? where record_number=?";
      template.update(sql, person.getDeptId(), person.getDutyId(), person.getName(), person.getSex(),
          person.getBirthday(), person.getPhoto(), person.getIdCard(), person.getMarriaged(),
          person.getNativePlaceId(), person.getPartyMember(), person.getSchoolAge(), person.getSpecialty(),
          person.getForeignLanguage(), person.getGrade(), person.getState(), person.getRoleId(),
          person.getRecordNumber());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public static void addPerson(TbPerson person) {
    try {
      String sql = "insert into tb_person(record_number,dept_id,duty_id,name,sex,"
          + "birthday,photo,id_card,marriaged,native_place_id,"
          + "party_member,school_age,specialty,foreign_language,"
          + "grade,state,role_id) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
      template.update(sql, person.getRecordNumber(), person.getDeptId(), person.getDutyId(), person.getName(),
          person.getSex(), person.getBirthday(), person.getPhoto(), person.getIdCard(), person.getMarriaged(),
          person.getNativePlaceId(), person.getPartyMember(), person.getSchoolAge(), person.getSpecialty(),
          person.getForeignLanguage(), person.getGrade(), person.getState(), person.getRoleId());
    } catch (DataAccessException e) {
      e.printStackTrace();
    }
  }
  public static void deletePersonByrecordNumber(String recordNumber) {
    try {
      String sql = "delete from tb_person where record_number=?";
      template.update(sql, recordNumber);
    } catch (DataAccessException e) {
      e.printStackTrace();
    }
  }
  public static TbPerson login(TbPerson person) {
    try {
      String sql = "select * from tb_person where record_number=? and password=?";
      TbPerson tbPerson = template.queryForObject(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class),
          person.getRecordNumber(), person.getPassword());
      return tbPerson;
    } catch (DataAccessException e) {
      System.out.println("空结果数据访问异常");
      e.printStackTrace();
      return null;
    }
  }
  public static void updatePersonPassword(TbPerson person) {
    try {
      String sql = "update tb_person set password = ? where record_number= ?";
      template.update(sql, person.getPassword(), person.getRecordNumber());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public static List<TbPerson> likePersonByName(String name) {
    try {
      String sql = "select * from tb_person where name like '%' ? '%'";
      List<TbPerson> tbPerson = template.query(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class), name);
      return tbPerson;
    } catch (DataAccessException e) {
      e.printStackTrace();
      return null;
    }
  }
  public static void main(String args[]) {
    String userName = "T00001";
    String password = "123456";
    TbPerson person = new TbPerson(userName, PwEncryption.encrypt(password, "key"));
    login(person);
  }
}
相关文章
|
10天前
|
运维 自然语言处理 供应链
Java云HIS医院管理系统源码 病案管理、医保业务、门诊、住院、电子病历编辑器
通过门诊的申请,或者直接住院登记,通过”护士工作站“分配患者,完成后,进入医生患者列表,医生对应开具”长期医嘱“和”临时医嘱“,并在电子病历中,记录病情。病人出院时,停止长期医嘱,开具出院医嘱。进入出院审核,审核医嘱与住院通过后,病人结清缴费,完成出院。
35 3
|
13天前
|
Java 数据库连接 数据库
深入探讨Java连接池技术如何通过复用数据库连接、减少连接建立和断开的开销,从而显著提升系统性能
在Java应用开发中,数据库操作常成为性能瓶颈。本文通过问题解答形式,深入探讨Java连接池技术如何通过复用数据库连接、减少连接建立和断开的开销,从而显著提升系统性能。文章介绍了连接池的优势、选择和使用方法,以及优化配置的技巧。
16 1
|
15天前
|
JavaScript Java 项目管理
Java毕设学习 基于SpringBoot + Vue 的医院管理系统 持续给大家寻找Java毕设学习项目(附源码)
基于SpringBoot + Vue的医院管理系统,涵盖医院、患者、挂号、药物、检查、病床、排班管理和数据分析等功能。开发工具为IDEA和HBuilder X,环境需配置jdk8、Node.js14、MySQL8。文末提供源码下载链接。
|
18天前
|
移动开发 前端开发 JavaScript
java家政系统成品源码的关键特点和技术应用
家政系统成品源码是已开发完成的家政服务管理软件,支持用户注册、登录、管理个人资料,家政人员信息管理,服务项目分类,订单与预约管理,支付集成,评价与反馈,地图定位等功能。适用于各种规模的家政服务公司,采用uniapp、SpringBoot、MySQL等技术栈,确保高效管理和优质用户体验。
|
20天前
|
XML JSON 监控
告别简陋:Java日志系统的最佳实践
【10月更文挑战第19天】 在Java开发中,`System.out.println()` 是最基本的输出方法,但它在实际项目中往往被认为是不专业和不足够的。本文将探讨为什么在现代Java应用中应该避免使用 `System.out.println()`,并介绍几种更先进的日志解决方案。
44 1
|
6月前
|
Java
Java Swing猜英文单词游戏(java+面向对象编程+swing+awt+io流)
Java Swing猜英文单词游戏(java+面向对象编程+swing+awt+io流)
|
Oracle 安全 Java
Java GUI框架选择什么?Swing,SWT,AWT,SwingX,JGoodies,JavaFX,Apache Pivot?
Java GUI框架选择什么?Swing,SWT,AWT,SwingX,JGoodies,JavaFX,Apache Pivot?
1464 0
|
Java Spring
[SOLVED] Caused by: java.awt.HeadlessException when trying to create a SWING/AWT frame from Sprin...
[SOLVED] Caused by: java.awt.HeadlessException when trying to create a SWING/AWT frame from Spring Boot In Spring Boot, when y...
1367 0