




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、工資系統(tǒng)代碼/*系統(tǒng)歡迎界面*/importjava.awt.FlowLayout;importjava.awt.event.*;importjavax.swing.*;SuppressWarnings(serial)classWagesSystemextendsJFrameimplementsActionListenerJFrameframe=newJFrame(歡迎進(jìn)入工資管理系統(tǒng));JButtonbuttonl=newJButton(進(jìn)入系統(tǒng));JButtonbutton2=newJButton(退出系統(tǒng));ImageIconim=newImageIcon(1.jpg);JLabela1
2、=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.setDefaultC
3、loseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setLocationRelativeTo(null);frame.setVisible(true);publicstaticvoidmain(Stringargs)WagesSystemdome=newWagesSystem();dome.Create();publicvoidactionPerformed(ActionEvente)if(button1.equals(e.getSource()DLdl=newDL();dl.create();frame.dispose();if(b
4、utton2.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.swi
5、ng.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPasswordField;importjavax.swing.JTextField;.*;importjava.sql.*;SuppressWarnings(serial)classDLextendsJFrameimplementsActionListenerNetConnsql;Statementsqll;ResultSetrs;JFrameframe=newJFrame(
6、職工/管理員登陸);JLabe11abe11=newJLabel(用戶名);JLabe11abe12=newJLabe1(密碼);JButtonlogonButtonl=newJButton(系統(tǒng)管理員登錄);JButton1ogonButton2=newJButton(教職工登錄);JButton1ogonButton3=newJButton(財(cái)務(wù)管理員登錄);JButtoncancelButton=newJButton(退出);JTextFie1dusername=newJTextFie1d(9);JPasswordFie1dpassword=newJPasswordFie1d(9);st
7、aticStringt1;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,
8、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);logonButt
9、on3.addActionListener(this);cancelButton.addActionListener(this);sql=newNetConn();/建立數(shù)據(jù)庫(kù)連接frame.setSize(350,250);frame.setLocationRelativeTo(null);frame.setVisible(true);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);SuppressWarnings(deprecation)publicvoidactionPerformed(ActionEvente)t1=userna
10、me.getText();t2=password.getText();/系統(tǒng)管理員登錄if(e.getSource()=logonButton1)if(username.getText().equals(admin)=true&(password.getText().equals(admin)=true)登錄成功!);登錄成功!);frame.dispose();elseJOptionPane.showMessageDialog(null,輸入用戶名或密碼錯(cuò)誤!);/教職工登陸if(e.getSource()=logonButton2)sqll=sql.connect();tryrs=sqll
11、.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.crea
12、t(rs.getString(1);frame.dispose();elseJOptionPane.showMessageDialog(null,輸入用戶名或密碼錯(cuò)誤!);elseJOptionPane.showMessageDialog(null,用戶不存在!);catch(SQLExceptione2)/TODO自動(dòng)生成的catch塊e2.printStackTrace();/財(cái)務(wù)登陸if(e.getSource()=logonButton3)sqll=sql.connect();tryrs=sqll.executeQuery(SELECT*FROMuser_cwwherename=+us
13、ername.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();elseJOptionPane.showMessageDi
14、alog(null,輸入用戶名或密碼錯(cuò)誤!);elseJOptionPane.showMessageDialog(null,用戶不存在!);catch(SQLExceptione2)/TODO自動(dòng)生成的catch塊e2.printStackTrace();/退出if(cancelButton.equals(e.getSource()System.exit(0);/*數(shù)據(jù)庫(kù)鏈接*/importjava.sql.*;/數(shù)據(jù)庫(kù)聯(lián)接類publicclassNetConnConnectioncon;Statementsql;publicStatementconnect()try/載入驅(qū)動(dòng)程序字符串Cla
15、ss.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);catch(ClassNotFoundExceptione1)try通過JDBCURL得到Connetction對(duì)象con=DriverManager.getConnection(jdbc:sqlserver:/localhost:1433;DatabaseName=gzxt,sa,123456);/通過Connection對(duì)象創(chuàng)建Statement對(duì)象sql=con.createStatement();catch(SQLExceptione2)returnsql;/*系統(tǒng)管理員界
16、面*/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.JL
17、abel;importjavax.swing.JPasswordField;importjavax.swing.JScrollPane;importjavax.swing.JTabbedPane;importjavax.swing.JTable;importjavax.swing.JTextField;SuppressWarnings(serial)classxtglyextendsJFrameimplementsActionListenerJFrameframe=newJFrame(教職工信息查詢及密碼修改);Objecta,b;Objectcolname=工號(hào),姓名,密碼;NetConns
18、ql;Statementsqll;ResultSetrs;JTabletable,table2;JButtonButtonl=newJButton(添加教職工);JButtonButton2=newJButton(添力口財(cái)務(wù)管理員”);JButtonButton3=newJButton(修改密碼);JButtonButton4=newJButton(刷新);JTabbedPanetab=newJTabbedPane(JTabbedPane.TOP);inti=0;xtgly()frame.setLayout(null);sql=newNetConn();sqll=sql.connect();a
19、=newObject303;b=newObject303;tryStringtemp=select*fromuser_cw;rs=sqll.executeQuery(temp);while(rs.next()ai0=rs.getString(1);ai1=rs.getString(2);ai2=rs.getString(3);i+;i=0;Stringtemp2=select*fromuser_teacher;rs=sqll.executeQuery(temp2);while(rs.next()bi0=rs.getString(1);bi1=rs.getString(2);bi2=rs.get
20、String(3);i+;catch(SQLExceptione)/TODO自動(dòng)生成的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,財(cái)務(wù)管理員);tab.add(JSP2,教職工);tab.setBounds(
21、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(
22、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();/添
23、加財(cái)務(wù)管理員if(e.getSource()=Button2)Add_cwadd2=newAdd_cw();/修改密碼if(e.getSource()=Button3)Change_mimachange=newChange_mima();if(e.getSource()=Button4)i=0;tryStringtemp=select*fromuser_cw;rs=sqll.executeQuery(temp);while(rs.next()ai0=rs.getString(1);ai1=rs.getString(2);ai2=rs.getString(3);i+;i=0;Stringtemp
24、2=select*fromuser_teacher;rs=sqll.executeQuery(temp2);while(rs.next()bi0=rs.getString(1);bi1=rs.getString(2);bi2=rs.getString(3);i+;catch(SQLExceptione1)/TODO自動(dòng)生成的catch塊e1.printStackTrace();table.removeAll();table2.removeAll();table=newJTable(a,colname);table.setEnabled(false);table2=newJTable(b,col
25、name);table2.setEnabled(false);tab.updateUI();/*添加財(cái)務(wù)管理人員*/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.
26、JOptionPane;importjavax.swing.JPasswordField;importjavax.swing.JTextField;publicclassAdd_cwimplementsActionListenerJDialoguser_cw=newJDialog();JLabelno,name,key,re_key;JTextFielduser_no,user_name;JPasswordFieldpass,aenter;JButtonbutton1,button2;NetConnsql;Statementsqll;ResultSetrs;Add_cw()user_cw.se
27、tTitle(添加財(cái)務(wù)管理員);user_cw.setLayout(null);no=newJLabel(工號(hào):);user_no=newJTextField(,10);user_no.setBounds(115,5,120,20);no.setBounds(20,5,80,20);name=newJLabel(姓名:);user_name=newJTextField(,10);user_name.setBounds(115,30,120,20);name.setBounds(20,30,80,20);key=newJLabel(密碼:);pass=newJPasswordField(,10)
28、;pass.setEchoChar(*);pass.setBounds(115,55,120,20);key.setBounds(20,55,80,20);re_key=newJLabel(確認(rèn)密碼:);aenter=newJPasswordField(,10);aenter.setEchoChar(*);aenter.setBounds(115,80,120,20);re_key.setBounds(20,80,80,20);button1=newJButton(確認(rèn));button1.setBounds(50,110,80,20);button1.addActionListener(thi
29、s);button2=newJButton(取消);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);user_cw.add(button2);user_cw.setSiz
30、e(300,180);user_cw.setModal(true);user_cw.setLocationRelativeTo(null);user_cw.setVisible(true);publicvoidactionPerformed(ActionEvente)if(e.getSource()=button1)Strings=aenter.getText().trim();if(!(pass.getText().trim().equals(s)JOptionPane.showMessageDialog(null,兩次輸入的密碼不一致!);elseif(pass.getText().tri
31、m().equals()|user_no.getText().trim().equals()|user_name.getText().trim().equals()JOptionPane.showMessageDialog(null,輸入的信息不全,請(qǐng)?zhí)顚懲暾?;elsetrysql=newNetConn();sqll=sql.connect();/根據(jù)用戶添加的用戶名進(jìn)行選擇rs=sqll.executeQuery(SELECT*FROMuser_cwwhereno=+user_no.getText()+);/如果已經(jīng)存在同名的用戶,則顯示錯(cuò)誤提示if(rs.next()JOptionPa
32、ne.showMessageDialog(null,”用戶已經(jīng)存在,添加失敗!);/如果不存在用戶名,則將用戶新添加信息添加到數(shù)據(jù)庫(kù)中else/ints1=Integer.parseInt(user_no.getText().trim();Strings1=+user_no.getText().trim()+;Strings2=+user_name.getText().trim()+;Strings3=+pass.getText().trim()+;Stringtemp=INSERTINTOuser_cwVALUES(+s1+,+s2+,+s3+);sqll.executeUpdate(tem
33、p);JOptionPane.showMessageDialog(null,”用戶添加成功!”);catch(SQLExceptione1)e1.printStackTrace();if(e.getSource()=button2)user_cw.dispose();/*添加教職工用戶*/importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importja
34、vax.swing.JButton;importjavax.swing.JDialog;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPasswordField;importjavax.swing.JTextField;publicclassAdd_teacherimplementsActionListenerJDialoguser_teacher=newJDialog();JLabelno,name,key,re_key,yhk_num,zhiwu;JTextFielduser_no,use
35、r_name,user_yhk_num,user_zhiwu;JPasswordFieldpass,aenter;JButtonbutton1,button2;NetConnsql;Statementsqll;ResultSetrs;Add_teacher()user_teacher.setTitle(添加教職工);user_teacher.setLayout(null);no=newJLabel(工號(hào):);user_no=newJTextField(,10);user_no.setBounds(115,5,120,20);no.setBounds(20,5,80,20);name=newJL
36、abel(姓名:);user_name=newJTextField(,10);user_name.setBounds(115,30,120,20);name.setBounds(20,30,80,20);key=newJLabel(密碼:);pass=newJPasswordField(,10);pass.setEchoChar(*);pass.setBounds(115,55,120,20);key.setBounds(20,55,80,20);re_key=newJLabel(確認(rèn)密碼:);aenter=newJPasswordField(,10);aenter.setEchoChar(*
37、);aenter.setBounds(115,80,120,20);re_key.setBounds(20,80,80,20);yhk_num=newJLabel(銀行卡號(hào):);user_yhk_num=newJTextField(,10);user_yhk_num.setBounds(115,105,120,20);yhk_num.setBounds(20,105,80,20);zhiwu=newJLabel(職務(wù):);user_zhiwu=newJTextField(,10);user_zhiwu.setBounds(115,130,120,20);zhiwu.setBounds(20,1
38、30,80,20);button1=newJButton(確認(rèn));button1.setBounds(50,160,80,20);button1.addActionListener(this);button2=newJButton(取消);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
39、);user_teacher.add(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.setLocationRelativeTo(null);user_teacher.setVisible(true);publicvoidactionPerformed(ActionEvente)if(e.getSource()=button1)Strings=aenter.getText().trim();if(!(pass.getText().trim().equals(s)JOptionPane.showMessageDialog(null,兩次輸入的密碼不一致!);elseif(pass.getText().trim().equals(
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 河南省許平汝名校2025屆高三下學(xué)期二模試題 政治 含解析
- 商品鴿棚轉(zhuǎn)讓合同協(xié)議
- 快遞合作協(xié)議合同書
- 2025商業(yè)購(gòu)房合同模板
- 2025年無固定期限勞動(dòng)合同與范本
- 2025標(biāo)準(zhǔn)供貨合同協(xié)議書
- 2025大理石材供貨合同范本
- 2025年人民幣典當(dāng)借款合同
- 咨詢酒水合同協(xié)議
- 品牌經(jīng)營(yíng)權(quán)轉(zhuǎn)讓合同協(xié)議
- 《BACnet基礎(chǔ)教程》課件
- 環(huán)境污染舉報(bào)信范文
- 《基于PLC的包裝機(jī)控制系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)》10000字(論文)
- 電力工程勘測(cè)的基本知識(shí)
- 2025年成都地鐵運(yùn)營(yíng)有限公司招聘筆試參考題庫(kù)含答案解析
- 《藝術(shù)作品欣賞》課件
- 體育賽事版權(quán)保護(hù)與監(jiān)管-洞察分析
- 自動(dòng)分類垃圾桶創(chuàng)新
- 2025年南京證券招聘筆試參考題庫(kù)含答案解析
- 02S515排水檢查井-標(biāo)準(zhǔn)圖集
- (2024年高考真題)2024年普通高等學(xué)校招生全國(guó)統(tǒng)一考試數(shù)學(xué)試卷-新課標(biāo)Ⅰ卷(含部分解析)
評(píng)論
0/150
提交評(píng)論