




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
4.2設(shè)計代碼Java源程序:importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.awt.*;importjava.sql.*;importjava.lang.*;importjava.util.*;importjavax.swing.table.*;importjava.math.*;classDB_LSimplementsActionListener{JFrameframe=newJFrame("歡迎進(jìn)入LS工資管理系統(tǒng)");JLabellabel=newJLabel("09網(wǎng)絡(luò)2_54_李月生",JLabel.CENTER);JButtonbutton1=newJButton("進(jìn)入系統(tǒng)");JButtonbutton2=newJButton("退出系統(tǒng)");ImageIconim=newImageIcon("1.jpg");JLabela1=newJLabel(im);voidCreate(){JPanelpcontentPane=(JPanel)frame.getContentPane();JPanelpcontentPane1=newJPanel();pcontentPane.add(label);pcontentPane.setLayout(newFlowLayout());pcontentPane.add(button1);pcontentPane.add(button2);pcontentPane.add(newLabel(" "));pcontentPane.add(a1);pcontentPane.setBackground(Color.green);pcontentPane.setVisible(true);button1.addActionListener(this);button2.addActionListener(this);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setBounds(200,100,550,600);frame.setVisible(true);}publicstaticvoidmain(String[]args){DB_LSdome=newDB_LS();dome.Create();}publicvoidactionPerformed(ActionEvente){if(button1.equals(e.getSource())){DLdl=newDL();dl.create();}if(button2.equals(e.getSource())){//退出System.exit(0);p.add(label2)p.add(label2);p.add(label2)p.add(label2);classDLimplementsActionListener{JFrameframe=newJFrame("職工/管理員登陸");JLabellabel1=newJLabel("用戶名");JLabellabel2=newJLabel("密碼");JButtonlogonButton1=newJButton("管理員登錄“);JButtonlogonButton2=newJButton("職工登錄");JButtoncancelButton=newJButton("退出");JTextFieldt1=newJTextField(0);JTextFieldt2=newJTextField(0);ImageIconim=newImageIcon("2.jpg");JLabela2=newJLabel(im);JTextFieldusername=newJTextField(9);JPasswordFieldpassword=newJPasswordField(9);voidcreate(){JPanelp=(JPanel)frame.getContentPane();JPanelp1=newJPanel();p.setLayout(newFlowLayout());p.add(label1);p.setSize(5,5);p.setLocation(4,8);p.add(username);p.setSize(100,200);p.setLocation(800,800);p.setSize(50,20);p.setLocation(40,80);p.add(password);p.setSize(100,20);p.setLocation(80,120);p.add(logonButton1);TOC\o"1-5"\h\zp.add(newJLabel(" "));p.add(logonButton2);p.add(newJLabel(" "));p.add(cancelButton);p.add(newJLabel(" "));p.add(a2);p.add(t1);p.add(t2);p.setBackground(Color.blue);p.setVisible(true);logonButton1.addActionListener(this);logonButton2.addActionListener(this);cancelButton.addActionListener(this);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setBounds(200,100,750,550);frame.setVisible(true);}publicvoidactionPerformed(ActionEvente){if(logonButton1.equals(e.getSource())&&(username.getText().equals("123")==true)&&(password.getText().equals("123")==true)){GZGLZJMgz=newGZGLZJM();gz.create();}else{JOptionPane.showMessageDialog(null,"對不起,你輸入的密碼錯誤!”);};if(logonButton2.equals(e.getSource())&&(username.getText().equals(t1.getText())==true)&&(password.getText().equals(t2.getText())==true)){XKxk=newXK();xk.create();Connectioncon;Statementsql;ResultSetrs;Vectorvector=newVector();try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundExceptione1){System.out.println(""+e1);}try{con=DriverManager.getConnection("jdbc:odbc:123","","");sql =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);sql.executeQuery("SELECTGno,mmFROMYWHEREGno="+t1.getText()+"ANDmm="+t2.getText());}catch(SQLExceptione1){System.out.println(e1);}}if(cancelButton.equals(e.getSource())){System.exit(0);}}}classGZGLZJMextendsJFrameimplementsActionListener{JFramef=newJFrame("工資管理系統(tǒng)");JButtonb1=newJButton("津貼管理");JButtonb2=newJButton("總查詢");JButtonb3=newJButton("工資管理");JButtonb4=newJButton("后勤管理");JButtonb6=newJButton("員工個人信息管理”);JButtonb5=newJButton("返回");ImageIconim=newImageIcon("3.jpg");JLabela3=newJLabel(im);voidcreate(){JPanelp=(JPanel)f.getContentPane();JPanelp1=newJPanel();p.setLayout(newFlowLayout());p.add(b1);TOC\o"1-5"\h\zp.add(newJLabel(" "));p.add(b6);p.add(newJLabel(" "));p.add(b3);p.add(newJLabel(" "));p.add(b4);p.add(newJLabel(" "));p.add(b2);p.add(newJLabel(" "));p.add(b5);p.add(a3);p.setBackground(Color.red);p.setVisible(true);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);b5.addActionListener(this);b6.addActionListener(this);f.setBounds(200,100,800,600);f.setVisible(true);}publicvoidactionPerformed(ActionEvente){if(b5.equals(e.getSource())){//返回DLd=newDL();f.dispose();}if(b1.equals(e.getSource())){//津貼管理JTGLjt=newJTGL();jt.create();}if(b6.equals(e.getSource())){//員工個人信息管理YGGLyg=newYGGL();yg.create();}if(b2.equals(e.getSource())){//查詢XKxk=newXK();xk.create();}if(b4.equals(e.getSource())){//后勤管理KQGLkq=newKQGL();kq.create();}if(b3.equals(e.getSource())){//工資管理GZGLgz=newGZGL();gz.create();}}}classKQGLimplementsActionListener{JFramef=newJFrame("錄入修改刪除考勤信息");JButtonb1=newJButton("錄入");JButtonb2=newJButton("修改");JButtonb3=newJButton("冊^除");JButtonb4=newJButton("查詢所有");JButtonb5=newJButton("返回");JTextFieldtf1=newJTextField(4);JTextFieldtf2=newJTextField(4);JTextFieldtf3=newJTextField(4);JTextFieldtf4=newJTextField(4);JTextFieldtf5=newJTextField(6);JButtonb6=newJButton("查詢單人考勤”);String口cloum={"職工號","缺勤天數(shù)","缺勤類別","缺勤時間"};Object[][]row=newObject[50][4];JTabletable=newJTable(row,cloum);JScrollPanescrollpane=newJScrollPane(table);JSplitPanesplitpane=newJSplitPane(JSplitPane.VERTICAL_SPLIT);voidcreate(){JPanelp=(JPanel)f.getContentPane();p.setLayout(newFlowLayout());//p.add(scrollpane);p.add(splitpane);JPanelp1=newJPanel();p1.add(b1);p1.add(b2);p1.add(b3);p1.add(b4);p1.add(b6);p1.add(b5);JPanelp2=newJPanel();p2.setBackground(Color.red);p2.add(scrollpane);JPanelp3=newJPanel();p.setLayout(newFlowLayout());p.add(newJLabel(""));p.add(newJLabel("職工號"));p.add(tf1);p.add(newJLabel("缺勤天數(shù)"));p.add(tf2);p.add(newJLabel("缺勤類別"));p.add(tf3);p.add(newJLabel(""));p.add(newJLabel("缺勤時間"));p.add(tf4);p.add(newJLabel(" 在此處輸入職工號點(diǎn)擊查詢刪除"));p.add(tf5);splitpane.add(p1,splitpane.TOP);}}catch(ClassNotFoundExceptione1){}}catch(ClassNotFoundExceptione1){splitpane.add(p2,splitpane.BOTTOM);splitpane.setDividerLocation(50);p.setBackground(Color.CYAN);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);b5.addActionListener(this);b6.addActionListener(this);f.setBounds(200,100,500,600);f.setResizable(true);//可以調(diào)整界面大小f.setVisible(true);}publicvoidactionPerformed(ActionEvente){if(b1.equals(e.getSource())){//添加Connectioncon;Statementsql;ResultSetrs;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");System.out.println(""+e1);}try{con=DriverManager.getConnection("jdbc:odbc:123","","");sql=con.createStatement();StringinsertStr="INSERTINTOKVALUES"+"("+"'"+tf1.getText()+"'"+,"+tf2.getText()+","+"'"+tf3.getText()+"'"+","+tf4.getText()+")";sql.executeUpdate(insertStr);con.close();}catch(SQLExceptione1){System.out.println(e1);}}if(b2.equals(e.getSource())){//修改Connectioncon;Statementsql;ResultSetrs;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundExceptione1){System.out.println(""+e1);}try{con=DriverManager.getConnection("jdbc:odbc:123","","");sql=con.createStatement();sql.executeUpdate("UPDATE KSET ts="+tf2.getText()+"WHEREKno="+tf1.getText()+"");}}catch(SQLExceptione1){}}catch(SQLExceptione1){sql.executeUpdate("UPDATESETlb="+tf3.getText()+"WHEREsql.executeUpdate("UPDATESETlb="+tf3.getText()+"WHEREKno="+tf1.getText()+"");sql.executeUpdate("UPDATEKSET sj="+tf4.getText()+"WHEREKno="+tf1.getText()+"");con.close();}catch(SQLExceptione1){System.out.println(e1);}}if(b3.equals(e.getSource())){//刪除Connectioncon;Statementsql;ResultSetrs;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundExceptione1){System.out.println(""+e1);}try{con=DriverManager.getConnection("jdbc:odbc:123","","");sql =con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);sql.executeUpdate("DELETEFROMKWHEREKno="+tf5.getText());con.close();System.out.println(e1);}System.out.println(e1);}System.out.println(e1);}System.out.println(e1);}}if(b4.equals(e.getSource())){//查詢?nèi)緾onnectioncon;Statementsql;ResultSetrs;Vectorvector=newVector();try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundExceptione1){System.out.println(""+e1);}try{con=DriverManager.getConnection("jdbc:odbc:123","sa","");sqlcon.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);if(b4.equals(e.getSource())){for(inti=0;i<50;i++)for(intj=0;j<4;j++)table.setValueAt("",i,j);rs=sql.executeQuery("SELECT*FROMKORDERBYKnoDESC");intk=-1;while(rs.next()){}}catch(ClassNotFoundExceptione1){}}catch(ClassNotFoundExceptione1){++k;StringKno=rs.getString(1);Stringts=rs.getString(2);Stringlb=rs.getString(3);Stringsj=rs.getString(4);table.setValueAt(Kno,k,0);table.setValueAt(ts,k,1);
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 山東工商學(xué)院《服務(wù)禮儀理論教學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- 貴州水利水電職業(yè)技術(shù)學(xué)院《中醫(yī)護(hù)理技術(shù)》2023-2024學(xué)年第二學(xué)期期末試卷
- 重慶五一職業(yè)技術(shù)學(xué)院《交通運(yùn)輸安全2》2023-2024學(xué)年第二學(xué)期期末試卷
- 上海中僑職業(yè)技術(shù)大學(xué)《建筑營造》2023-2024學(xué)年第二學(xué)期期末試卷
- 重慶建筑工程職業(yè)學(xué)院《跨媒介創(chuàng)意2》2023-2024學(xué)年第二學(xué)期期末試卷
- 北京工商大學(xué)嘉華學(xué)院《管理學(xué)原理B1》2023-2024學(xué)年第二學(xué)期期末試卷
- 新疆現(xiàn)代職業(yè)技術(shù)學(xué)院《教育學(xué)研究新進(jìn)展》2023-2024學(xué)年第二學(xué)期期末試卷
- 大連海洋大學(xué)《插畫基礎(chǔ)》2023-2024學(xué)年第二學(xué)期期末試卷
- 上海工商職業(yè)技術(shù)學(xué)院《陶瓷產(chǎn)品設(shè)計》2023-2024學(xué)年第二學(xué)期期末試卷
- 湖南交通工程學(xué)院《數(shù)字電路與數(shù)字邏輯》2023-2024學(xué)年第二學(xué)期期末試卷
- 職場C位指南-大學(xué)生職業(yè)素養(yǎng)養(yǎng)成智慧樹知到期末考試答案章節(jié)答案2024年云南林業(yè)職業(yè)技術(shù)學(xué)院
- 2.6高壓電力電容器運(yùn)行與維護(hù)
- 美學(xué)與人生智慧樹知到期末考試答案2024年
- GB/T 3953-2024電工圓銅線
- 碘缺乏病知識宣傳課件
- 曙光醫(yī)院網(wǎng)上查報告
- (附加條款版)醫(yī)院勞務(wù)合同書
- GA/T 1093-2023安全防范人臉識別應(yīng)用出入口控制人臉識別技術(shù)要求
- 港口危貨作業(yè)單位主要安全管理人員試題及答案(536道)
- 2024年監(jiān)理工程師考試《三控》真題與答案
- 2024年天津市初中地理學(xué)業(yè)考查試卷
評論
0/150
提交評論