1、工资系统代码JAVA版工资系统代码/*系统欢迎界面*/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(退出系统); Ima
2、geIcon im = new ImageIcon(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.addActionList
3、ener(this); button2.addActionListener(this); 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(ActionEven
4、t e) if (button1.equals(e.getSource() DL dl = new DL(); 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.DriverMan
5、ager;import java.sql.ResultSet;import java.sql.SQLException;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.*;SuppressWarn
6、ings(serial)class DL extends JFrame implements ActionListener 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(教职工登录); JBut
7、ton logonButton3 = new JButton(财务管理员登录); JButton cancelButton = new JButton(退出); JTextField 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); userna
8、me.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.se
9、tBounds(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=new NetConn();/建立数据库连接 frame.
10、setSize(350,250); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SuppressWarnings(deprecation) public void actionPerformed(ActionEvent e) t1 = username.getText(); t2 = password.getText(); /系统管理员登录 if(e.getSource()=logonButton1) if( us
11、ername.getText().equals(admin) = true & (password.getText().equals(admin) = true) JOptionPane.showMessageDialog(this, 登录成功!); xtgly a=new xtgly(); frame.dispose(); else JOptionPane.showMessageDialog(null, 输入用户名或密码错误!); /教职工登陆 if(e.getSource()=logonButton2) sqll=sql.connect(); try rs=sqll.executeQuer
12、y(SELECT * FROM user_teacher where name=+username.getText()+); String sname,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_P a=new Teacher_P(); a
13、.creat(rs.getString(1); frame.dispose(); else JOptionPane.showMessageDialog(null, 输入用户名或密码错误!); else JOptionPane.showMessageDialog(null, 用户不存在!); catch (SQLException e2) / TODO 自动生成的 catch 块 e2.printStackTrace(); /财务登陆 if (e.getSource()=logonButton3) sqll=sql.connect(); try rs=sqll.executeQuery(SELE
14、CT * 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)&(username.getText().trim().equals(sname) JOptionPane.showMessageDialog(this, 登录成功!); CW a=new CW(); a.create(rs.getString(1);
15、frame.dispose(); else JOptionPane.showMessageDialog(null, 输入用户名或密码错误!); else JOptionPane.showMessageDialog(null, 用户不存在!); catch (SQLException e2) / TODO 自动生成的 catch 块 e2.printStackTrace(); / 退出 if (cancelButton.equals(e.getSource() System.exit(0); /*数据库链接*/import java.sql.*;/数据库联接类public class NetCo
16、nn Connection con; Statement sql; public Statement connect() try /载入驱动程序字符串 Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); catch(ClassNotFoundException e1) try /通过JDBC URL得到Connetction对象 con=DriverManager.getConnection(jdbc:sqlserver:/localhost:1433;DatabaseName=gzxt,sa,123456); /通过Con
17、nection对象创建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.ActionListener;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Stateme
18、nt;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;import javax.swing.JTable;import javax.swing.JTextField;SuppressWarnings(serial)class xtgly ext
19、ends 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(添加教职工); JButton Button2 = new JButton(添加财务管理员); JButton Button3 = new JButton(修改密码); JButt
20、on 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=sqll.executeQuery(temp); while(rs.next() ai0=rs.getString(1); a
21、i1=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.printStackTrace(); table=new JTable(a,colname); tab
22、le.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.addActionListener(this); Butto
23、n2.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.set
24、Size(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_cw();
25、 /修改密码 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
26、=sqll.executeQuery(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);
27、table2.setEnabled(false); tab.updateUI(); /*添加财务管理人员*/import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPasswordField;import javax.swing.JTextField;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1