Java课程设计-企业工资管理.docx_第1页
Java课程设计-企业工资管理.docx_第2页
Java课程设计-企业工资管理.docx_第3页
Java课程设计-企业工资管理.docx_第4页
Java课程设计-企业工资管理.docx_第5页
已阅读5页,还剩30页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

目 录一需求分析.21.1功能需求.31.2性能需求.3二.设计总流程图.4三.系统详细设计.43.1数据库逻辑设计.43.2各模块功能.5 3.2.1职工信息管理系统.5 3.2.2职工工资管理系统.6 3.2.3职工登录查询管理系统.8四.设计代码.9五.心得体会 .35 一、 需求分析:1.功能需求:1) 员工信息表;及时反映员工的基本信息2) 员工津贴表,反映员工津贴3) 员工基本工资表4) 基本工资的设定5) 津贴的设定6) 计算出月工资7) 录入员工工资信息8) 添加员工工资信息9) 更改员工工资信息2.性能需求:此工资管理系统对工资数据精度的计算能在默认情况之下精确到小数点后3位小数,即是精确到分的计算。但在用户使用过程中,能自行根据实际情况进行小数计算精度的设定,最大能允许保留小数点后5位的精度。在时间特性上,当用户发出命令请求时的服务器的响应时间、对数据更新处理、工资数据的查询检索等上,同样要求系统响应时间不会超过0.5秒时间。系统支持多种操作系统的运行环境,多不同操作系统,不同文件格式的磁盘上的数据均能实现信息的互通,及共享。当服务器移植到其他的系统平台,如:Linux平台下时,同样能和其他的系统进行数据存取同步,不会出现系统之间互不兼容的情况,系统支持多系统之间的互连互通,系统有巨大的强健性。本课程设计是用Java语言编写,mysql数据库。二、 数据总流程图:基本工资姓名职工号职工号员工工资领取 影响津贴姓名 姓名津贴领取密码职工号三、 系统详细设计1.数据库逻辑设计工资信息管理系统数据库中各个表格的设计结果如下面的几个表格所示。表一:员工信息表:表二:基本工资表:表三:津贴信息表2. 各模块功能:1) 职工信息管理系统功能为:财务部门相关人员录入、修改、删除、员工个人信息 添加员工信息图 修改员工信息图 删除员工信息图2) 职工工资管理系统功能为:根据工资生成公式,按照员工的考勤情况及各种表现按月生成相应的工资;财务部门相关人员能录入、修改、删除、查询每个月每个员工的工资信息以及工资汇总;员工本人能查询自己的工资信息以及工资汇总; 工资录入图 工资修改图 工资删除图3) 职工登陆查询系统功能为:员工本人能通过用户名和密码查询自己的信息以及修改自己的密码员工登录界面 员工修改密码图四、 设计代码DB类:package wage_management;import java.awt.*; import java.awt.event.*;import javax.swing.*;class DB extends JFrame implements ActionListener public DB() JFrame frame = new JFrame(欢迎进入企业工资管理系统);JLabel label = new JLabel(, JLabel.CENTER);JButton button1 = new JButton(进入系统);JButton button2 = new JButton(退出系统);ImageIcon im = new ImageIcon(1);JLabel a1 = new JLabel(im);void Create() JPanel pcontentPane = (JPanel) frame.getContentPane();pcontentPane.add(a1);pcontentPane.add(label);pcontentPane.setLayout(new FlowLayout();pcontentPane.add(button1);pcontentPane.add(button2);pcontentPane.setVisible(true);button1.addActionListener(this);button2.addActionListener(this);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setBounds(200, 100, 550, 180);frame.setVisible(true);public static void main(String args) DB dome = new DB();dome.Create();public void actionPerformed(ActionEvent e) if (button1.equals(e.getSource() DL dl = new DL();dl.create();frame.dispose();if (button2.equals(e.getSource() / 退出System.exit(0);登录类:package wage_management;import java.awt.Color; import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.Statement;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;class DL extends JFrame implements ActionListener ImageIcon im = new ImageIcon(2.jpg);JLabel a2 = new JLabel(im);JFrame frame = new JFrame(职工/管理员登陆);JLabel label1 = new JLabel(用户名);JLabel label2 = new JLabel(密码);JButton logonButton1 = new JButton(管理员登录);JButton logonButton2 = new JButton(职工登录);JButton cancelButton = new JButton(退出);JTextField username = new JTextField(9);JPasswordField password = new JPasswordField(9);static String t1;static String t2;public void create() JPanel p = (JPanel) frame.getContentPane();JPanel p1 = new JPanel();p.setLayout(new FlowLayout();p.add(a2);p.add(label1);p.setSize(5, 5);p.setLocation(4, 8);p.add(username);p.setSize(100, 200);p.setLocation(800, 800);p.add(label2);p.setSize(50, 20);p.setLocation(40, 80);p.add(password);p.setSize(100, 20);p.setLocation(80, 120);p.add(logonButton1);p.add(logonButton2);p.add(cancelButton);p.setBackground(Color.cyan);p.setVisible(true);logonButton1.addActionListener(this);logonButton2.addActionListener(this);cancelButton.addActionListener(this);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setBounds(200, 100, 500, 220);frame.setVisible(true);public void actionPerformed(ActionEvent e) t1 = username.getText();t2 = password.getText();if(e.getSource()=logonButton1)if( username.getText().equals(admin) = true& (password.getText().equals(123456) = true) JOptionPane.showMessageDialog(this, 登录成功!);GZGLZJM gz = new GZGLZJM();gz.create();frame.dispose(); else JOptionPane.showMessageDialog(null, 输入用户名或密码错误!);if (e.getSource()=logonButton2)try Connection con;Statement ps;ResultSet rs;String sql = null;Class.forName(org.gjt.mm.mysql.Driver);Class.forName(org.gjt.mm.mysql.Driver).newInstance();con = DriverManager.getConnection( jdbc:mysql:/localhost:3306/db_book,root,123456); sql=select * from workerinfo where name=+t1+ and mi=+t2+;ps=(PreparedStatement)con.prepareStatement(sql);rs = ps.executeQuery(sql);if(rs.next()if(rs.getString(name).equals(t1) & rs.getString(mi).equals(t2)YGGLZJM yg = new YGGLZJM();yg.create();frame.dispose();JOptionPane.showMessageDialog(this, 登录成功!);this.dispose();else JOptionPane.showMessageDialog(this, 输入用户名或密码错误!);catch (Exception e1) / TODO Auto-generated catch blocke1.printStackTrace();if (cancelButton.equals(e.getSource() / 退出System.exit(0);package wage_management;import java.sql.Connection;import java.sql.DriverManager;DLUtil类public class DLUtil private String dbUrl=jdbc:mysql:/localhost:3306/db_book;private String dbUserName=root;private String dbPassword=123456;private String jdbcName=com.mysql.jdbc.Driver;/驱动名称public Connection getCon() throws ExceptionClass.forName(jdbcName);Connection con=DriverManager.getConnection(dbUrl, dbUserName, dbPassword);return con;public void closeCon(Connection con) throws Exceptionif(con!=null)con.close();/ceshipublic static void main(String args) DLUtil dbUtil=new DLUtil();try dbUtil.getCon();System.out.println(数据库连接成功!); catch (Exception e) / TODO Auto-generated catch blocke.printStackTrace();System.out.println(数据库连接失败!);工资管理类package wage_management;import java.awt.Color;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JSplitPane;import javax.swing.JTable;import javax.swing.JTextField;public class GZGL extends JFrame implements ActionListener public GZGL() 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 Object505;JTable table = new JTable(row, cloum);JScrollPane scrollpane = new JScrollPane(table);JSplitPane splitpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);public void create() JPanel p = (JPanel) f.getContentPane();p.setLayout(new FlowLayout();p.add(scrollpane);p.add(splitpane);JPanel p1 = new JPanel();p1.add(b1);p1.add(b2);p1.add(b3);p1.add(b4);p1.add(b5);JPanel p2 = new JPanel();p2.setBackground(Color.cyan);p2.add(scrollpane);JPanel p3 = new JPanel();p.setLayout(new FlowLayout();p.add(new JLabel();p.add(new JLabel(职工号);p.add(tf1);p.add(new JLabel(姓名);p.add(tf2);p.add(new JLabel(津贴);p.add(tf3);p.add(new JLabel(月基本工资);p.add(tf4);p.add(new JLabel(月薪);p.add(tf5);p.add(new JLabel(在此处输入职工号点击查询删除);p.add(tf6);splitpane.add(p1, splitpane.TOP);splitpane.add(p2, splitpane.BOTTOM);splitpane.setDividerLocation(50);p.setBackground(Color.CYAN);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);b5.addActionListener(this);f.setBounds(200, 100, 500, 600);f.setResizable(true);/ 可以调整界面大小f.setVisible(true);public void actionPerformed(ActionEvent e) if (b1.equals(e.getSource() / 录入Connection con;Statement sql;try Class.forName(org.gjt.mm.mysql.Driver); catch (ClassNotFoundException e1) System.out.println( + e1);try con=DriverManager.getConnection(jdbc:mysql:/localhost:3306/db_book,root,123456);sql = con.createStatement();String insertStr = INSERT INTO welfare (no,name,jt)VALUES(+tf1.getText()+,+tf2.getText()+,+tf3.getText()+);sql.executeUpdate(insertStr);String insertStr1 = INSERT INTO wageinfo (no,name,jb)VALUES(+tf1.getText()+,+tf2.getText()+,+tf4.getText()+);sql.executeUpdate(insertStr1);con.close();JOptionPane.showMessageDialog(this, 入录成功!); catch (SQLException e1) JOptionPane.showMessageDialog(this, 入录失败!);if (b2.equals(e.getSource() / 修改Connection con;Statement sql;try Class.forName(org.gjt.mm.mysql.Driver); catch (ClassNotFoundException e1) System.out.println( + e1);try con = DriverManager.getConnection(jdbc:mysql:/localhost:3306/db_book,root,123456);sql = con.createStatement();String updateStr = UPDATE welfare SET jt=+tf3.getText()+,name=+tf2.getText()+where no=+tf1.getText()+;sql.executeUpdate(updateStr);String updateStr1 = UPDATE wageinfo SET jb=+tf4.getText()+,name=+tf2.getText()+where no=+tf1.getText()+;sql.executeUpdate(updateStr1);JOptionPane.showMessageDialog(this, 修改成功!);con.close(); catch (SQLException e1) JOptionPane.showMessageDialog(this, 信息不存在!);if (b3.equals(e.getSource() / 删除Connection con;Statement sql;ResultSet rs;try Class.forName(org.gjt.mm.mysql.Driver); catch (ClassNotFoundException e1) System.out.println( + e1);try con = DriverManager.getConnection(jdbc:mysql:/localhost:3306/db_book,root,123456);sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);sql.executeUpdate(DELETE FROM wageinfo where no=+tf6.getText()+;);sql.executeUpdate(DELETE FROM welfare where no=+tf6.getText()+;);JOptionPane.showMessageDialog(this, 删除成功!);con.close(); catch (SQLException e1) JOptionPane.showMessageDialog(this, 删除失败!);if (b4.equals(e.getSource() / 查询全部Connection con;Statement sql;ResultSet rs;/Vector vector = new Vector();try Class.forName(org.gjt.mm.mysql.Driver); catch (ClassNotFoundException e1) JOptionPane.showMessageDialog(this, 连接数据库失败!);try con = DriverManager.getConnection(jdbc:mysql:/localhost:3306/db_book,root,123456);sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);if (b4.equals(e.getSource() for (int i = 0; i 50; i+)for (int j = 0; j 4; j+)table.setValueAt(, i, j);rs = sql.executeQuery(select distinct * from wageinfo ,welfare where =);int k = -1;while (rs.next() +k;String no = rs.getString(1);String name = rs.getString(2);String jb = rs.getString(3);String jt = rs.getString(6);int sum=rs.getInt(3)+rs.getInt(6);table.setValueAt(no, k, 0);table.setValueAt(name, k, 1);table.setValueAt(jb, k, 3);table.setValueAt(jt, k, 2);table.setValueAt(sum,k,4); catch (SQLException e1) JOptionPane.showMessageDialog(this, 查询失败!);if (b5.equals(e.getSource() / 返回GZGLZJM gl=new GZGLZJM();gl.create();f.dispose();工资管理主界面类package wage_management;import java.awt.Color;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;class GZGLZJM extends JFrame implements ActionListener public GZGLZJM() JFrame f = new JFrame(工资管理系统);JButton b1 = new JButton(工资管理);JButton b2 = new JButton(员工信息管理);JButton b3 = new JButton(返回);ImageIcon im = new ImageIcon(3.jpg);JLabel a1 = new JLabel(im);void create() JPanel p = (JPanel) f.getContentPane();p.setLayout(new FlowLayout();p.add(a1);p.add(b1);p.add(b2);p.add(b3);p.setBackground(Color.cyan);p.setVisible(true);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);f.setBounds(200, 100, 500, 200);f.setVisible(true);public void actionPerformed(ActionEvent e) if (b3.equals(e.getSource() / 返回DL d = new DL();d.create();f.dispose();if (b2.equals(e.getSource() / 员工信息管理YGGL yg = new YGGL();yg.create();f.dispose();if (b1.equals(e.getSource() / 工资管理GZGL gz = new GZGL();gz.create();f.dispose();修改密码类package wage_management;import java.awt.Color;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;class XGMM extends DL implements ActionListener public XGMM() 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);public void create() JPanel p = (JPanel) frame.getContentPane();p.setLayout(new FlowLayout();p.add(label1);p.setSize(5, 5);p.setLocation(4, 8);p.add(password);p.setSize(100, 200);p.setLocation(600, 600);p.add(label2);p.setSize(50, 20);p.setLocation(40, 80);p.add(newpassword);p.setSize(100, 20);p.setLocation(80, 120);p.add(Button1);p.add(cancelButton);p.setBackground(Color.cyan);p.setVisible(true);Button1.addActionListener(this);cancelButton.addActionListener(this);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setBounds(200, 100, 500, 220);frame.setVisible(true);public void actionPerformed(ActionEvent e) if (e.getSource()=Button1)Connection con;Statement sql;try Class.forName(org.gjt.mm.mysql.Driver); catch (ClassNotFoundException e1) JOptionPane.showMessageDialog(this, 连接数据库失败!);try con = DriverManager.getConnection(jdbc:mysql:/localhost:3306/db_book,root,123456);sql = con.createStatement();String updateStr = UPDATE workerinfo SET mi=+newpassword.getText()+where name=+t1+;sql.executeUpdate(updateStr);JOptionPane.showMessageDialog(this, 修改成功!);con.close(); catch (SQLException e1) JOptionPane.showMessageDialog(this, 请输入原密码和新密码!);/System.out.println(e1);if (e.getSource()=cancelButton) / 返回YGGLZJM dl=new YGGLZJM();dl.create();frame.dispose();员工管理类package wage_management;import java.awt.Color;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import ja

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论