企业工资管理系统课程设计报告姓名XXX班级XXXXX学号XXXXXX课程名称数据库原理及应用指导教师201X年X月X日目录一.工资管理系统需求分析…………………………………功能需求………………………………………………………………………………………………………………………………………性能需求…………………………………………………数据流图………………………………………………二.总体设计…………………………………………………数据库概念设计…………………………………………功能模块…………………………………………………三.系统详细设计……………………………………………数据库逻辑设计…………………………………………各模块功能………………………………………………………………………………………………………………………………………………………四.系统实现…………………………………………………界面截图……………………………………………………………………………………………………………………………………………………………………设计代码…………………………………………………五.实验总结…………………………………………………1、需求分析1.1功能需求(1)、员工信息表;及时反映员工的基本信息(2)、员工津贴表,反映员工津贴(3)、员工基本工资表功能描述(1)、基本工资的设定(2)、津贴的设定(3)、计算出月工资(4)、录入员工工资信息(5)、添加员工工资信息(6)、更改员工工资信息性能需求此工资管理系统对工资数据精度的计算能在默认情况之下精确到小数点后3位小数,即是精确到分的计算。
但在用户使用过程中,能自行根据实际情况进行小数计算精度的设定,最大能允许保留小数点后5位的精度。
在时间特性上,当用户发出命令请求时的服务器的响应时间、对数据更新处理、工资数据的查询检索等上,同样要求系统响应时间不会超过秒时间。
系统支持多种操作系统的运行环境,多不同操作系统,不同文件格式的磁盘上的数据均能实现信息的互通,及共享。
当服务器移植到其他的系统平台,如:Linux平台下时,同样能和其他的系统进行数据存取同步,不会出现系统之间互不兼容的情况,系统支持多系统之间的互连互通,系统有巨大的强健性。
本课程设计是用Java 语言编写,mysql数据库。
数据流图根据工资管理要求及用户需求调查分析,得到以下数据流图图第一层数据流图图职工信息的载入图考勤的信息载入2.总体设计数据库概念设计有了数据流图,用E-R图来说明工资信息管理系统的数据库概念模式,如图m功能模块3津贴(职工号,姓名,奖金)其中,标有下划线的字段表示为该数据表的主码,即主关键字。
在上面的实体以及实体之间关系的基础上,形成数据库中的表格以及各个表格之间的关系。
工资信息管理系统数据库中各个表格的设计结果如下面的几个表格所示。
每个表格表示在数据库中的一个表。
表一:员工信息表:各模块功能功能为:财务部门相关人员录入、修改、删除、查询员工个人信息功能为:根据工资生成公式,按照员工的考勤情况及各种表现按月生成相应的工资;财务部门相关人员能录入、修改、删除、查询每个月每个员工的工资信息以及工资汇总;员工本人能查询自己的工资信息以及工资汇总;功能为:员工本人能通过用户名和密码查询自己的信息以及修改自己的密码;4.系统实现界面截图主界面登录界面管理员管理工资界面信息录入,修改,删除,查询界面信息查询界面界面设计代码package wage_management;import .*;import .*;class DB extends JFrame implements ActionListener { JFrame frame = new JFrame("欢迎进入企业工资管理系统");JLabel label = new JLabel("", ;JButton button1 = new JButton("进入系统");JButton button2 = new JButton("退出系统");ImageIcon im = new ImageIcon("");JLabel a1 = new JLabel(im);void Create() {JPanel pcontentPane = (JPanel) ();(a1);(label);(new FlowLayout());(button1);(button2);(true);(this);(this);;();(200, 100, 550, 180);(true);}public static void main(String[] args) {DB dome = new DB();();}public void actionPerformed(ActionEvent e) { if ())) {DL dl = new DL();();();}if ())) {quals("admin") == true&& ().equals("admin") == true)){(this, "登录成功!");GZGLZJM gz = new GZGLZJM();();();}else {(null, "输入用户名或密码错误!");}}if ()==logonButton2){try {Connection con;Statement ps;ResultSet rs;String sql = null;con = (sql="select * from workerinfo where name='"+t1+"' and mi='"+t2+"'";ps=(PreparedStatement) (sql);rs = (sql);if()){if("name").equals(t1) && ("mi").equals(t2)){YGDLJM yg = new YGDLJM();();();(this, "登录成功!");();}}else {(this, "输入用户名或密码错误!");}}catch (Exception e1) {// TODO Auto-generated catch block();}}if ())) // 退出{(0);}}}/工资管理主界面package wage_management;class GZGLZJM extends JFrame implements ActionListener { JFrame f = new JFrame("工资管理系统");JButton b1 = new JButton("工资管理");JButton b2 = new JButton("员工信息管理");JButton b3 = new JButton("返回");ImageIcon im = new ImageIcon("");JLabel a1 = new JLabel(im);void create() {JPanel p = (JPanel) ();(new FlowLayout());(a1);(b1);(b2);(b3);;(true);(this);(this);(this);(200, 100, 500, 200);(true);}public void actionPerformed(ActionEvent e) {if ())) {// 返回DL d = new DL();();();}if ())) {// 员工信息管理YGGL yg = new YGGL();();();}if ())) {// 工资管理GZGL gz = new GZGL();();();}}}//////工资管理package wage_management;public class GZGL extends JFrame implements ActionListener { JFrame f = new JFrame("工资管理");JButton b1 = new JButton("录入");JButton b2 = new JButton("修改");JButton b3 = new JButton("删除");JButton b4 = new JButton("查询所有");JButton b5 = new JButton("返回");JTextField tf1 = new JTextField(4);JTextField tf2 = new JTextField(4);JTextField tf3 = new JTextField(4);JTextField tf4 = new JTextField(4);JTextField tf5 = new JTextField(6);JTextField tf6 = new JTextField(7);String[] cloum = { "职工号", "姓名", "津贴", "月基本工资","月薪"};Object[][] row = new Object[50][5];JTable table = new JTable(row, cloum);JScrollPane scrollpane = new JScrollPane(table); JSplitPane splitpane = new JSplitPane;void create() {JPanel p = (JPanel) ();(new FlowLayout());(scrollpane);(splitpane);JPanel p1 = new JPanel();(b1);(b2);(b3);(b4);(b5);JPanel p2 = new JPanel();;(scrollpane);JPanel p3 = new JPanel();(new FlowLayout());(new JLabel(""));(new JLabel("职工号"));(tf1);(new JLabel("姓名"));(tf2);(new JLabel("津贴"));(tf3);(new JLabel("月基本工资"));(tf4);(new JLabel("月薪"));(tf5);(new JLabel("在此处输入职工号点击查询删除"));(tf6);(p1, ;(p2, ;(50);;(this);(this);(this);(this);(this);(200, 100, 500, 600);(true);// 可以调整界面大小(true);}public void actionPerformed(ActionEvent e) { if ())) { // 录入Connection con;Statement sql;try {} catch (ClassNotFoundException e1) {}try {sql = ();String insertStr = "INSERT INTO welfare (no,name,jt)VALUES('"+()+"','"+()+"','"+()+"');";(insertStr);String insertStr1 = "INSERT INTO wageinfo (no,name,jb)VALUES('"+()+"','"+()+"','"+()+"');";(insertStr1);();(this, "入录成功!");} catch (SQLException e1) {(this, "入录失败!");}}if ())) {// 修改Connection con;Statement sql;try {} catch (ClassNotFoundException e1) {}try {sql = ();String updateStr = "UPDATE welfare SETjt='"+()+"',name='"+()+"'where no='"+()+"';";(updateStr);String updateStr1 = "UPDATE wageinfo SET jb='"+()+"',name='"+()+"'where no='"+()+"';";(updateStr1);(this, "修改成功!");();} catch (SQLException e1) {(this, "信息不存在!");}}if ())) {// 删除Connection con;Statement sql;ResultSet rs;try {} catch (ClassNotFoundException e1) {}try {sql = ,;("DELETE FROM wageinfo where no='"+()+"';");("DELETE FROM welfare where no='"+()+"';");(this, "删除成功!");();} catch (SQLException e1) {(this, "删除失败!");}}if ())) {// 查询全部Connection con;Statement sql;ResultSet rs;//Vector vector = new Vector();try {} catch (ClassNotFoundException e1) {(this, "连接数据库失败!");}try {sql = ,;if ())) {for (int i = 0; i < 50; i++)for (int j = 0; j < 4; j++)("", i, j);rs = ("select distinct * fromwageinfo ,welfare where =");int k = -1;while ()) {++k;String no = (1);String name = (2);String jb = (3);String jt = (6);int sum= (3)+(6);(no, k, 0);(name, k, 1);(jb, k, 3);(jt, k, 2);(sum,k,4);}}} catch (SQLException e1) {(this, "查询失败!");}}if ())) {// 返回GZGLZJM gl=new GZGLZJM();();();}}}////////修改管理主界面package wage_management;public class YGDLJM extends DL implements ActionListener { JFrame f = new JFrame("工资管理");JButton b1 = new JButton("查询个人工资");JButton b2 = new JButton("修改密码");JButton b3 = new JButton("返回");String[] cloum = { "职工号", "姓名", "津贴", "月基本工资","月薪"};Object[][] row = new Object[50][5];JTable table = new JTable(row, cloum);JScrollPane scrollpane = new JScrollPane(table);JSplitPane splitpane = new JSplitPane;void create() {JPanel p = (JPanel) ();(new FlowLayout());(scrollpane);(splitpane);JPanel p1 = new JPanel();(b1);(b2);(b3);JPanel p2 = new JPanel();;(scrollpane);JPanel p3 = new JPanel();(new FlowLayout());(p1, ;(p2, ;(50);;(this);(this);(this);(200, 100, 500, 550);(true);// 可以调整界面大小(true);}public void actionPerformed(ActionEvent e) {if ())) {// 查询个人工资Connection con;Statement sql;ResultSet rs;try {} catch (ClassNotFoundException e1) {}try {sql = ,;if ())) {for (int i = 0; i < 50; i++)for (int j = 0; j < 4; j++)("", i, j);rs = ("select distinct * fromwageinfo ,welfare,workerinfo where = and = and ='"+t1+"' and ='"+t2+"'");int k = -1;while ()) {++k;String no = (1);String name = (2);String jb = (3);String jt = (6);int sum= (3)+(6);(no, k, 0);(name, k, 1);(jb, k, 3);(jt, k, 2);(sum,k,4);}}} catch (SQLException e1) {(this, "查询失败!");}}if ())){// 修改密码XGMM xgmm=new XGMM();();}if ())) {// 返回DL dl=new DL();();();}}}///修改管理package wage_management;public class YGGL extends JFrame implements ActionListener { JFrame f = new JFrame("员工信息管理");JButton b1 = new JButton("添加新员工信息");JButton b2 = new JButton("修改员工信息");JButton b3 = new JButton("删除员工信息");JButton b4 = new JButton("查询所有员工信息");JButton b5 = new JButton("返回");JTextField tf1 = new JTextField(4);JTextField tf2 = new JTextField(4);JTextField tf3 = new JTextField(4);JTextField tf4 = new JTextField(4);JTextField tf5 = new JTextField(6);JTextField tf6 = new JTextField(7);String[] cloum = { "职工号", "姓名", "津贴", "月基本工资","月薪","登陆密码"};Object[][] row = new Object[50][6];JTable table = new JTable(row, cloum);JScrollPane scrollpane = new JScrollPane(table);JSplitPane splitpane = new JSplitPane;void create() {JPanel p = (JPanel) ();(new FlowLayout());(scrollpane);(splitpane);JPanel p1 = new JPanel();(b1);(b2);(b3);(b4);(b5);JPanel p2 = new JPanel();;(scrollpane);(new FlowLayout());(new JLabel(""));(new JLabel("职工号"));(tf1);(new JLabel("姓名"));(tf2);(new JLabel("津贴"));(tf3);(new JLabel("月基本工资"));(tf4);(new JLabel("登陆密码"));(tf5);(new JLabel(" 在此处输入职工号点击查询删除"));(tf6);(p1, ;(p2, ;(50);;(this);(this);(this);(this);(this);(200, 100, 600, 600);(true);// 可以调整界面大小(true);}public void actionPerformed(ActionEvent e) {if ())) { // 添加新员工信息Connection con;Statement sql;try {} catch (ClassNotFoundException e1) {(this, "连接数据库失败!");}try {sql = ();String insertStr = "INSERT INTO welfare(no,name,jt)VALUES('"+()+"','"+()+"','"+()+"');";(insertStr);String insertStr1 = "INSERT INTO wageinfo (no,name,jb)VALUES('"+()+"','"+()+"','"+()+"');";(insertStr1);String insertStr2 = "INSERT INTO workerinfo (no,name,mi)VALUES('"+()+"','"+()+"','"+()+"');";(insertStr2);(this, "添加成功!");();} catch (SQLException e1) {(this, "添加失败!");}}if ())) {// 修改员工信息Connection con;Statement sql;try {} catch (ClassNotFoundException e1) {(this, "连接数据库失败!");}try {sql = ();sql = ();String updateStr = "UPDATE welfare SETjt='"+()+"',name='"+()+"'where no='"+()+"';";(updateStr);String updateStr1 = "UPDATE wageinfo SETjb='"+()+"',name='"+()+"'where no='"+()+"';";(updateStr1);(updateStr1);String updateStr2 = "UPDATE workerinfo SET name='"+()+"',mi='"+()+"'where no='"+()+"';";(updateStr2);(this, "修改成功!");();} catch (SQLException e1) {(this, "修改失败!");}}if ())) {// 删除员工信息Connection con;Statement sql;try {} catch (ClassNotFoundException e1) {(this, "连接数据库失败!");}try {sql = ,;("DELETE FROM wageinfo where no='"+()+"';");("DELETE FROM welfare where no='"+()+"';");("DELETE FROM workerinfo whereno='"+()+"';");(this, "删除成功!");();} catch (SQLException e1) {(this, "删除失败!");}}if ())) {// 查询全部员工信息Connection con;Statement sql;ResultSet rs;try {} catch (ClassNotFoundException e1) {(this, "连接数据库失败!");}try {sql = ,;if ())) {for (int i = 0; i < 50; i++)for (int j = 0; j < 4; j++)("", i, j);rs = ("select distinct * fromwageinfo ,welfare,workerinfo where = and = ;");int k = -1;while ()) {++k;String no = (1);String name = (2);String jb = (3);String jt = (6);int sum= (3)+(6);String mi = (9);(no, k, 0);(name, k, 1);(jb, k, 3);(jt, k, 2);(sum,k,4);(mi,k,5);}}} catch (SQLException e1) {(this, "查询失败!");}}if ())) {// 返回GZGLZJM gl=new GZGLZJM();();();}}}////修改密码package wage_management;class XGMM extends DL implements ActionListener{JFrame frame = new JFrame("密码修改");JLabel label1 = new JLabel("原密码");JLabel label2 = new JLabel("新密码");JButton Button1 = new JButton("确定");JButton cancelButton = new JButton("返回");JPasswordField password = new JPasswordField(9);JPasswordField newpassword = new JPasswordField(9);void create(){JPanel p = (JPanel) ();(new FlowLayout());(label1);(5, 5);(4, 8);(password);(100, 200);(600, 600);(label2);(50, 20);(40, 80);(newpassword);(100, 20);(80, 120);(Button1);(cancelButton);;(true);(this);(this);;();(200, 100, 500, 220);(true);}public void actionPerformed(ActionEvent e){if ()==Button1){Connection con;Statement sql;try {} catch (ClassNotFoundException e1) {(this, "连接数据库失败!");}try {sql = ();String updateStr = "UPDATE workerinfo SET mi='"+()+"'where name='"+t1+"';";(updateStr);(this, "修改成功!");();} catch (SQLException e1) {(this, "请输入原密码和新密码!");}}if ()==cancelButton) // 返回{YGDLJM dl=new YGDLJM();();();}}}5.课设总结此次课设难度有点大,通过几天的努力终于完成了,开始对如何连接数据库不太了解,通过小组合作,和网上查阅资料,最终解决了问题,在写员工登陆界面时,要从数据库读取和验证密码,开始遇到了些问题,后来慢慢都完成了,总的来说收获很大,了解了如何将所学数据库运用到编程里,对数据库数据的查询,更改,添加都有了更一步的了解。