工资系统代码JAVA版-.pdf
《工资系统代码JAVA版-.pdf》由会员分享,可在线阅读,更多相关《工资系统代码JAVA版-.pdf(33页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、工资系统代码/*系统欢迎界面*/import java.awt.FlowLayout;import java.awt.event.*;import javax.swing.*;SuppressWarnings(serial)class WagesSystem extends JFrame implements ActionListener JFrame frame=new JFrame(欢迎进入工资管理系统);JButton button1=new JButton(进入系统);JButton button2=new JButton(退出系统);ImageIcon im=new ImageIco
2、n(1.jpg);JLabel a1=new JLabel(im);void Create()JPanel pcontentPane=(JPanel)frame.getContentPane();pcontentPane.add(a1);pcontentPane.setLayout(new FlowLayout();pcontentPane.add(button1);pcontentPane.add(button2);pcontentPane.setVisible(true);button1.addActionListener(this);button2.addActionListener(t
3、his);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setLocationRelativeTo(null);frame.setVisible(true);public static void main(String args)WagesSystem dome=new WagesSystem();dome.Create();public void actionPerformed(ActionEvent e)if(button1.equals(e.getSource()DL dl=new DL()
4、;dl.create();frame.dispose();if(button2.equals(e.getSource()System.exit(0);/*登录界面*/import java.awt.HeadlessException;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;
5、import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPasswordField;import javax.swing.JTextField;import .*;import java.sql.*;SuppressWarnings(serial)class DL extends JFrame implements ActionListene
6、r NetConn sql;Statement sqll;ResultSet rs;JFrame frame=new JFrame(职工/管理员登陆);JLabel label1=new JLabel(用户名);JLabel label2=new JLabel(密码);JButton logonButton1=new JButton(系统管理员登录);JButton logonButton2=new JButton(教职工登录);JButton logonButton3=new JButton(财务管理员登录);JButton cancelButton=new JButton(退出);JTex
7、tField username=new JTextField(9);JPasswordField password=new JPasswordField(9);static String t1;static String t2;void create()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);p
8、assword.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(cancelButt
9、on);logonButton1.addActionListener(this);logonButton2.addActionListener(this);logonButton3.addActionListener(this);cancelButton.addActionListener(this);sql=new NetConn();/建立数据库连接frame.setSize(350,250);frame.setLocationRelativeTo(null);frame.setVisible(true);frame.setDefaultCloseOperation(JFrame.EXIT
10、_ON_CLOSE);SuppressWarnings(deprecation)public void actionPerformed(ActionEvent e)t1=username.getText();t2=password.getText();/系统管理员登录if(e.getSource()=logonButton1)if(username.getText().equals(admin)=true&(password.getText().equals(admin)=true)JOptionPane.showMessageDialog(this,登录成功!);xtgly a=new xt
11、gly();frame.dispose();else JOptionPane.showMessageDialog(null,输入用户名或密码错误!);/教职工登陆if(e.getSource()=logonButton2)sqll=sql.connect();try rs=sqll.executeQuery(SELECT*FROM user_teacher where name=+username.getText()+);String sname,spass;if(rs.next()sname=rs.getString(2);spass=rs.getString(3);if(password.
12、getText().trim().equals(spass)&(username.getText().trim().equals(sname)JOptionPane.showMessageDialog(this,登录成功!);Teacher_P a=new Teacher_P();a.creat(rs.getString(1);frame.dispose();else JOptionPane.showMessageDialog(null,输入用户名或密码错误!);else JOptionPane.showMessageDialog(null,用户不存在!);catch(SQLException
13、 e2)/TODO 自动生成的catch 块e2.printStackTrace();/财务登陆if(e.getSource()=logonButton3)sqll=sql.connect();try rs=sqll.executeQuery(SELECT*FROM user_cw where name=+username.getText()+);String sname,spass;if(rs.next()sname=rs.getString(2);spass=rs.getString(3);if(password.getText().trim().equals(spass)&(userna
14、me.getText().trim().equals(sname)JOptionPane.showMessageDialog(this,登录成功!);CW a=new CW();a.create(rs.getString(1);frame.dispose();else JOptionPane.showMessageDialog(null,输入用户名或密码错误!);else JOptionPane.showMessageDialog(null,用户不存在!);catch(SQLException e2)/TODO 自动生成的catch 块e2.printStackTrace();/退出if(ca
15、ncelButton.equals(e.getSource()System.exit(0);/*数据库链接*/import java.sql.*;/数据库联接类public class NetConn Connection con;Statement sql;public Statement connect()try /载入驱动程序字符串Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);catch(ClassNotFoundException e1)try /通过 JDBC URL 得到 Connetction 对象con=
16、DriverManager.getConnection(jdbc:sqlserver:/localhost:1433;DatabaseName=gzxt,sa,123456);/通过 Connection 对象创建 Statement 对象sql=con.createStatement();catch(SQLException e2)return sql;/*系统管理员界面*/import java.awt.BorderLayout;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event
17、.ActionListener;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPasswordField;import javax.swing.JScrollPane;import javax.swing.JTabbedPane;i
18、mport javax.swing.JTable;import javax.swing.JTextField;SuppressWarnings(serial)class xtgly extends JFrame implements ActionListener JFrame frame=new JFrame(教职工信息查询及密码修改);Object a,b;Object colname=工号,姓名,密码;NetConn sql;Statement sqll;ResultSet rs;JTable table,table2;JButton Button1=new JButton(添加教职工);
19、JButton Button2=new JButton(添加财务管理员);JButton Button3=new JButton(修改密码);JButton Button4=new JButton(刷新);JTabbedPane tab=new JTabbedPane(JTabbedPane.TOP);int i=0;xtgly()frame.setLayout(null);sql=new NetConn();sqll=sql.connect();a=new Object303;b=new Object303;try String temp=select*from user_cw;rs=sql
20、l.executeQuery(temp);while(rs.next()ai0=rs.getString(1);ai1=rs.getString(2);ai2=rs.getString(3);i+;i=0;String temp2=select*from user_teacher;rs=sqll.executeQuery(temp2);while(rs.next()bi0=rs.getString(1);bi1=rs.getString(2);bi2=rs.getString(3);i+;catch(SQLException e)/TODO 自动生成的catch 块e.printStackTr
21、ace();table=new JTable(a,colname);table.setEnabled(false);table2=new JTable(b,colname);table2.setEnabled(false);JScrollPane JSP=new JScrollPane(table);JScrollPane JSP2=new JScrollPane(table2);tab.add(JSP,财务管理员);tab.add(JSP2,教职工);tab.setBounds(0,0,350,180);Button1.setBounds(1,185,110,20);Button1.addA
22、ctionListener(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(
23、tab);frame.setSize(350,250);frame.setLocationRelativeTo(null);frame.setVisible(true);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);public void actionPerformed(ActionEvent e)/添加教职工if(e.getSource()=Button1)Add_teacher add1=new Add_teacher();/添加财务管理员if(e.getSource()=Button2)Add_cw add2=new Add_c
24、w();/修改密码if(e.getSource()=Button3)Change_mima change=new Change_mima();if(e.getSource()=Button4)i=0;try String temp=select*from user_cw;rs=sqll.executeQuery(temp);while(rs.next()ai0=rs.getString(1);ai1=rs.getString(2);ai2=rs.getString(3);i+;i=0;String temp2=select*from user_teacher;rs=sqll.executeQu
25、ery(temp2);while(rs.next()bi0=rs.getString(1);bi1=rs.getString(2);bi2=rs.getString(3);i+;catch(SQLException e1)/TODO 自动生成的catch 块e1.printStackTrace();table.removeAll();table2.removeAll();table=new JTable(a,colname);table.setEnabled(false);table2=new JTable(b,colname);table2.setEnabled(false);tab.upd
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 工资 系统 代码 JAVA
限制150内