《人事工资管理系统附录文件源代码.pdf》由会员分享,可在线阅读,更多相关《人事工资管理系统附录文件源代码.pdf(29页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、bm。javaimport java.awt。;import java。awt。event。;import java。sql。*;import javax.swing.;class bm extends Frame implements ActionListener,ItemListener privatecondb conx=null;private ResultSet rs=null;private String sql=null;private Label num=new Label(”职工号”);private Label jb=new Label(税收);private Label
2、fj=new Label(医疗保险”);private Label in=new Label(”退休保险”);private TextField numtx=new TextField();private TextField jbtx=new TextField();private TextField fjtx=new TextField();private TextField intx=new TextField();private Choice numcho=new Choice();private Button add=new Button(增加”);private Button exi
3、t=new Button(退出”);public bm()setTitle(扣除工资);setSize(400,300);setBackground(Color.LIGHT_GRAY);this。setLocationRelativeTo(this.getParent());this.setResizable(false);setLayout(null);num。setBounds(80,50,50,20);jb.setBounds(80,80,50,20);fj。setBounds(80,110,50,20);in.setBounds(80,140,50,20);numtx.setBound
4、s(160,50,100,20);jbtx。setBounds(160,80,100,20);fjtx。setBounds(160,110,100,20);intx.setBounds(160,140,100,20);numcho。setBounds(160,170,100,20);add.setBounds(60,220,50,20);exit.setBounds(300,220,50,20);add(add);add(exit);add(num);add(jb);add(fj);add(in);add(numtx);add(jbtx);add(fjtx);add(intx);add(num
5、cho);/lbadd。addActionListener(this);exit。addActionListener(this);numcho.addItemListener(this);initnumcho();setVisible(true);addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););public void itemStateChanged(ItemEvent i)numtx。setText(numcho。getSelectedItem();public
6、void initnumcho()conx=new condb();sql=”select*from 扣除工资”;numcho。removeAll();try rs=conx.getrs(conx.con,sql);while(rs.next()numcho.add(rs。getString(职工号”);conx。dbclose(conx。con,rs);conx=null;rs=null;catch(Exception eo)public void actionPerformed(ActionEvent e)conx=new condb();if(e.getActionCommand()。e
7、quals(退出”)this.dispose();if(e.getActionCommand().equals(增加)sql=”select from 扣除工资 where 职工号=”+numtx.getText()+”;try rs=conx.getrs(conx.con,sql);if(rs。next())sql=insert into 扣除工资(职工号,税收,医疗保险,养老保险)+values(+numtx。getText()。trim()+”,”+jbtx。getText()+,”+fjtx。getText()+”,+intx。getText()+);try System。out。pr
8、intln(sql);conx.dbclose(conx.con,null);catch(Exception ue)System.out.println(+ue);JOptionPane jop=new JOptionPane();jop。showMessageDialog(null,扣除工资添加成功!,”添加成功,1);conx.dbclose(conx。con,rs);numtx。setText(”)jbtx。setText(”);fjtx.setText(”);conx=null;rs=null;else JOptionPane jop=new JOptionPane();jop。sho
9、wConfirmDialog(null,”添加失败!”,警告!”,1);conx.dbclose(conx.con,rs);conx=null;rs=null;catch(SQLException et)System.out。println(”+et);/*else/bmcx.javaimport java.awt。;import java.awt。event.;import java。sql。;import javax.swing.;import java.awt.Window;class bmcx extends Frame implements ActionListenerprivate
10、 condb conc=null;private ResultSet rs=null;private String sql=null;private Label chao=new Label(职工号:);private Label cname=new Label(”姓名:”);private Label csex=new Label(”税收:”);private Label cage=new Label(医疗保险:);private Label cdep=new Label(”退休保险:);private TextField chaotx=new TextField();private Lab
11、el cnametx=new Label();private Label csextx=new Label(”);private Label cagetx=new Label(”);private Label cdeptx=new Label(”);private Button cx=new Button(查询”);private Button tc=new Button(”退出);public bmcx()setTitle(”扣除工资查询);setSize(400,250);setBackground(Color。LIGHT_GRAY);this.setLocationRelativeTo(
12、this.getParent();this。setResizable(false);setLayout(null);chao.setBounds(80,50,50,20);cname.setBounds(80,80,50,20);csex.setBounds(80,110,50,20);cage.setBounds(80,140,50,20);cdep.setBounds(80,170,50,20);chaotx。setBounds(160,50,150,20);cnametx。setBounds(160,80,150,20);csextx.setBounds(160,110,150,20);
13、cagetx.setBounds(160,140,150,20);cdeptx。setBounds(140,170,150,20);cx.setBounds(60,205,50,20);tc.setBounds(300,205,50,20);add(chao);add(cname);add(cagetx);add(cage);add(csex);add(cdep);add(chaotx);add(cnametx);add(csextx);add(cdeptx);add(cx);add(tc);setVisible(true);cx。addActionListener(this);tc.addA
14、ctionListener(this);addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););public void actionPerformed(ActionEvent e)if(e.getActionCommand()。equals(退出”))this.dispose();if(e。getActionCommand()。equals(”查询)conc=new condb();sql=”select 姓名,税收,医疗保险,退休保险 from 扣除工资,职工 where
15、 扣除工资。职工号=职工。职工号 and 扣除工资。职工号=+chaotx.getText()+”;try rs=conc。getrs(conc.con,sql);if(rs。next()cnametx。setText(rs。getString(”姓名”);csextx.setText(rs。getString(税收);cagetx.setText(rs。getString(”医疗保险”));cdeptx.setText(rs.getString(”退休保险”));conc。dbclose(conc。con,rs);conc=null;rs=null;else JOptionPane jop=
16、new JOptionPane();jop。showConfirmDialog(null,该用户不存在!”,警告,-1);catch(Exception ee)condb.javaimport java.sql.*;public class condb public Connection con;/在类头定义连接对象public condb()/在此构造方法中实现有关程序的加载,同时捕捉异常。try Class。forName(sun.jdbc.odbc.JdbcOdbcDriver);/加载驱动程序catch(java.lang。ClassNotFoundException e)System
17、。out.println(error);try con=DriverManager.getConnection(”jdbc:odbc:xin”);/连接数据源catch(SQLException e)System。out。println(”connect database error!);public ResultSet getrs(Connection con,String sql)/自定义查询数据库返回记录集的方法。ResultSet rs=null;tryStatement stmt=con.createStatement();/创建发送 sql 语句的对象 stmt。rs=stmt。e
18、xecuteQuery(sql);/执行查询语句 sql,得记录集。catch(Exception e)System。out.println(”+e)return rs;/getrs()中行参 sql 为实现数据库查询的查询语句,con 表示数据库连接对象。public void moddb(Connection con,String sql)/自定义具有对数据库实现增加,删除,修改功能的方法:try Statement stmt=con.createStatement();/创建发送 sql 语句的对象 stmt。stmt。executeUpdate(sql);/实现增加,删除,修改数据库等
19、操作。catch(Exception e)/方法.executeUpdate()根据 sql 语句实现对数据库的增加,删除,修改功能.public void dbclose(Connection con,ResultSet rs)/定义关闭连接对象和记录集的方法 try con。close();/关闭连接对象rs.close();/关闭记录集catch(SQLException rse)dl.javaimport java.awt。*;import java。awt。event。;import java.sql。*;import javax.swing.*;import java.awt。ge
20、om.*;class denglu extends Framepublic Label name=new Label(用户名);public Label pass=new Label(”密码”);public TextField txtname=new TextField();public TextField txtpass=new TextField();public Button btok=new Button(登陆”);public Button btexit=new Button(取消”);public condb conu=new condb();private String sql
21、=null;private ResultSet rs=null;private Image img;public denglu()img=getToolkit().getImage(getClass().getResource(”/ww。jpg));setTitle(欢迎使用工资管理系统);setLayout(null);setResizable(false);setSize(500,350);Dimension scr=Toolkit。getDefaultToolkit()。getScreenSize();Dimension frm=this。getSize();setLocation(sc
22、r.widthfrm。width)/2,(scr。height-frm。height)/2-18);txtpass。setEchoChar(*);txtname.setBounds(120,260,120,27);txtpass.setBounds(120,300,120,27);btok.setBounds(340,260,100,28);btexit。setBounds(340,300,100,28);add(name);add(txtname);add(pass);add(txtpass);add(btok);add(btexit);setVisible(true);btexit.add
23、ActionListener(new ActionListener()public void actionPerformed(ActionEvent e)dispose();System。exit(0););btok.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)sql=select*from 数据库用户 where 用户名=”+txtname.getText()+and密码=+txtpass。getText()+”;try rs=conu.getrs(conu.con,sql);
24、if(rs.next()mainff mf=new mainff();dispose();mf.show();else JOptionPane jop=new JOptionPane();jop.showMessageDialog(null,”用户名或密码错误,”信息提示!”,1);catch(Exception ee));addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)dispose();System.exit(0););public void paint(Graphics g)g.se
25、tClip(new Rectangle2D.Float(0,0,500,350);g。drawImage(img,0,0,this);public class dl public static void main(String args)denglu deng=new denglu();jz。javaimport java.awt。;import java.awt.event.;import java.sql.*;import javax.swing.*;class gz extends Frame implements ActionListener,ItemListener privatec
26、ondb conx=null;private ResultSet rs=null;private String sql=null;private Label num=new Label(职工号”);private Label jb=new Label(普通请假);private Label fj=new Label(病假);private Label in=new Label(”迟到);private TextField numtx=new TextField();private TextField jbtx=new TextField();private TextField fjtx=new
27、 TextField();private TextField intx=new TextField();private Button add=new Button(增加);private Button exit=new Button(”退出”);public gz()setTitle(”职工休假);setSize(400,300);setBackground(Color.LIGHT_GRAY);this。setLocationRelativeTo(this.getParent();this.setResizable(false);setLayout(null);num.setBounds(80
28、,50,50,20);jb。setBounds(80,80,50,20);fj.setBounds(80,110,50,20);in.setBounds(80,140,50,20);numtx.setBounds(160,50,100,20);jbtx。setBounds(160,80,100,20);fjtx.setBounds(160,110,100,20);intx.setBounds(160,140,100,20);add。setBounds(60,220,50,20);exit。setBounds(300,220,50,20);add(add);add(exit);add(num);
29、add(jb);add(fj);add(in);add(numtx);add(jbtx);add(fjtx);add(intx);/lbadd.addActionListener(this);exit。addActionListener(this);setVisible(true);addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););public void itemStateChanged(ItemEvent i)public void actionPerformed(
30、ActionEvent e)conx=new condb();if(e。getActionCommand().equals(”退出))this。dispose();if(e.getActionCommand()。equals(增加))sql=”select*from 职工 where 职工号=”+numtx。getText()+”;try rs=conx。getrs(conx.con,sql);if(rs。next()sql=”insert into 职工(职工号,普通请假,病假,迟到)”+values(”+numtx。getText()。trim()+,+jbtx.getText()+,”+
31、fjtx.getText()+”,”+intx。getText()+)”try System.out。println(sql);conx.dbclose(conx.con,null);catch(Exception ue)System。out.println(+ue);JOptionPane jop=new JOptionPane();jop。showMessageDialog(null,”职工休假添加成功!,”添加成功”,-1);conx.dbclose(conx.con,rs);numtx.setText(”);jbtx。setText(”);fjtx.setText(”);conx=nu
32、ll;rs=null;else JOptionPane jop=new JOptionPane();jop。showConfirmDialog(null,”添加失败!,警告!”,-1);conx。dbclose(conx.con,rs);conx=null;rs=null;catch(SQLException et)System。out。println(”+et);/*/gzcx。javaimport java.awt。;import java。awt.event。;import java。sql.;import javax.swing.*;import java.awt.Window;cla
33、ss gzcx extends Frame implements ActionListenerprivate condb conc=null;private ResultSet rs=null;private String sql=null;private Label chao=new Label(职工号:);private Label cjb=new Label(基本工资:”);private Label cfj=new Label(奖金:);private Label csf=new Label(”扣除工资:);private Label in=new Label(实发工资”);priva
34、te TextField chaotx=new TextField();private Label cjbtx=new Label(”);private Label cfjtx=new Label(”);private Label csftx=new Label();private Label intx=new Label(”);private Button cx=new Button(”查询”);private Button tc=new Button(”退出”);public gzcx()setTitle(职工工资查询);setSize(400,250);setBackground(Col
35、or。LIGHT_GRAY);this.setLocationRelativeTo(this。getParent());this。setResizable(false);setLayout(null);chao。setBounds(80,50,50,20);cjb.setBounds(80,80,50,20);cfj.setBounds(80,110,50,20);csf。setBounds(80,140,50,20);in.setBounds(80,170,50,20);intx。setBounds(160,170,150,20);chaotx.setBounds(160,50,150,20
36、);cjbtx.setBounds(160,80,150,20);cfjtx.setBounds(160,110,150,20);csftx。setBounds(160,140,150,20);cx。setBounds(60,205,50,20);tc.setBounds(300,205,50,20);add(chao);add(cjb);add(in);add(cfj);add(csf);add(intx);add(cjbtx);add(cfjtx);add(chaotx);add(csftx);add(cx);add(tc);setVisible(true);cx。addActionLis
37、tener(this);tc。addActionListener(this);addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)dispose(););public void actionPerformed(ActionEvent e)if(e.getActionCommand()。equals(退出))this。dispose();if(e.getActionCommand()。equals(”查询”)conc=new condb();sql=select*from 工资 where 职工
38、号=+chaotx。getText()+”;try rs=conc.getrs(conc。con,sql);if(rs.next())cjbtx.setText(rs.getString(基本工资));cfjtx。setText(rs。getString(”奖金);csftx。setText(rs。getString(扣除工资”);intx.setText(rs。getString(”实发工资”);conc.dbclose(conc.con,rs);conc=null;rs=null;else JOptionPane jop=new JOptionPane();jop。showConfirmD
39、ialog(null,”该用户不存在!”,警告”,1);catch(Exception ee)jiesh.javaimport java。awt.;import java.awt.event.;import javax。swing.*;import java.sql.*;class jiesh extends JFrame implements ActionListenerprivate condb con=null;private ResultSet rs=null;private String sql=null;private JLabel q1=new JLabel(本软件介绍”);pr
40、ivate JTextArea jstx=new JTextArea();private JButton d2=new JButton(”返回主界面);public jiesh()super(软件介绍);setSize(400,350);setBackground(Color。LIGHT_GRAY);this.setLocationRelativeTo(this。getParent();setResizable(false);Container cont=this。getContentPane();cont。setLayout(null);q1。setBounds(150,20,300,30)
41、;jstx。setBounds(40,50,300,200);jstx.setText(本软件适用于人事工资管理不复杂的中小企业或其他类型n 企事业单位.软件界面友好、操作简单。”);jstx。setEditable(false);d2.setBounds(240,260,100,30);cont。add(q1);cont。add(jstx);cont。add(d2);d2.addActionListener(this);setVisible(true);public void actionPerformed(ActionEvent ae)if(ae.getActionCommand().eq
42、uals(返回主界面)dispose();mainff.javaimport java.awt。;import java。awt.event。;import java.awt.Window;import javax.swing。;import javax.swing.tree.*;import java.sql.;import java.awt.geom。;class mainff extends Frame implements ActionListenerprivate condb con=null;private ResultSet rs=null;String sql=null;Str
43、ing sqlb=null;private JOptionPane jop=new JOptionPane();private MenuBar mnubar=new MenuBar();private Menu gongzi=new Menu(工资管理);private Menu lookfor=new Menu(信息查询);private Menu initsys=new Menu(”系统初始化);private Menu user=new Menu(”用户管理);private Menu help=new Menu(”帮助信息);private MenuItem gong1=new Men
44、uItem(”全部查询);private MenuItem search1=new MenuItem(”扣除工资查询);private MenuItem search3=new MenuItem(职工工资查询);private MenuItem search2=new MenuItem(职工休假查询);private MenuItem dep=new MenuItem(”添加工资);private MenuItem emp=new MenuItem(选择支付方式”);private MenuItem selary=new MenuItem(”添加休假);private MenuItem use
45、r1=new MenuItem(用户管理”);private MenuItem help1=new MenuItem(系统介绍”);private MenuItem help2=new MenuItem(”操作说明”);private MenuItem help3=new MenuItem(”版本信息);private Image img;public mainff()super(欢迎使用工资管理系统!);setSize(800,600);setBackground(Color.LIGHT_GRAY);setLayout(null);/以下三句设置当前框架位置。Dimension scr=To
46、olkit.getDefaultToolkit().getScreenSize();Dimension frm=this。getSize();setLocation((int)(scr.getWidth()-frm.getWidth()/2,(int)(scr。getHeight()-frm.getHeight()/250);/设置水平居中.gongzi。add(gong1);lookfor.add(search1);lookfor.add(search2);lookfor。add(search3);initsys.add(dep);initsys。add(emp);initsys.add(s
47、elary);user。add(user1);mnubar.add(gongzi);mnubar.add(lookfor);mnubar。add(initsys);mnubar.add(user);mnubar.add(help);help.add(help1);help.add(help2);help.add(help3);img=getToolkit().getImage(getClass().getResource(/sk.jpg”);this.setMenuBar(mnubar);/设置菜单条,显示菜单gongzi.addActionListener(this);initsys.add
48、ActionListener(this);lookfor。addActionListener(this);user。addActionListener(this);help。addActionListener(this);setVisible(true);/设置可显性addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)tuich tc=new tuich(););/关闭窗口public void paint(Graphics g)g.setClip(new Rectangle2D。Float(
49、0,30,800,570);g.drawImage(img,0,0,this);public void actionPerformed(ActionEvent ae)if(ae。getActionCommand().equals(”添加休假))gz gong=new gz();/类调用if(ae.getActionCommand().equals(”选择支付方式)zg zhi=new zg();/类调用if(ae.getActionCommand().equals(添加工资)bm bu=new bm();if(ae.getActionCommand()。equals(职工工资查询”))gzcx
50、 gongcx=new gzcx();if(ae.getActionCommand()。equals(扣除工资查询))bmcx bucx=new bmcx();if(ae.getActionCommand()。equals(”职工休假查询”)zgcx zhi=new zgcx();if(ae.getActionCommand()。equals(用户管理)user use=new user();if(ae.getActionCommand().equals(”全部查询”))whole use1=new whole();if(ae。getActionCommand()。equals(系统介绍”)j