企业工资管理系统(Java+MySQL)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

企业工资管理系统(MySQL+Java)本代码仅供初学者参考使用,相互学习,共同进步,让优秀成为一种习惯。软件下载:开发语言:Java开发工具:eclipse数据库软件:MySQL数据库驱动:mysql-connector-java-5.1.6-bin驱动下载地址:以下是代码和界面截图,共7个类。1.DB1欢迎界面importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;classDB1extendsJFrameimplementsActionListener{privatestaticfinallongserialVersionUID=1L;JFrameframe=newJFrame(欢迎进入工资管理系统);JLabellabel=newJLabel(,JLabel.CENTER);JButtonbutton1=newJButton(进入系统);JButtonbutton2=newJButton(退出系统);voidCreate(){JPanelpcontentPane=(JPanel)frame.getContentPane();pcontentPane.add(label);pcontentPane.setLayout(newFlowLayout());pcontentPane.add(button1);pcontentPane.add(button2);pcontentPane.setBackground(Color.gray);pcontentPane.setVisible(true);button1.addActionListener(this);button2.addActionListener(this);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setBounds(500,300,300,150);frame.setResizable(false);frame.setVisible(true);}publicstaticvoidmain(String[]args){DB1dome=newDB1();dome.Create();}publicvoidactionPerformed(ActionEvente){if(button1.equals(e.getSource())){DLdl=newDL();dl.create();frame.dispose();}if(button2.equals(e.getSource())){//退出System.exit(0);}}}1.DL登陆界面importjava.awt.Color;importjava.awt.FlowLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.Statement;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPasswordField;importjavax.swing.JTextField;importcom.mysql.jdbc.PreparedStatement;@SuppressWarnings(serial)classDLextendsJFrameimplementsActionListener{JFrameframe=newJFrame(职工/管理员登陆);JLabellabel1=newJLabel(用户名);JLabellabel2=newJLabel(密码);JButtonlogonButton1=newJButton(管理员登录);JButtonlogonButton2=newJButton(职工登录);JButtoncancelButton=newJButton(退出);JTextFieldusername=newJTextField(9);JPasswordFieldpassword=newJPasswordField(9);staticStringt1;staticStringt2;voidcreate(){JPanelp=(JPanel)frame.getContentPane();@SuppressWarnings(unused)JPanelp1=newJPanel();p.setLayout(newFlowLayout());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.gray);p.setVisible(true);logonButton1.addActionListener(this);logonButton2.addActionListener(this);cancelButton.addActionListener(this);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setBounds(500,300,500,220);frame.setVisible(true);}@SuppressWarnings(deprecation)publicvoidactionPerformed(ActionEvente){t1=username.getText();t2=password.getText();if(e.getSource()==logonButton1){if(username.getText().equals(admin)==true&&(password.getText().equals(admin)==true)){JOptionPane.showMessageDialog(this,登录成功!);GZGLZJMgz=newGZGLZJM();gz.create();frame.dispose();}else{JOptionPane.showMessageDialog(null,输入用户名或密码错误!);}}if(e.getSource()==logonButton2){try{Connectioncon;Statementps;ResultSetrs;Stringsql=null;Class.forName(org.gjt.mm.mysql.Driver);Class.forName(org.gjt.mm.mysql.Driver).newInstance();con=DriverManager.getConnection(jdbc:mysql://localhost:3306/management,root,hellomysql);sql=select*fromworkerwherenum='+t1+'andpassword='+t2+';ps=(PreparedStatement)con.prepareStatement(sql);rs=ps.executeQuery(sql);if(rs.next()){if(rs.getString(num).equals(t1)&&rs.getString(password).equals(t2)){YGGLZJMyg=newYGGLZJM();yg.create();frame.dispose();JOptionPane.showMessageDialog(this,登录成功!);this.dispose();}}else{JOptionPane.showMessageDialog(this,输入用户名或密码错误!);}}catch(Exceptione1){//TODOAuto-generatedcatchblocke1.printStackTrace();}}if(cancelButton.equals(e.getSource()))//退出{System.exit(0);}}}2.GZGL工资管理界面importjava.awt.Color;importjava.awt.FlowLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjavax.swing.JSplitPane;importjavax.swing.JTable;importjavax.swing.JTextField;@SuppressWarnings(serial)publicclassGZGLextendsJFrameimplementsActionListener{JFramef=newJFrame(员工工资管理);JButtonb1=newJButton(录入);JButtonb2=newJButton(修改);JButtonb3=newJButton(删除);JButtonb4=newJButton(查询所有);JButtonb5=newJButton(返回);JTextFieldtf1=newJTextField(6);JTextFieldtf2=newJTextField(4);JTextFieldtf3=newJTextField(4);JTextFieldtf4=newJTextField(4);JTextFieldtf5=newJTextField(4);JTextFieldtf6=newJTextField(4);JTextFieldtf7=newJTextField(6);JTextFieldtf8=newJTextField(6);JTextFieldtf9=newJTextField(4);JTextFieldtf10=newJTextField(4);JTextFieldtf11=newJTextField(6);JTextFieldtf12=newJTextField(6);String[]clou

1 / 24
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功