




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、標(biāo)準(zhǔn)文案工資系統(tǒng)代碼/*系統(tǒng)歡迎界面*/import java.awt.FlowLayout;import java.awt.event.*; import javax.swing.*; SuppressWarnings("serial")class WagesSystem extends JFrame implements ActionListener JFrame frame = new JFrame("歡迎進(jìn)入工資管理系統(tǒng)"); JButton button1 = new JButton("進(jìn)入系統(tǒng)"); JButton but
2、ton2 = new JButton("退出系統(tǒng)"); ImageIcon 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); p
3、contentPane.setVisible(true); button1.addActionListener(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(); dom
4、e.Create(); public void actionPerformed(ActionEvent 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;imp
5、ort java.sql.Connection;import java.sql.DriverManager;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.JT
6、extField;import .*;import java.sql.*;SuppressWarnings("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("密 碼");J
7、Button logonButton1 = new JButton("系統(tǒng)管理員登錄");JButton logonButton2 = new JButton("教職工登錄");JButton logonButton3 = new JButton("財(cái)務(wù)管理員登錄");JButton cancelButton = new JButton("退出");JTextField username = new JTextField(9);JPasswordField password = new JPasswordField
8、(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);password.setBounds(130,50,150,20);frame.add(password);logonButton1.setBounds
9、(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(thi
10、s);logonButton3.addActionListener(this);cancelButton.addActionListener(this);sql=new NetConn();/建立數(shù)據(jù)庫(kù)連接frame.setSize(350,250);frame.setLocationRelativeTo(null);frame.setVisible(true);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);SuppressWarnings("deprecation")public void actionPerfo
11、rmed(ActionEvent e) t1 = username.getText();t2 = password.getText();/系統(tǒng)管理員登錄if(e.getSource()=logonButton1)if( username.getText().equals("admin") = true&& (password.getText().equals("admin") = true) JOptionPane.showMessageDialog(this, " 登錄成功!");xtgly a=new xtgly(
12、);frame.dispose(); else JOptionPane.showMessageDialog(null, "輸入用戶名或密碼錯(cuò)誤!");/教職工登陸if(e.getSource()=logonButton2)sqll=sql.connect(); try rs=sqll.executeQuery("SELECT * FROM user_teacher where name="+"'"+username.getText()+"'");String sname,spass;if(rs.ne
13、xt()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.creat(rs.getString(1);frame.dispose(); elseJOptionPane.showMessageDialog
14、(null, "輸入用戶名或密碼錯(cuò)誤!");elseJOptionPane.showMessageDialog(null, " 用戶不存在!"); catch (SQLException e2) / TODO 自動(dòng)生成的 catch 塊e2.printStackTrace();/財(cái)務(wù)登陸if (e.getSource()=logonButton3)sqll=sql.connect(); try rs=sqll.executeQuery("SELECT * FROM user_cw where name="+"'&qu
15、ot;+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.getStri
16、ng(1);frame.dispose(); elseJOptionPane.showMessageDialog(null, "輸入用戶名或密碼錯(cuò)誤!");elseJOptionPane.showMessageDialog(null, " 用戶不存在!"); catch (SQLException e2) / TODO 自動(dòng)生成的 catch 塊e2.printStackTrace();/ 退出if (cancelButton.equals(e.getSource() System.exit(0);/*數(shù)據(jù)庫(kù)鏈接*/import java.sql.*;/
17、數(shù)據(jù)庫(kù)聯(lián)接類(lèi)public class NetConn Connection con;Statement sql;public Statement connect()try /載入驅(qū)動(dòng)程序字符串 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); catch(ClassNotFoundException e1) try /通過(guò)JDBC URL得到Connetction對(duì)象 con=DriverManager.getConnection("jdbc:sqlserver:/localhost:14
18、33;DatabaseName=gzxt","sa","123456"); /通過(guò)Connection對(duì)象創(chuàng)建Statement對(duì)象 sql=con.createStatement(); catch(SQLException e2) return sql;/*系統(tǒng)管理員界面*/import java.awt.BorderLayout;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import jav
19、a.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;import javax.swing.JTable;i
20、mport javax.swing.JTextField;SuppressWarnings("serial")class xtgly extends JFrame implements ActionListenerJFrame frame = new JFrame("教職工信息查詢及密碼修改");Object a,b; Object colname="工號(hào)","姓名","密碼"NetConn sql;Statement sqll;ResultSet rs;JTable table,table2;
21、JButton Button1 = new JButton("添加教職工");JButton Button2 = new JButton("添加財(cái)務(wù)管理員");JButton Button3 = new JButton("修改密碼");JButton Button4 = new JButton("刷新");JTabbedPane tab = new JTabbedPane(JTabbedPane.TOP); int i=0;xtgly()frame.setLayout(null);sql=new NetConn()
22、;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);ai1=rs.getString(2);ai2=rs.getString(3);i+;i=0;String temp2="select * from user_teacher"rs=sqll.executeQuery(temp2);while(rs.ne
23、xt()bi0=rs.getString(1);bi1=rs.getString(2);bi2=rs.getString(3);i+; catch (SQLException e) / TODO 自動(dòng)生成的 catch 塊e.printStackTrace();table=new JTable(a,colname);table.setEnabled(false);table2=new JTable(b,colname);table2.setEnabled(false);JScrollPane JSP= new JScrollPane(table);JScrollPane JSP2= new J
24、ScrollPane(table2);tab.add(JSP,"財(cái)務(wù)管理員");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
25、);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);public void
26、 actionPerformed(ActionEvent e)/添加教職工if(e.getSource()=Button1)Add_teacher add1=new Add_teacher();/添加財(cái)務(wù)管理員if(e.getSource()=Button2)Add_cw add2=new Add_cw();/修改密碼if(e.getSource()=Button3)Change_mima change=new Change_mima();if(e.getSource()=Button4)i=0;try String temp="select * from user_cw"
27、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.executeQuery(temp2);while(rs.next()bi0=rs.getString(1);bi1=rs.getString(2);bi2=rs.getString(3);i+; catch (SQLException e1) / TODO 自動(dòng)
28、生成的 catch 塊e1.printStackTrace();table.removeAll();table2.removeAll();table=new JTable(a,colname);table.setEnabled(false);table2=new JTable(b,colname);table2.setEnabled(false);tab.updateUI();/*添加財(cái)務(wù)管理人員*/import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.ResultSet;i
29、mport 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;public class Add_cw implements ActionListenerJDialog user_cw=new JDialo
30、g();JLabel no,name,key,re_key;JTextField user_no,user_name;JPasswordField pass,aenter;JButton button1,button2;NetConn sql;Statement sqll;ResultSet rs;Add_cw()user_cw.setTitle("添加財(cái)務(wù)管理員");user_cw.setLayout(null);no=new JLabel(" 工 號(hào):");user_no=new JTextField("",10);user_no
31、.setBounds(115,5,120,20);no.setBounds(20,5,80,20);name=new JLabel(" 姓 名:");user_name=new JTextField("",10);user_name.setBounds(115,30,120,20);name.setBounds(20,30,80,20);key=new JLabel(" 密 碼:");pass=new JPasswordField("",10);pass.setEchoChar('*');pass.
32、setBounds(115,55,120,20);key.setBounds(20,55,80,20);re_key=new JLabel("確認(rèn)密碼:");aenter=new JPasswordField("",10);aenter.setEchoChar('*');aenter.setBounds(115,80,120,20);re_key.setBounds(20,80,80,20);button1=new JButton("確認(rèn)");button1.setBounds(50,110,80,20);button
33、1.addActionListener(this);button2=new JButton("取消");button2.setBounds(170,110,80,20);button2.addActionListener(this);user_cw.add(no);user_cw.add(name);user_cw.add(key);user_cw.add(re_key);user_cw.add(user_no);user_cw.add(user_name);user_cw.add(pass);user_cw.add(aenter);user_cw.add(button1)
34、;user_cw.add(button2);user_cw.setSize(300,180);user_cw.setModal(true);user_cw.setLocationRelativeTo(null);user_cw.setVisible(true);public void actionPerformed(ActionEvent e)if(e.getSource()=button1)String s=aenter.getText().trim();if(!(pass.getText().trim().equals(s)JOptionPane.showMessageDialog(nul
35、l, "兩次輸入的密碼不一致!");else if(pass.getText().trim().equals("")|user_no.getText().trim().equals("")|user_name.getText().trim().equals("")JOptionPane.showMessageDialog(null, "輸入的信息不全,請(qǐng)?zhí)顚?xiě)完整!");elsetry sql=new NetConn(); sqll=sql.connect();/根據(jù)用戶添加的用戶名進(jìn)行選擇rs=
36、sqll.executeQuery("SELECT * FROM user_cw where no="+"'"+user_no.getText()+"'");/如果已經(jīng)存在同名的用戶,則顯示錯(cuò)誤提示if(rs.next()JOptionPane.showMessageDialog(null,"用戶已經(jīng)存在,添加失敗!");/如果不存在用戶名,則將用戶新添加信息添加到數(shù)據(jù)庫(kù)中else/int s1=Integer.parseInt(user_no.getText().trim();String s1=
37、"'"+user_no.getText().trim()+"'"String s2="'"+user_name.getText().trim()+"'"String s3="'"+pass.getText().trim()+"'"String temp="INSERT INTO user_cw VALUES ("+s1+","+s2+","+s3+")&quo
38、t;sqll.executeUpdate(temp);JOptionPane.showMessageDialog(null,"用戶添加成功!"); catch (SQLException e1) e1.printStackTrace();if(e.getSource()=button2)user_cw.dispose();/*添加教職工用戶*/import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.ResultSet;import java.sql.SQLE
39、xception;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;public class Add_teacher implements ActionListenerJDialog user_teacher=new JDialog();JLabe
40、l no,name,key,re_key,yhk_num,zhiwu;JTextField user_no,user_name,user_yhk_num,user_zhiwu;JPasswordField pass,aenter;JButton button1,button2;NetConn sql;Statement sqll;ResultSet rs;Add_teacher()user_teacher.setTitle("添加教職工");user_teacher.setLayout(null);no=new JLabel(" 工 號(hào):");user_
41、no=new JTextField("",10);user_no.setBounds(115,5,120,20);no.setBounds(20,5,80,20);name=new JLabel(" 姓 名:");user_name=new JTextField("",10);user_name.setBounds(115,30,120,20);name.setBounds(20,30,80,20);key=new JLabel(" 密 碼:");pass=new JPasswordField("&quo
42、t;,10);pass.setEchoChar('*');pass.setBounds(115,55,120,20);key.setBounds(20,55,80,20);re_key=new JLabel("確認(rèn)密碼:");aenter=new JPasswordField("",10);aenter.setEchoChar('*');aenter.setBounds(115,80,120,20);re_key.setBounds(20,80,80,20);yhk_num=new JLabel("銀行卡號(hào):&q
43、uot;);user_yhk_num=new JTextField("",10);user_yhk_num.setBounds(115,105,120,20);yhk_num.setBounds(20,105,80,20);zhiwu=new JLabel(" 職 務(wù):");user_zhiwu=new JTextField("",10);user_zhiwu.setBounds(115,130,120,20);zhiwu.setBounds(20,130,80,20);button1=new JButton("確認(rèn)&quo
44、t;);button1.setBounds(50,160,80,20);button1.addActionListener(this);button2=new JButton("取消");button2.setBounds(170,160,80,20);button2.addActionListener(this);user_teacher.add(no);user_teacher.add(name);user_teacher.add(key);user_teacher.add(re_key);user_teacher.add(yhk_num);user_teacher.a
45、dd(zhiwu);user_teacher.add(user_no);user_teacher.add(user_name);user_teacher.add(pass);user_teacher.add(aenter);user_teacher.add(user_yhk_num);user_teacher.add(user_zhiwu);user_teacher.add(button1);user_teacher.add(button2);user_teacher.setSize(300,230);user_teacher.setModal(true);user_teacher.setLo
46、cationRelativeTo(null);user_teacher.setVisible(true);public void actionPerformed(ActionEvent e)if(e.getSource()=button1)String s=aenter.getText().trim();if(!(pass.getText().trim().equals(s)JOptionPane.showMessageDialog(null, "兩次輸入的密碼不一致!");else if(pass.getText().trim().equals("")
47、|user_no.getText().trim().equals("")|user_name.getText().trim().equals("")|user_yhk_num.getText().trim().equals("")|user_zhiwu.getText().trim().equals("")JOptionPane.showMessageDialog(null, "輸入的信息不全,請(qǐng)?zhí)顚?xiě)完整!");elsetry sql=new NetConn(); sqll=sql.connec
48、t();/根據(jù)用戶添加的用戶名進(jìn)行選擇rs=sqll.executeQuery("SELECT * FROM user_teacher where no="+"'"+user_no.getText()+"'");/如果已經(jīng)存在同名的用戶,則顯示錯(cuò)誤提示if(rs.next()JOptionPane.showMessageDialog(null,"用戶已經(jīng)存在,添加失敗!");/如果不存在用戶名,則將用戶新添加信息添加到數(shù)據(jù)庫(kù)中else/int s1=Integer.parseInt(user_no.
49、getText().trim();String s1="'"+user_no.getText().trim()+"'"String s2="'"+user_name.getText().trim()+"'"String s3="'"+pass.getText().trim()+"'"String s4="'"+user_yhk_num.getText().trim()+"'"
50、;String s5="'"+user_zhiwu.getText().trim()+"'"String temp="INSERT INTO user_teacher VALUES ("+s1+","+s2+","+s3+","+s4+","+s5+")"sqll.executeUpdate(temp);JOptionPane.showMessageDialog(null,"用戶添加成功!"); ca
51、tch (SQLException e1) e1.printStackTrace();if(e.getSource()=button2)user_teacher.dispose();/*通過(guò)管理員密碼修改*/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.swin
52、g.JDialog;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPasswordField;import javax.swing.JTextField;public class Change_mima implements ActionListenerJDialog change=new JDialog();JLabel no,name,key,re_key;JTextField user_no,user_name;JPasswordField pass,aenter;JButton
53、button1,button2;NetConn sql;Statement sqll;ResultSet rs,rs2;Change_mima()change.setTitle("添加財(cái)務(wù)管理員");change.setLayout(null);no=new JLabel(" 工 號(hào):");user_no=new JTextField("",10);user_no.setBounds(115,5,120,20);no.setBounds(20,5,80,20);name=new JLabel(" 姓 名:");user_name=new JTextField("",10);user_name.setBounds(115,30,120,20);name.setBounds(20,30,80,20);key=new JLabel(" 密 碼:");pass=new
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 藝術(shù)陶瓷設(shè)計(jì)考核試卷
- 光學(xué)印刷設(shè)備的智能化控制策略應(yīng)用考核試卷
- 溫濕度監(jiān)測(cè)技術(shù)考核試卷
- 多衛(wèi)星系統(tǒng)協(xié)同災(zāi)害監(jiān)測(cè)考核試卷
- 智能儀表在智能工廠生產(chǎn)自動(dòng)化中的應(yīng)用考核試卷
- 產(chǎn)品證明書(shū)范文
- 假期計(jì)劃書(shū)15篇
- 防盜安全教育
- 會(huì)計(jì)轉(zhuǎn)正工作總結(jié)范文
- 梁祝幼兒活動(dòng)方案
- 《批判性思維原理和方法》全套教學(xué)課件
- 《道德經(jīng)》的智慧啟示智慧樹(shù)知到期末考試答案章節(jié)答案2024年中國(guó)海洋大學(xué)
- 老公出軌保證書(shū)范文
- 【正版授權(quán)】 ISO 7887:1994 EN Water quality - Examination and determination of colour
- 獨(dú)家供應(yīng)商協(xié)議
- 學(xué)術(shù)交流英語(yǔ)(學(xué)術(shù)寫(xiě)作)智慧樹(shù)知到期末考試答案2024年
- 《建筑施工模板安全技術(shù)規(guī)范》JGJ162-2024解析
- 中年危機(jī)人生規(guī)劃
- 《光伏發(fā)電工程工程量清單計(jì)價(jià)規(guī)范》
- 港口企業(yè)財(cái)務(wù)風(fēng)險(xiǎn)分析報(bào)告
- 采購(gòu)協(xié)議與合作框架構(gòu)建
評(píng)論
0/150
提交評(píng)論