当前位置:首页 > JAVA课设职工信息管理系统
二、总体设计
根据需求分析,整个职工管理系统的功能结构如图1所示:
职工信息管理系统 信息维护 查询管理 职修信 工改息信 更删息新除 查询
图1 系统功能结构图
基础功能 系统管理 入职工信息录 护用户信息维 密码修改退出系统 - 2 -
三、详细设计
3.1基础数据类定义
3.1.1职工数据定义
public class Staff { }
private String id; // 职工号 private String name; // 姓名 private String type; // 任职类型 private String xueli; // 学历 private String address; // 地址 private String sex; // 性别 private int age; // 年龄 private double salary; // 工资
3.1.2用户数据定义
public class User { }
private String id; // 用户编号 private String name; // 用户姓名 private String sex; // 性别 private String type; // 用户类别
3.1.3数据库操作定义
public class BaseDao {
protected static String driver = \; // 数据库驱动 protected
static
String
url
=
%utf8\; // 连接url
// 构造方法,创建数据库连接 private BaseDao() {
try {
if (conn == null) {
protected static String dbUser = \; // 数据库用户名 protected static String dbPwd = \; // 数据库密码 private static Connection conn = null;
- 3 -
}
Class.forName(driver); // 加载数据库驱动
conn = DriverManager.getConnection(url, dbUser, dbPwd); // 建立
数据库连接
} else
return;
} catch (Exception ee) { }
System.out.println(\数 据 库 连 接 失 败 !\); ee.printStackTrace();
// 执行数据库查询操作
public static ResultSet executeQuery(String sql) { }
try {
if (conn == null)
new BaseDao();
return conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE).executeQuery(sql); // 执行数据
库查询
} catch (SQLException e) { }
e.printStackTrace(); return null;
// 执行数据库更新操作
public static int executeUpdate(String sql) { }
public static void close() {
try {
conn.close();
e.printStackTrace(); } catch (SQLException e) { try { }
if (conn == null)
new BaseDao();
return conn.createStatement().executeUpdate(sql); // 执行数据库更新 System.out.println(\错误信息:\+e.getMessage()); return -1;
} catch (SQLException e) {
} finally {
- 4 -
}
}
} finally { }
conn = null;
3.2主要功能实现
private void initComponents() {
dialogPane = new JPanel(); contentPanel = new JPanel(); lb_id = new JLabel(); tf_id = new JTextField(); lb_name = new JLabel(); tf_name = new JTextField(); lb_type = new JLabel();
cb_type = new JComboBox(Constant.STAFF_TYPES);
- 5 -
public StaffAdd() { }
initComponents();
3.2.1 职工信息录入
public class StaffAdd extends JFrame {
private JPanel dialogPane; private JPanel contentPanel; private JLabel lb_id; private JTextField tf_id; private JLabel lb_name; private JTextField tf_name; private JLabel lb_type; private JComboBox cb_type; private JLabel lb_xueli; private JTextField tf_xueli; private JLabel lb_address; private JTextField tf_address; private JLabel lb_sex; private JTextField tf_sex; private JLabel lb_salary; private JTextField tf_salary; private JLabel lb_age; private JTextField tf_age; private JPanel buttonBar; private JButton btn_save; private JButton btn_close;
共分享92篇相关文档