版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、工資系統(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 button2
2、 = 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); pcont
3、entPane.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(); dome.Cr
4、eate(); 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;import
5、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.JTextF
6、ield;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("密 碼");JButt
7、on 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(9);
8、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(100
9、,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);l
10、ogonButton3.addActionListener(this);cancelButton.addActionListener(this);sql=new NetConn();/建立數(shù)據(jù)庫連接frame.setSize(350,250);frame.setLocationRelativeTo(null);frame.setVisible(true);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);SuppressWarnings("deprecation")public void actionPerformed
11、(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();fr
12、ame.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.next()
13、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(nul
14、l, "輸入用戶名或密碼錯(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="+"'"+
15、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
16、);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ù)庫鏈接*/import java.sql.*;/數(shù)據(jù)庫聯(lián)
17、接類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 /通過JDBC URL得到Connetction對象 con=DriverManager.getConnection("jdbc:sqlserver:/localhost:1433;D
18、atabaseName=gzxt","sa","123456"); /通過Connection對象創(chuàng)建Statement對象 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 java.sq
19、l.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;impor
20、t 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;JBut
21、ton 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();sql
22、l=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.next()
23、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 JScro
24、llPane(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);Bu
25、tton4.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 act
26、ionPerformed(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"rs=s
27、qll.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;impor
29、t 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 JDialog();
30、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.set
31、Bounds(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.setB
32、ounds(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);button1.ad
33、dActionListener(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);use
34、r_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(null, &
35、quot;兩次輸入的密碼不一致!");else if(pass.getText().trim().equals("")|user_no.getText().trim().equals("")|user_name.getText().trim().equals("")JOptionPane.showMessageDialog(null, "輸入的信息不全,請?zhí)顚懲暾?quot;);elsetry sql=new NetConn(); sqll=sql.connect();/根據(jù)用戶添加的用戶名進(jìn)行選擇rs=sqll
36、.executeQuery("SELECT * FROM user_cw where no="+"'"+user_no.getText()+"'");/如果已經(jīng)存在同名的用戶,則顯示錯(cuò)誤提示if(rs.next()JOptionPane.showMessageDialog(null,"用戶已經(jīng)存在,添加失敗!");/如果不存在用戶名,則將用戶新添加信息添加到數(shù)據(jù)庫中else/int s1=Integer.parseInt(user_no.getText().trim();String s1=&quo
37、t;'"+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+")"sq
38、ll.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.SQLExcep
39、tion;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();JLabel no
40、,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_no=n
41、ew 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("",1
42、0);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):"
43、);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)");
44、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.add(z
45、hiwu);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.setLocati
46、onRelativeTo(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("")|use
47、r_no.getText().trim().equals("")|user_name.getText().trim().equals("")|user_yhk_num.getText().trim().equals("")|user_zhiwu.getText().trim().equals("")JOptionPane.showMessageDialog(null, "輸入的信息不全,請?zhí)顚懲暾?quot;);elsetry sql=new NetConn(); sqll=sql.connect();
48、/根據(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ù)庫中else/int s1=Integer.parseInt(user_no.getT
49、ext().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()+"'"Str
50、ing s5="'"+user_zhiwu.getText().trim()+"'"String temp="INSERT INTO user_teacher VALUES ("+s1+","+s2+","+s3+","+s4+","+s5+")"sqll.executeUpdate(temp);JOptionPane.showMessageDialog(null,"用戶添加成功!"); catch
51、(SQLException e1) e1.printStackTrace();if(e.getSource()=button2)user_teacher.dispose();/*通過管理員密碼修改*/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.JD
52、ialog;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 butt
53、on1,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 JPass
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 七年級(jí)道德與法治上冊第三單元師長情誼第六課師生之間第1框走近老師教案新人教版
- 三年級(jí)科學(xué)上冊第三單元天氣與我們的生活第十四課我的雨量器教案青島版
- 小學(xué)生家校溝通制度
- 《吃蟲草》課件(3篇)
- 《行行重行行完整》課件
- 三年級(jí)閱讀課教學(xué)參考計(jì)劃范文5篇
- 破釜沉舟成語故事課件全
- 2021年衛(wèi)生法簡答題
- 風(fēng)險(xiǎn)合規(guī)管理培訓(xùn)課件
- 2021年全國應(yīng)急普法知識(shí)考試題庫(全真題庫)
- 某酒店散客預(yù)訂單
- 2021年深圳亞迪學(xué)校小升初面試數(shù)學(xué)模擬題及答案
- 抽沙船施工方案
- 內(nèi)蒙古蘇尼特右旗銅鉛鋅礦選礦試驗(yàn)報(bào)告
- 諾如病毒檢測技術(shù)培訓(xùn)
- 自考05627職業(yè)輔導(dǎo)個(gè)人筆記
- 成人高等教育行業(yè)營銷方案
- 活動(dòng)義齒(設(shè)計(jì))課件
- 主題班會(huì)《我愛爸爸媽媽》
- 部編版六年級(jí)語文上冊《認(rèn)識(shí)分號(hào)》教學(xué)課件
- 新中小企業(yè)促進(jìn)法宣講暨十條的措施解讀課件
評論
0/150
提交評論