工资系统代码JAVA版.docx

上传人:b****0 文档编号:12824990 上传时间:2023-04-22 格式:DOCX 页数:53 大小:25.67KB
下载 相关 举报
工资系统代码JAVA版.docx_第1页
第1页 / 共53页
工资系统代码JAVA版.docx_第2页
第2页 / 共53页
工资系统代码JAVA版.docx_第3页
第3页 / 共53页
工资系统代码JAVA版.docx_第4页
第4页 / 共53页
工资系统代码JAVA版.docx_第5页
第5页 / 共53页
点击查看更多>>
下载资源
资源描述

工资系统代码JAVA版.docx

《工资系统代码JAVA版.docx》由会员分享,可在线阅读,更多相关《工资系统代码JAVA版.docx(53页珍藏版)》请在冰豆网上搜索。

工资系统代码JAVA版.docx

工资系统代码JAVA版

工资系统代码

/*系统欢迎界面*/

importjava.awt.FlowLayout;

importjava.awt.event.*;

importjavax.swing.*;

@SuppressWarnings("serial")

classWagesSystemextendsJFrameimplementsActionListener

{

JFrameframe=newJFrame("欢迎进入工资管理系统");

JButtonbutton1=newJButton("进入系统");

JButtonbutton2=newJButton("退出系统");

ImageIconim=newImageIcon("1.jpg");

JLabela1=newJLabel(im);

voidCreate()

{

JPanelpcontentPane=(JPanel)frame.getContentPane();

pcontentPane.add(a1);

pcontentPane.setLayout(newFlowLayout());

pcontentPane.add(button1);

pcontentPane.add(button2);

pcontentPane.setVisible(true);

button1.addActionListener(this);

button2.addActionListener(this);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.pack();

frame.setLocationRelativeTo(null);

frame.setVisible(true);

}

publicstaticvoidmain(String[]args)

{

WagesSystemdome=newWagesSystem();

dome.Create();

}

publicvoidactionPerformed(ActionEvente)

{

if(button1.equals(e.getSource()))

{

DLdl=newDL();

dl.create();

frame.dispose();

}

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

{

System.exit(0);

}

}

}

 

/*登录界面*/

importjava.awt.HeadlessException;

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.JPasswordField;

importjavax.swing.JTextField;

import.*;

importjava.sql.*;

@SuppressWarnings("serial")

classDLextendsJFrameimplementsActionListener

{

NetConnsql;

Statementsqll;

ResultSetrs;

JFrameframe=newJFrame("职工/管理员登陆");

JLabellabel1=newJLabel("用户名");

JLabellabel2=newJLabel("密码");

JButtonlogonButton1=newJButton("系统管理员登录");

JButtonlogonButton2=newJButton("教职工登录");

JButtonlogonButton3=newJButton("财务管理员登录");

JButtoncancelButton=newJButton("退出");

JTextFieldusername=newJTextField(9);

JPasswordFieldpassword=newJPasswordField(9);

staticStringt1;

staticStringt2;

voidcreate()

{

frame.setLayout(null);

label1.setBounds(60,20,50,20);

frame.add(label1);

username.setBounds(130,20,150,20);

frame.add(username);

label2.setBounds(60,50,50,20);

frame.add(label2);

password.setBounds(130,50,150,20);

frame.add(password);

logonButton1.setBounds(100,90,150,20);

frame.add(logonButton1);

logonButton2.setBounds(100,120,150,20);

frame.add(logonButton2);

logonButton3.setBounds(100,150,150,20);

frame.add(logonButton3);

cancelButton.setBounds(100,180,150,20);

frame.add(cancelButton);

logonButton1.addActionListener(this);

logonButton2.addActionListener(this);

logonButton3.addActionListener(this);

cancelButton.addActionListener(this);

sql=newNetConn();//建立数据库连接

frame.setSize(350,250);

frame.setLocationRelativeTo(null);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

@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,"登录成功!

");

xtglya=newxtgly();

frame.dispose();

}

else

{

JOptionPane.showMessageDialog(null,"输入用户名或密码错误!

");

}

}

//教职工登陆

if(e.getSource()==logonButton2)

{

sqll=sql.connect();

try

{

rs=sqll.executeQuery("SELECT*FROMuser_teacherwherename="+"'"+username.getText()+"'");

Stringsname,spass;

if(rs.next())

{

sname=rs.getString

(2);

spass=rs.getString(3);

if((password.getText().trim().equals(spass))&&(username.getText().trim().equals(sname)))

{

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

");

Teacher_Pa=newTeacher_P();

a.creat(rs.getString

(1));

frame.dispose();

}

else

{

JOptionPane.showMessageDialog(null,"输入用户名或密码错误!

");

}

}

else

{

JOptionPane.showMessageDialog(null,"用户不存在!

");

}

}

catch(SQLExceptione2){

//TODO自动生成的catch块

e2.printStackTrace();

}

}

//财务登陆

if(e.getSource()==logonButton3)

{

sqll=sql.connect();

try

{

rs=sqll.executeQuery("SELECT*FROMuser_cwwherename="+"'"+username.getText()+"'");

Stringsname,spass;

if(rs.next())

{

sname=rs.getString

(2);

spass=rs.getString(3);

if((password.getText().trim().equals(spass))&&(username.getText().trim().equals(sname)))

{

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

");

CWa=newCW();

a.create(rs.getString

(1));

frame.dispose();

}

else

{

JOptionPane.showMessageDialog(null,"输入用户名或密码错误!

");

}

}

else

{

JOptionPane.showMessageDialog(null,"用户不存在!

");

}

}

catch(SQLExceptione2){

//TODO自动生成的catch块

e2.printStackTrace();

}

}

//退出

if(cancelButton.equals(e.getSource()))

{

System.exit(0);

}

}

}

/*数据库链接*/

importjava.sql.*;

//数据库联接类

publicclassNetConn

{

Connectioncon;

Statementsql;

publicStatementconnect()

{

try

{

//载入驱动程序字符串

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

}

catch(ClassNotFoundExceptione1)

{

}

try

{

//通过JDBCURL得到Connetction对象

con=DriverManager.getConnection("jdbc:

sqlserver:

//localhost:

1433;DatabaseName=gzxt","sa","123456");

//通过Connection对象创建Statement对象

sql=con.createStatement();

}

catch(SQLExceptione2)

{}

returnsql;

}

}

/*系统管理员界面*/

importjava.awt.BorderLayout;

importjava.awt.Container;

importjava.awt.event.ActionEvent;

importjava.awt.event.ActionListener;

importjava.sql.ResultSet;

importjava.sql.SQLException;

importjava.sql.Statement;

importjavax.swing.JButton;

importjavax.swing.JDialog;

importjavax.swing.JFrame;

importjavax.swing.JLabel;

importjavax.swing.JPasswordField;

importjavax.swing.JScrollPane;

importjavax.swing.JTabbedPane;

importjavax.swing.JTable;

importjavax.swing.JTextField;

 

@SuppressWarnings("serial")

classxtglyextendsJFrameimplementsActionListener

{

JFrameframe=newJFrame("教职工信息查询及密码修改");

Objecta[][],b[][];

Objectcolname[]={"工号","姓名","密码"};

NetConnsql;

Statementsqll;

ResultSetrs;

JTabletable,table2;

JButtonButton1=newJButton("添加教职工");

JButtonButton2=newJButton("添加财务管理员");

JButtonButton3=newJButton("修改密码");

JButtonButton4=newJButton("刷新");

JTabbedPanetab=newJTabbedPane(JTabbedPane.TOP);

inti=0;

xtgly()

{

frame.setLayout(null);

sql=newNetConn();

sqll=sql.connect();

a=newObject[30][3];

b=newObject[30][3];

try

{

Stringtemp="select*fromuser_cw";

rs=sqll.executeQuery(temp);

while(rs.next())

{

a[i][0]=rs.getString

(1);

a[i][1]=rs.getString

(2);

a[i][2]=rs.getString(3);

i++;

}

i=0;

Stringtemp2="select*fromuser_teacher";

rs=sqll.executeQuery(temp2);

while(rs.next())

{

b[i][0]=rs.getString

(1);

b[i][1]=rs.getString

(2);

b[i][2]=rs.getString(3);

i++;

}

}

catch(SQLExceptione)

{

//TODO自动生成的catch块

e.printStackTrace();

}

table=newJTable(a,colname);

table.setEnabled(false);

table2=newJTable(b,colname);

table2.setEnabled(false);

JScrollPaneJSP=newJScrollPane(table);

JScrollPaneJSP2=newJScrollPane(table2);

tab.add(JSP,"财务管理员");

tab.add(JSP2,"教职工");

tab.setBounds(0,0,350,180);

Button1.setBounds(1,185,110,20);

Button1.addActionListener(this);

Button2.setBounds(115,185,125,20);

Button2.addActionListener(this);

Button3.setBounds(245,185,89,20);

Button3.addActionListener(this);

Button4.setBounds(260,0,75,20);

Button4.addActionListener(this);

frame.add(Button1);

frame.add(Button2);

frame.add(Button3);

frame.add(Button4);

frame.add(tab);

frame.setSize(350,250);

frame.setLocationRelativeTo(null);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

publicvoidactionPerformed(ActionEvente)

{

//添加教职工

if(e.getSource()==Button1)

{

Add_teacheradd1=newAdd_teacher();

}

//添加财务管理员

if(e.getSource()==Button2)

{

Add_cwadd2=newAdd_cw();

}

//修改密码

if(e.getSource()==Button3)

{

Change_mimachange=newChange_mima();

}

if(e.getSource()==Button4)

{

i=0;

try

{

Stringtemp="select*fromuser_cw";

rs=sqll.executeQuery(temp);

while(rs.next())

{

a[i][0]=rs.getString

(1);

a[i][1]=rs.getString

(2);

a[i][2]=rs.getString(3);

i++;

}

i=0;

Stringtemp2="select*fromuser_teacher";

rs=sqll.executeQuery(temp2);

while(rs.next())

{

b[i][0]=rs.getString

(1);

b[i][1]=rs.getString

(2);

b[i][2]=rs.getString(3);

i++;

}

}

catch(SQLExceptione1)

{

//TODO自动生成的catch块

e1.printStackTrace();

}

table.removeAll();

table2.removeAll();

table=newJTable(a,colname);

table.setEnabled(false);

table2=newJTable(b,colname);

table2.setEnabled(false);

tab.updateUI();

}

}

}

/*添加财务管理人员*/

importjava.awt.event.ActionEvent;

importjava.awt.event.ActionListener;

importjava.sql.ResultSet;

importjava.sql.SQLException;

importjava.sql.Statement;

importjavax.swing.JButton;

importjavax.swing.JDialog;

importjavax.swing.JLabel;

importjavax.swing.JOptionPane;

importjavax.swing.JPasswordField;

importjavax.swing.JTextField;

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

当前位置:首页 > 经管营销 > 经济市场

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

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