企业工资管理系统JavaMySQL样本.docx

上传人:b****7 文档编号:11228977 上传时间:2023-02-25 格式:DOCX 页数:34 大小:116.05KB
下载 相关 举报
企业工资管理系统JavaMySQL样本.docx_第1页
第1页 / 共34页
企业工资管理系统JavaMySQL样本.docx_第2页
第2页 / 共34页
企业工资管理系统JavaMySQL样本.docx_第3页
第3页 / 共34页
企业工资管理系统JavaMySQL样本.docx_第4页
第4页 / 共34页
企业工资管理系统JavaMySQL样本.docx_第5页
第5页 / 共34页
点击查看更多>>
下载资源
资源描述

企业工资管理系统JavaMySQL样本.docx

《企业工资管理系统JavaMySQL样本.docx》由会员分享,可在线阅读,更多相关《企业工资管理系统JavaMySQL样本.docx(34页珍藏版)》请在冰豆网上搜索。

企业工资管理系统JavaMySQL样本.docx

企业工资管理系统JavaMySQL样本

企业工资管理系统(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();

 

publicvoidactionPeformed(ActionEvente){if(button1.equals(e.getSource())){

DLdl=newDL();

dl.create();

frame.dispose();

退出

if(button2.equals(e.getSource())){//

System.exit(O);

}

}

}importjava.awt.Color;

1.DL登陆界面

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("密码");

资料内容仅供您学习参考,如有不当或者侵权,请联系改正或者删除。

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");

and

sql="select*fromworkerwherenum='"+t1+"'password='"+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{

误!

");

}

}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[]cloum={"

职工号","基本工资","津贴","奖金","保险","房贷

Object[][]row=newObject[50][7];

JTabletable=newJTable(row,cloum);

JScrollPanescrollpane=newJScrollPane(table);

JSplitPanesplitpane=newJSplitPane(JSplitPane.VERTICAL_SPLIT);voidcreate(){

JPanelp=(JPanel)f.getContentPane();p.setLayout(newFlowLayout());

p.add(scrollpane);

p.add(splitpane);

JPanelp1=newJPanel();p1.add(b1);

p1.add(b2);

p1.add(b3);

p1.add(b4);

p1.add(b5);

JPanelp2=newJPanel();p2.setBackground(Color.gray);p2.add(scrollpane);

@SuppressWarnings("unused")JPanelp3=newJPanel();p.setLayout(newFlowLayout());p.add(newJLabel(""));p.add(newJLabel("职工号"));p.add(tf1);

p.add(newJLabel("基本工资"));p.add(tf2);

p.add(newJLabel("津贴"));

p.add(tf3);

p.add(newJLabel("奖金"));p.add(tf4);

p.add(newJLabel("保险"));

p.add(tf5);

p.add(newJLabel("房贷"));p.add(tf6);

p.add(newJLabel("总工资"));p.add(tf7);

资料内容仅供您学习参考,如有不当或者侵权,请联系改正或者删除。

p.add(newJLabel("姓名"));

p.add(tf8);

p.add(newJLabel("性别"));

p.add(tf9);

p.add(newJLabel("年龄"));

p.add(tf10);

p.add(newJLabel("部门"));

p.add(tf11);

p.add(newJLabel("职业"));

p.add(tf12);

splitpane.add(p1,JSplitPane.TOP);

splitpane.add(p2,JSplitPane.BOTTOM);

splitpane.setDividerLocation(50);

p.setBackground(Color.gray);

b1.addActionListener(this);

b2.addActionListener(this);

b3.addActionListener(this);

b4.addActionListener(this);

b5.addActionListener(this);

f.setBounds(500,100,500,600);

f.setResizable(false);//能够调整界面大小

f.setVisible(true);

资料内容仅供您学习参考,如有不当或者侵权,请联系改正或者删除。

publicvoidactionPerformed(ActionEvente){

if(b1.equals(e.getSource())){//录入

Connectioncon;

Statementsql;

try{

Class.forName("org.gjt.mm.mysql.Driver");

}catch(ClassNotFoundExceptione1){

System.out.println(""+e1);

}

try{

con=DriverManager.getConnection("jdbc:

mysql:

//localhost:

3306/manage

ment","root","hellomysql");

sql=con.createStatement();

salary

worker

StringinsertStr="INSERTINTO

(worker_num,basic_pay,welfare,bonus,insurance,housing_fund,payment)VAL

UES('"+tf1.getText()+"','"+tf2.getText()+"','"+tf3.getText()+"','"+tf4

.getText()+"','"+tf5.getText()+"','"+tf6.getText()+"','"+tf7.getText()

+"');";

sql.executeUpdate(insertStr);

StringinsertStr1="INSERTINTO

(num,name,sex,age,dep,occup,password)VALUES('"+tf1.getText()+"','"+tf8

资料内容仅供您学习参考,如有不当或者侵权,请联系改正或者删除。

.getText()+"','"+tf9.getText()+"','"+tf10.getText()+"','"+tf11.getText

()+"','"+tf12.getText()+"','"+tf1.getText()+"');";

sql.executeUpdate(insertStr1);

con.close();

JOptionPane.showMessageDialog(this,"入录成功!

");

}catch(SQLExceptione1){

JOptionPane.showMessageDialog(this,"入录失败!

");

}

}

if(b2.equals(e.getSource())){//修改

Connectioncon;

Statementsql;

try{

Class.forName("org.gjt.mm.mysql.Driver");

}catch(ClassNotFoundExceptione1){

System.out.println(""+e1);

}

try{

con

DriverManager.getConnection("jdbc:

mysql:

//localhost:

3306/management","root","hellomysql");

sql=con.createStatement();

资料内容仅供您学习参考,如有不当或者侵权,请联系改正或者删除。

basic_pay='"+tf2.getText()+"',welfare='"+tf3.getText()+"',bonus='"+tf4

.getText()+"',insurance='"+tf5.getText()+"',housing_fund='"+tf6.getTex

t()+"',payment='"+tf7.getText()+"'whereworker_num='"+tf1.getText()+"';";

sql.executeUpdate(updateStr);

SET

StringupdateStr1="UPDATEworker

name='"+tf8.getText()+"',sex='"+tf9.getText()+"',age='"+tf10.getText()+"',dep='"+tf11.getText()+"',occup='"+tf12.getText()+"'wherenum='"+tf1.getText()+"';";

sql.executeUpdate(updateStr1);

JOptionPane.showMessageDialog(this,"修改成功!

");con.close();

}catch(SQLExceptione1){

JOptionPane.showMessageDialog(this,"信息不存在!

");

}

}

if(b3.equals(e.getSource())){//删除

Connectioncon;

Statementsql;

@SuppressWarnings("unused")

ResultSetrs;

try{

资料内容仅供您学习参考,如有不当或者侵权,请联系改正或者删除。

Class.forName("org.gjt.mm.mysql.Driver");

}catch(ClassNotFoundExceptione1){

System.out.println(""+e1);

}

try{

con

DriverManager.getConnection("jdbc:

mysql:

//localhost:

3306/management","root","hellomysql");

sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,

ResultS

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1