下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、企业(Java+MySQL)资管理系统作者:日期:#企业工资管理系统(MySQL+Java软件下载:本代码仅供初学者参考使用,相互学习,共同进步,让优秀成为一种习惯。htt P: /51share.isitestar.c n/开发语言:Java开发工具:ecli pse7数据库软件:MySQL 数据库驱动:mysql-co nn ector-java-5.1.6-bin驱动下载地址: http:/pan .baidu.eom/s/1sixOLWT以下是代码和界面截图,共7个类。1. DB1欢迎界面国欢迎进入工资管理系统进入系统退崔系统import java.awt.*;import java.
2、awt.eve nt.*;import javax.swi ng.*;class DB1 exte nds JFrame imp leme nts Action Liste ner p rivate static fin al l ong serialVers ionUID = 1L;JFrame frame = new JFrame("欢迎进入工资管理系统 ");JLabel label = new JLabel("", JLabel.CENTER);JButton button1 = new JButton(” 进入系统");JButton
3、 button2 = new JButton(” 退出系统");void Create。JPanel pcontentPane = (JPan el) frame.getC ontentPan e();pcontentPan e.add(label);pcontentPan e.setLayout (new FlowLayout();pcontentPan e.add(butt on 1);DL登陆界面pcontentPan e.add(butt on 2);pcontentPan e.setBackgro un d(Color.gray);pcontentPan e.setVisi
4、ble(true);butt on 1.addAct ion Liste ner(this);butt on 2.addAct ion Liste ner(this);frame.setDefaultClose Op erati on (JFrame.EXIT_ON_CLOSE); frame .p ack();frame.setBou nds(500, 300, 300, 150);frame.setResizable(false); frame.setVisible(true);p ublic static void main( Stri ng args) DB1 dome = new D
5、B1(); dome.Create();p ublic void actionP erformed(Act ion Eve nt e) if (butt on 1.equals(e.getSource() DL dl = new DL();dl.create(); frame.dis po se();if (butto n2.equals(e.getSource() / 退出System.exit(0);1.import java.awt.Color;import java.awt.FlowLayout;import java.awt.eve nt.Act ionEvent;import ja
6、va.awt.eve nt.Act ion Liste ner;import java.sql.C onnection;import java.sql.DriverMa nager;import java.sql.ResultSet;import java.sql.Stateme nt;import javax.swi ng.JButt on;import javax.swi ng.JFrame;import javax.sw in g.JLabel;import javax.sw in g.J Op tio nPane; import javax.sw in g.J Pan el;impor
7、t javax.swi ng.J PasswordField; import javax.swi ng.JTextField;import com.mysql.jdbc. Prep aredStateme nt;Supp ressWar nin gs("serial") class DL exte nds JFrame impi eme nts Acti on Liste nerJFrame frame = new JFrame("职工 /管理员登陆”);JLabel label1 = new JLabel("用户名");JLabel labe
8、l2 = new JLabel("密码");JButton logonButton1 = new JButton(” 管理员登录");JButton logonButton2 = new JButton(” 职工登录");JButton cancelButton = new JButton(” 退出");JTextField user name = new JTextField(9);JP asswordField p assword = new JP asswordField(9); static Stri ng t1;static Stri
9、 ng t2;void create()JPanel p = (JPan el) frame.getC ontentPan e();Supp ressWar nin gs(" unu sed")JPanel p1 = new JPan el();p. setLayout (new FlowLayout();p.add(label1);p. setSize(5, 5);p. setLocati on(4, 8);p. add(user name);p.setSize(100, 200);p.setLocati on(800, 800);p.add(label2);p.setS
10、ize(50, 20);p .setLocati on (40, 80);p. add( password);p.setSize(100, 20);p .setLocati on (80, 120);p. add(log on Butt on 1);p. add(log on Butt on 2);p. add(ca ncelButt on);p. setBackgro un d(Color.gray);p .setVisible(true);logo nButt on 1.addActi on Liste ner(this);logo nButt on 2.addActi on Liste
11、ner(this);can celButt on. addActi on Liste ner(this);frame.setDefaultClose Op erati on (JFrame.EXIT_ON_CLOSE); frame .p ack();frame.setBou nds(500, 300, 500, 220); frame.setVisible(true); Supp ressWar nin gs("de precatio n")p ublic void actionP erformed(Act ion Eve nt e) t1 = username.getT
12、ext();t2 = p assword.getText();if(e.getSource()=logo nButt on1)if( user name.getText().equals("adm in") = true&& (p assword.getText().equals("adm in") = true)JOp tio nPan e.showMessageDialog(this,"登录成功! ”);GZGLZJM gz = new GZGLZJM();gz.create();frame.dis po se();else
13、 JOptionPane.showMessageDialog(null,"输入用户名或密码错误!");if (e.getSource()=log on Butt on2)try Conn ecti on con;Stateme nt ps;ResultSet rs;String sql = nu II;Class.forName("org.gjt.mm.mysql.Driver"); Class.forName("org.gjt.mm.mysql.Driver"). newin sta nce(); con = DriverMa na
14、ger.getC onnection("jdbc:mysql:/localhost:3306/ma nageme nt","root","hellomysql"); sql="select * fromworker where num="+和+"' and password='"+t2+""'ps=(Prep aredStateme nt)con.prep areStateme nt(sql);rs = p s.executeQuery(sql);if
15、(rs. next()if(rs.getStri ng(” num").equals(t1) && rs.getStri ng(" password").equals(t2)YGGLZJM yg = new YGGLZJM();yg.createO;frame.dis po se();JOptionPane.showMessageDialog(this,"登录成功!"); this.dis po se(); else JOptionPane.showMessageDialog(this,"输入用户名或密码错误!&quo
16、t;);catch (Exce ptio n e1) / TODO Auto-ge nerated catch blocke1. prin tStackTrace();if (cancelButton.equals(e.getSource() / 退出System.exit(0);2.GZGL工资管理界面员工工资管理录入K工号基本工资津贴奖金保脸总工资000011800300200110020020000000228003002001002003000000031800300200100200200000004280030020010020030000000518003002001002002
17、0000000720002002001001002200I砸回虹号总工资基菇工资津贴奖金I部门import java.awt.Color;import java.awt.FlowLayout;import java.awt.eve nt.Act ionEvent;import java.awt.eve nt.Act ion Liste ner;import java.sql.C onnection;import java.sql.DriverMa nager;import java.sql.ResultSet;import java.sql.SQLExce ptio n;import java
18、.sql.Stateme nt;import javax.swi ngJButt on;import javax.swi ngJFrame;import javax.sw in g.JLabel;import javax.swi ngJ Op tio nPane;import javax.sw in g.J Pan el;import javax.sw in g.JScroll Pane;import javax.sw in g.JS plit Pane;import javax.sw in g.JTable;import javax.swi ng.JTextField;Supp ressWa
19、r nin gs("serial")p ublic class GZGL exte nds JFrame impi eme nts Acti on Liste ner JFrame f = new JFrame(”员工工资管理”);JButton b1 = new JButton(” 录入");JButton b2 = new JButton(” 修改");JButton b3 = new JButton("删除");JButton b4 = new JButton(” 查询所有");JButton b5 = new JBu
20、tton(” 返回");JTextField tf1 = new JTextField(6);JTextField tf2 = new JTextField(4);JTextField tf3 = new JTextField(4);JTextField tf4 = new JTextField(4);JTextField tf5 = new JTextField(4);JTextField tf6 = new JTextField(4);JTextField tf7 = new JTextField(6);JTextField tf8 = new JTextField(6);JTe
21、xtField tf9 = new JTextField(4);JTextField tf10= new JTextField(4);JTextField tf11= new JTextField(6);JTextField tf12= new JTextField(6);String cloum = "职工号","基本工资","津贴","奖金","保险","房贷",”总工资"Object row = new Object507;JTable table = new
22、 JTable(row, cloum);JScroll Pane scroll pane = new JScroll Pan e(table);JSplitPane splitpane = new JSp lit Pan e(JS pl it Pan e.VERTICAL_S PLIT);void create() JPanel p = (JPanel) f.getCo ntentPan e();p. setLayout (new FlowLayout();p. add(scroll pan e);p. add(s plit pan e);JPanel p1 = new JPan el();p
23、 1.add(b1);p1.add(b2);p1.add(b3);p1.add(b4);p1.add(b5);JPanel p2 = new JPan el();p 2.setBackgro un d(Color.gray);p 2.add(scroll pan e);Supp ressWar nin gs(" unu sed")15JPanel p3 = new JPan el();p. setLayout (new FlowLayout();p.add( new JLabel("");p.add(new JLabel("职工号")
24、;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);p.add(new JLabel("总工资");p.add(tf7);p.add(new JLabel(&quo
25、t;姓名");p.add(tf8);p.add(new JLabel("性别");p.add(tf9);p.add(new JLabel("年龄");p .add(tf1O);p.add(new JLabel("部门");p .add(tf11);p.add(new JLabel("职业");p .add(tf12);sp lit pan e.add( p1, JS pl it Pan e.TO P);sp lit pan e.add( p2, JS pl it Pan e.BOTTOM);sp lit
26、pan e.setDividerLocati on( 50);p. setBackgro un d(Color.gray);b1.addAct ion Liste ner(this);b2.addAct ion Liste ner(this);b3.addAct ion Liste ner(this);b4.addAct ion Liste ner(this);b5.addAct ion Liste ner(this);f.setBou nds(500, 100, 500, 600);f.setResizable(false);/可以调整界面大小 f.setVisible(true);p ub
27、lic void actionP erformed(Act ion Eve nt e) if (b1.equals(e.getSource() / 录入Conn ecti on con;Stateme nt sql;try Class.forName("org.gjt.mm.mysql.Driver"); catch (ClassNotFou ndExce ption e1) System.out .prin tl n("” + e1);try con=DriverMa nager.getC onnection ("jdbc:mysql:/localho
28、st:3306/ma nageme nt","root","hellomys ql");sql = con. createStateme nt();Stri ngin sertStr="INSERTINTOsalary(worker_ nu m,basic_ pay,welfare,b onu s,i nsura nce,hous ing_fund,p ayme nt)VALUES("'+tf1.getText()+"',"'+tf2.getText()+"',&
29、#39; "+tf3.getText()+"T"+tf4.getText()+"T"+tf5.getText()+"T"+tf6.getText()+"T"+tf7.getText()+"');"sql.execute Up date(i nsertStr);Stri ngin sertStr1="INSERTINTOworker(n um, name,sex,age,de p,occu p,p assword)VALUES('"+tf1.getTe
30、xt()+"','"+tf8.getText()+"','"+tf9.getText()+"','"+tf10.getTe xt()+"','"+tf11.getText()+"','"+tf12.getText()+"','"+tf1.getText()+"');"sql.execute Up date(i nsertStr1);con. close(
31、);JOp tio nPan e.showMessageDialog(this,"入录成功! ”); catch (SQLExce ption e1) JOp tio nPan e.showMessageDialog(this,"入录失败! ”);if (b2.equals(e.getSource() / 修改Conn ecti on con;Stateme nt sql;try Class.forName("org.gjt.mm.mysql.Driver"); catch (ClassNotFou ndExce ption e1) System.out
32、 .prin tl n("” + e1);try con=DriverMa nager.getC onnection ("jdbc:mysql:/localhost:3306/ma nageme nt","root","hellomys ql");sql = con. createStateme nt();Stri ngup dateStr="UP DATEsalarySETbasic_ pay=”'+tf2.getText()+"',welfare=”'+tf3.getText(
33、)+"',bo nus=”'+tf4.getText()+"',i nsura nce=”'+tf5.getText()+"',housin g_fun d='"+tf6.getText()+"', payme nt="'+tf7.getText()+"'where worker_ nu m="'+tf1.getText()+"'"sql.execute Up date( up dateStr);Stri n
34、gup dateStr1="UP DATEworkerSETname='"+tf8.getText()+"',sex='"+tf9.getText()+"',age='"+tf10.getText()+"',de p=”'+tf11.getText()+"',occu p=”'+tf12.getText ()+"'where num='"+tf1.getText()+"'"sql.
35、execute Up date( up dateStr1);JOp tio nPan e.showMessageDialog(this,"修改成功!”);con. close(); catch (SQLExce ption e1) JOp tio nPan e.showMessageDialog(this,"信息不存在!"); if (b3.equals(e.getSource() / 删除Conn ecti on con;Stateme nt sql;Supp ressWar nin gs(" unu sed")ResultSet rs;tr
36、y Class.forName("org.gjt.mm.mysql.Driver"); catch (ClassNotFou ndExce ption e1) System.out .prin tl n("” + e1);try conDriverMa nager.getC onnection ("jdbc:mysql:/localhost:3306/ma nageme nt","root","hellomys ql");sql = co n.createStateme nt(ResultSet.T YP
37、 E_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONL Y);sql.execute Up date("DELETE FROM salarywhere worker_num-"+tf1.getText()+"'");sql.execute Up date("DELETE FROM workerwhere nu m=”'+tf1.getText()+"'");JOptionPane.showMessageDialog(this,"删除成功!”);con.
38、close(); catch (SQLExce ption e1) JOptionPane.showMessageDialog(this,"删除失败!”); if (b4.equals(e.getSource() / 查询全部Conn ecti on con;Stateme nt sql;ResultSet rs;try Class.forName("org.gjt.mm.mysql.Driver"); catch (ClassNotFou ndExce ption e1) JOp tio nPan e.showMessageDialog(this,"连
39、接数据库失败!”);try conDriverMa nager.getC onnection ("jdbc:mysql:/localhost:3306/ma nageme nt","root","hellomysql");sql = co n.createStateme nt(ResultSet.T YP E_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONL Y);if (b4.equals(e.getSource() for (int i = 0; i < 50; i+)for (i nt
40、j = 0; j < 4; j+) table.setValueAt("", i, j);rs = sql.executeQuery("select * from salary"); int k = -1;while (rs.n ext() +k;String no = rs.getStri ng(1);String jb = rs.getStri ng(2);Stri ng jt = rs.getStri ng(3);String jj = rs.getStri ng(4);String bx = rs.getStri ng(5);String
41、zf = rs.getStri ng(6);String sum=rs.getStri ng(7);table.setValueAt( no, k, 0); table.setValueAt(jb, k, 1); table.setValueAt(jt, k, 2); table.setValueAt(jj, k, 3); table.setValueAt(bx, k, 4); table.setValueAt(zf, k, 5); table.setValueAt(sum,k, 6); catch (SQLExce ption e1) JOp tio nPan e.showMessageDi
42、alog(this,"查询失败!");if (b5.equals(e.getSource() / 返回 GZGLZJM gl=new GZGLZJM(); gl.create();f.dis po se();3.GZGLZJM 工资管理主界面工資管理员工信息管理逅回17 lpimport java.awt.Color;import java.awt.FlowLayout;import java.awt.eve nt.Act ionEvent;import java.awt.eve nt.Act ion Liste ner;import javax.swi ng.JButt
43、on; import javax.swi ng.JFrame;import javax.swi ng.J Pan el;class GZGLZJM exte nds JFrame imp leme nts Acti on Liste ner p rivate static fin al l ong serialVers ionUID = 1L; JFrame f = new JFrame("工资管理系统”); JButton b1 = new JButton(” 工资管理"); JButton b2 = new JButton(” 员工信息管理"); JButto
44、n b3 = new JButton(” 返回");void create() JPanel p = (JPan el) f.getCo nte ntPan e();p. setLayout (new FlowLayout();p.add(b1);p.add(b2);p.add(b3);p. setBackgro un d(Color.gray);p .setVisible(true);b1.addAct ion Liste ner(this); b2.addAct ion Liste ner(this); b3.addAct ion Liste ner(this); f.setBo
45、u nds(500, 300, 500, 200); f.setResizable(false);f.setVisible(true);p ublic void actionP eformed(Act ion Eve nt e) if (b3.equals(e.getSource() / DL d = new DL(); d.create();f.dis po se();返回4.if (b2.equals(e.getSource() / YGGL yg = new YGGL(); yg.create();f.dis po se();if (b1.equals(e.getSource() / G
46、ZGL gz = new GZGL(); gz. create();f.dis po se();XGMM修改密码员工信息管理员工工资管理密码修改近回21import java.awt.Color;import java.awt.FlowLayout;import java.awt.eve nt.Act ionEvent;import java.awt.eve nt.Act ion Liste ner;import java.sql.C onnection;import java.sql.DriverMa nager;import java.sql.SQLExce ptio n;import j
47、ava.sql.Stateme nt;import javax.swi ngJButt on; import javax.swi ngJFrame;import javax.sw in g.JLabel;import javax.sw in g.J Op tio nPane;import javax.sw in g.J Pan el;import javax.swi ng.J PasswordField;Supp ressWar nin gs("serial")class XGMM exte nds DL impi eme nts Action Liste nerJFram
48、e frame = new JFrame("密码修改");JLabel label1 = new JLabel("原密码");JLabel label2 = new JLabel("新密码");JButton Button1 = new JButton(” 确定");JButton cancelButton = new JButton(” 返回");JP asswordField p assword = new JP asswordField(9);JP asswordField newp assword = ne
49、w JP asswordField(9); void create()JPanel p = (JPan el) frame.getC ontentPan e();p. setLayout (new FlowLayout();p.add(label1);p. setSize(5, 5);p. setLocati on(4, 8);p. add( password);p.setSize(100, 200);p.setLocatio n(600, 600);p.add(label2);p.setSize(50, 20);p .setLocati on (40, 80);p. add( newp as
50、sword);p.setSize(100, 20);p .setLocati on (80, 120);p.add(Butto n1);p. add(ca ncelButt on);p. setBackgro un d(Color.cya n);p .setVisible(true);Butt on 1.addAct ion Liste ner(this);can celButt on. addActi on Liste ner(this);frame.setDefaultClose Op erati on (JFrame.EXIT_ON_CLOSE); frame .p ack();fram
51、e.setBou nds(200, 100, 500, 220); frame.setVisible(true);p ublic void actionP erformed(Act ion Eve nt e) if (e.getSource()=Butt on1)Conn ecti on con;Stateme nt sql;try Class.forName("org.gjt.mm.mysql.Driver"); catch (ClassNotFou ndExce ption e1) JOp tio nPan e.showMessageDialog(this,"
52、连接数据库失败!");try conDriverMa nager.getC onnection ("jdbc:mysql:/localhost:3306/ma nageme nt","root","hellomys ql");sql = con. createStateme nt();Supp ressWar nin gs("de precatio n")String updateStr = "UPDATE worker SET password='"+newpassword.
53、getText()+"'wherenum=”'+t1+"'"sql.execute Up date( up dateStr);JOp tio nPan e.showMessageDialog(this,"修改成功! ”);con. close();frame.dis po se(); catch (SQLExce ption e1) JOp tio nPan e.showMessageDialog(this,"请输入原密码和新密码!");if (e.getSource()=cancelButton) / 返回Y
54、GGLZJM dl=new YGGLZJM();dl.createO;frame.dis po se();5.YGGL员工信息管理界面员工信息管理储次员工信息,删隱员工信息查询晰有员工信息返回55工号姓名性别年龄部门55业OOOO'II金虎21技术科工程师1:J.虹号世别gpnimport java.awt.Color;import java.awt.FlowLayout;import java.awt.eve nt.Act ionEvent;import java.awt.eve nt.Act ion Liste ner;import java.sql.C onnection;imp
55、ort java.sql.DriverMa nager;import java.sql.ResultSet;import java.sql.SQLExce ptio n;import java.sql.Stateme nt;import javax.swi ngJButt on;import javax.swi ngJFrame;import javax.sw in g.JLabel;import javax.swi ngJ Op tio nPane;import javax.sw in g.J Pan el;import javax.sw in g.JScroll Pane;import j
56、avax.sw in g.JS plit Pane;import javax.sw in g.JTable;import javax.swi ng.JTextField;Supp ressWar nin gs("serial")p ublic class YGGL exte nds JFrame impi eme nts Action Liste ner JFrame f = new JFrame("员工信息管理”);JButton b2 = new JButton(” 修改员工信息”);JButton b3 = new JButton(” 删除员工信息”);JButton b4 = new JButton(” 查询所有员工信息 ”);JButton b5 = new JButton(” 返回");JTextField tf1 = new JTextField(8);JTextField tf2 = new JTextField(8);JTextField tf3 = new JTextField(6);JTextField tf4 = new JTextField(6);JTextField tf5 = new JTextField(6);JTextField tf6 = new JTextField(6);String clo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 通风与空调施工方案
- 二零二五年度2025版特色树种绿化苗木种植与养护服务合同3篇
- 2024年装修材料环保标准合同3篇
- 农家通道施工方案
- 木质吸音板施工方案
- 2024年酒店式办公预订协议3篇
- 2025版企业市场营销策略与渠道拓展服务合同3篇
- 2024年酒店改造项目设计及装修协议范本版B版
- 2025年度泵车租赁合同的验收与评估3篇
- 2025年度酒店客房改造场地租赁及室内设计合同3篇
- 2024年机动车检测站质量手册程序文件记录表格合集(根据补充要求编制)
- 公司未来发展规划及目标制定
- 2024年01月11067知识产权法期末试题答案
- 2025版国家开放大学法律事务专科《民法学(2)》期末纸质考试案例分析题库
- 浙江省杭州市钱塘区2023-2024学年四年级上学期语文期末试卷
- GB/T 44713-2024节地生态安葬服务指南
- 2024年形势与政策 第一讲《读懂中国式现代化》
- 一年级家长会课件2024-2025学年
- 情侣防出轨合同模板
- 2024-2025学年苏教版四年级上册期末自主测试数学试卷(一)(含答案解析)
- 中国特色大国外交和推动构建人类命运共同体
评论
0/150
提交评论