java教師工資管理系統(tǒng)完整代碼_第1頁(yè)
java教師工資管理系統(tǒng)完整代碼_第2頁(yè)
java教師工資管理系統(tǒng)完整代碼_第3頁(yè)
java教師工資管理系統(tǒng)完整代碼_第4頁(yè)
java教師工資管理系統(tǒng)完整代碼_第5頁(yè)
已閱讀5頁(yè),還剩52頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

教師工資管理系統(tǒng):開(kāi)發(fā)團(tuán)隊(duì):206和207時(shí)間:2012年4月8日數(shù)據(jù)庫(kù)配置:sqlserver2000創(chuàng)建數(shù)據(jù)庫(kù)SalaryManagement在其下創(chuàng)建數(shù)據(jù)表logindata、創(chuàng)建數(shù)據(jù)表Employee創(chuàng)建數(shù)據(jù)表January創(chuàng)建數(shù)據(jù)表February創(chuàng)建數(shù)據(jù)表March創(chuàng)建數(shù)據(jù)庫(kù)April創(chuàng)建數(shù)據(jù)表May創(chuàng)建數(shù)據(jù)表June創(chuàng)建數(shù)據(jù)表July創(chuàng)建數(shù)據(jù)表August創(chuàng)建數(shù)據(jù)表September創(chuàng)建數(shù)據(jù)表October創(chuàng)建數(shù)據(jù)表November創(chuàng)建數(shù)據(jù)表December開(kāi)發(fā)工具JDK1.6.21和eclipse,數(shù)據(jù)庫(kù)驅(qū)動(dòng)jdbc配置和導(dǎo)入省略。程序代碼如下importjava.awt.BorderLayout;importjava.awt.Dimension;importjava.awt.FlowLayout;importjava.awt.Font;importjava.awt.GridLayout;importjava.awt.Toolkit;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;importjavax.swing.ButtonGroup;importjavax.swing.JButton;importjavax.swing.JDialog;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPasswordField;importjavax.swing.JRadioButton;importjavax.swing.JTextField;publicclassLoginextendsJFrame{privateJLabellbTitle,lbUser,lbPwd;privateJButtonbtnLogon,btnOK,btnExit;privateBooleanlean=null;JTextFieldtfUser=newJTextField(15);JPasswordFieldtfPwd=newJPasswordField(15);JRadioButtonradiobutton1=newJRadioButton("教師登陸");JRadioButtonradiobutton2=newJRadioButton("管理登陸");ButtonGroupbuttongroup=newButtonGroup();Stringusername=tfUser.getText();Stringpassword=newString(tfPwd.getPassword());publicLogin(){ try{init();}catch(Exceptione3){ e3.printStackTrace(); }}publicvoidinit(){ this.setTitle("登陸界面");this.setBounds(450,300,400,300);JPanelp=newJPanel(newBorderLayout());p.setBounds(0,0,500,400);JPanelp1=newJPanel(newFlowLayout());JPanelp2=newJPanel(newGridLayout(2,1));JPanelp21=newJPanel(newFlowLayout());JPanelp22=newJPanel(newFlowLayout());JPanelp3=newJPanel(newFlowLayout());buttongroup.add(radiobutton1);buttongroup.add(radiobutton2);this.lbUser=newJLabel("用戶名:");this.lbPwd=newJLabel("密碼:");this.tfUser=newJTextField(15);this.tfPwd=newJPasswordField(15);this.tfPwd.setEchoChar('*');this.btnLogon=newJButton("注冊(cè)");this.btnOK=newJButton("登錄");this.btnExit=newJButton("退出");this.btnLogon.addActionListener(newActionMonitor());this.btnOK.addActionListener(newActionMonitor());this.btnExit.addActionListener(newActionMonitor());p1.add(radiobutton1);p1.add(radiobutton2);p21.add(this.lbUser);p21.add(this.tfUser);p22.add(this.lbPwd);p22.add(this.tfPwd);p3.add(btnLogon);p3.add(this.btnOK);p3.add(this.btnExit);p2.add(p21);p2.add(p22);p.add(p1,BorderLayout.NORTH);p.add(p2,BorderLayout.CENTER);p.add(p3,BorderLayout.SOUTH);p.setVisible(true);this.add(p);this.pack();this.setVisible(true);this.addWindowListener(newWindowMonitor());}classWindowMonitorextendsWindowAdapter{publicvoidwindowClosing(WindowEvente){setVisible(false);System.exit(0);}}classActionMonitorimplementsActionListener{publicvoidactionPerformed(ActionEvente){try{ if(e.getSource()==btnOK){ if(radiobutton2.isSelected()){ManageUseruser1=newManageUser();user1.setName(tfUser.getText());user1.setPassword(newString(tfPwd.getPassword()));ManageCheckar1=newManageCheck(user1); if(ar1.check()){ newManagementFrame().setVisible(true); }else{ JOptionPane.showMessageDialog(null,"賬號(hào)或密碼錯(cuò)誤","警告",JFrame.EXIT_ON_CLOSE);tfUser.setText("");tfPwd.setText(""); } }elseif(radiobutton1.isSelected()){Useruser=newUser();user.setUserName(tfUser.getText());user.setPassWord(newString(tfPwd.getPassword()));ActionCheckar=newActionCheck(user); if(ar.check()){ newTeacherFrame().setVisible(true); }else{ JOptionPane.showMessageDialog(null,"賬號(hào)或密碼錯(cuò)誤","警告",JFrame.EXIT_ON_CLOSE);tfUser.setText("");tfPwd.setText(""); } } }elseif(e.getSource()==btnExit){setVisible(false);System.exit(0);}elseif(e.getSource()==btnLogon){ newLogonFrame().setVisible(true);}}catch(Exceptione2){ e2.printStackTrace();}}}publicstaticvoidmain(String[]args){ Loginframe=newLogin(); DimensionscreenSize=Toolkit.getDefaultToolkit().getScreenSize(); DimensionframeSize=frame.getSize(); if(frameSize.height>screenSize.height) frameSize.height=screenSize.height; if(frameSize.width>screenSize.width) frameSize.width=screenSize.width; frame.setLocation((screenSize.width-frameSize.width)/2,(screenSize.height-frameSize.height)/2); frame.setVisible(true); }}importjava.awt.*;importjava.sql.*;importjavax.swing.*;importjava.awt.event.*;publicclassLogonFrameextendsJFrame{ Connectioncon; Statementst; JLabeljLabel1=newJLabel("職工工號(hào)"); JLabeljLabel2=newJLabel("登陸密碼"); JLabeljLabel3=newJLabel("職工姓別"); JLabeljLabel4=newJLabel("職工性名"); JLabeljLabel5=newJLabel("職工年齡"); JLabeljLabel6=newJLabel("所屬院系"); JLabeljLabel7=newJLabel("家庭住址"); JLabeljLabel8=newJLabel("聯(lián)系電話"); JTextFieldjTextField1=newJTextField(); JPasswordFieldjTextField2=newJPasswordField(); JTextFieldjTextField3=newJTextField(); JTextFieldjTextField4=newJTextField(); JTextFieldjTextField5=newJTextField(); JTextFieldjTextField6=newJTextField(); JTextFieldjTextField7=newJTextField(); JRadioButtonjRadioButton1=newJRadioButton("男"); JRadioButtonjRadioButton2=newJRadioButton("女"); ButtonGroupbuttonGroup1=newButtonGroup(); JButtonjButton1=newJButton("注冊(cè)"); JButtonjButton2=newJButton("取消"); publicLogonFrame() { try{ bInit(); } catch(Exceptionexception){ exception.printStackTrace(); } } privatevoidbInit()throwsException { con=DB.getConn(); st=con.createStatement(); this.setTitle("注冊(cè)界面"); this.setLayout(null); this.setSize(450,450); this.setLocationRelativeTo(null); jLabel1.setBounds(newRectangle(21,17,64,24)); jLabel2.setBounds(newRectangle(21,51,53,22)); jLabel3.setBounds(newRectangle(21,86,61,27)); jLabel4.setBounds(newRectangle(21,122,59,25)); jLabel5.setBounds(newRectangle(21,168,54,24)); jLabel6.setBounds(newRectangle(21,205,54,24)); jLabel7.setBounds(newRectangle(21,245,54,24)); jLabel8.setBounds(newRectangle(21,285,54,25)); jTextField1.setBounds(newRectangle(102,10,100,30)); jTextField2.setBounds(newRectangle(102,49,200,30)); jTextField3.setBounds(newRectangle(102,117,100,33)); jTextField4.setBounds(newRectangle(102,163,100,29)); jTextField5.setBounds(newRectangle(102,200,200,29)); jTextField6.setBounds(newRectangle(102,240,200,29)); jTextField7.setBounds(newRectangle(102,280,200,29)); jRadioButton1.setBounds(newRectangle(102,83,65,30)); jRadioButton2.setBounds(newRectangle(190,85,85,30)); jButton1.setBounds(newRectangle(130,320,60,32)); jButton2.setBounds(newRectangle(200,320,60,32)); jRadioButton1.setSelected(true); jButton1.addActionListener(newActionMonitor()); jButton2.addActionListener(newActionMonitor()); this.add(jLabel1); this.add(jTextField1); this.add(jLabel2); this.add(jTextField2); this.add(jLabel3); buttonGroup1.add(jRadioButton1); buttonGroup1.add(jRadioButton2); this.add(jRadioButton1); this.add(jRadioButton2); this.add(jLabel4); this.add(jTextField3); this.add(jLabel5); this.add(jTextField4); this.add(jLabel6); this.add(jTextField5); this.add(jLabel7); this.add(jTextField6); this.add(jLabel8); this.add(jTextField7); this.add(jButton1); this.add(jButton2); } classActionMonitorimplementsActionListener{ publicvoidactionPerformed(ActionEvente) { StringEmployeeID=jTextField1.getText(); StringEmployeePassword=newString(jTextField2.getPassword()); StringEmployeeSex=""; if(jRadioButton1.isSelected()) EmployeeSex+="男"; if(jRadioButton2.isSelected()) EmployeeSex+="女"; StringEmployeeName=jTextField3.getText(); StringEmployeeIge=jTextField4.getText(); StringEmployeeCollege=jTextField5.getText(); StringEmployeeAddress=jTextField6.getText(); StringEmployeeTell=jTextField7.getText(); try{ if(e.getSource()==jButton1){ if(EmployeeID.equals("")|EmployeePassword.equals("")|EmployeeName.equals("")|EmployeeIge.equals("")|EmployeeCollege.equals("")|EmployeeAddress.equals("")|EmployeeTell.equals("")){ JOptionPane.showMessageDialog(null,"內(nèi)容不允許為空","警告",JFrame.EXIT_ON_CLOSE); }else{ st.execute("setdateformatymd"); st.executeUpdate("insertintoEmployeevalues('"+EmployeeID+"','"+EmployeePassword+"','"+EmployeeName+"','"+EmployeeSex+"','"+EmployeeIge+"','"+EmployeeCollege+"','"+EmployeeAddress+"','"+EmployeeTell+"')"); JOptionPane.showMessageDialog(null,"職工添加成功!","提示",JFrame.EXIT_ON_CLOSE); jTextField1.setText(""); jTextField2.setText(""); jTextField3.setText(""); jTextField4.setText(""); jTextField5.setText(""); jTextField6.setText(""); } }elseif(e.getSource()==jButton2){ jTextField1.setText(""); jTextField2.setText(""); jTextField3.setText(""); jTextField4.setText(""); jTextField5.setText(""); jTextField6.setText(""); jTextField7.setText(""); } } catch(Exceptionex){ JOptionPane.showMessageDialog(null,"職工添加失敗!","提示",JFrame.EXIT_ON_CLOSE); ex.printStackTrace(); } } }}importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassManagementFrameextendsJFrameimplementsActionListener{ JPanelcontentPane; JLayeredPanecontentPane1; JMenuBarjMenuBar1=newJMenuBar(); JMenujMenu0=newJMenu("系統(tǒng)"); JMenuItemjMenuItem0=newJMenuItem("退出"); JMenuItemjMenuItem10=newJMenuItem("主界面"); JMenujMenu1=newJMenu("職工管理"); JMenuItemjMenuItem1=newJMenuItem("添加職工"); JMenuItemjMenuItem2=newJMenuItem("修改職工"); JMenuItemjMenuItem3=newJMenuItem("刪除職工"); JMenujMenu2=newJMenu("工資管理"); JMenuItemjMenuItem4=newJMenuItem("添加工資"); JMenuItemjMenuItem5=newJMenuItem("修改工資"); JMenuItemjMenuItem8=newJMenuItem("工資查詢"); JMenujMenu3=newJMenu("職工查詢"); JMenuItemjMenuItem6=newJMenuItem("按工號(hào)查詢"); JMenuItemjMenuItem7=newJMenuItem("按姓名查詢"); JMenujMenu4=newJMenu("幫助"); JMenuItemjMenuItem9=newJMenuItem("互動(dòng)"); publicManagementFrame() { try{ setDefaultCloseOperation(EXIT_ON_CLOSE); Init(); } catch(Exceptionexception){ exception.printStackTrace(); } } privatevoidInit()throwsException { setContentPane(newLayeredpane()); setSize(newLayeredpane().getWidth(),newLayeredpane().getHeight()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("教師工資管理小系統(tǒng)"); setLocationRelativeTo(null); jMenuItem0.addActionListener(this); jMenuItem1.addActionListener(this); jMenuItem2.addActionListener(this); jMenuItem3.addActionListener(this); jMenuItem4.addActionListener(this); jMenuItem5.addActionListener(this); jMenuItem6.addActionListener(this); jMenuItem7.addActionListener(this); jMenuItem8.addActionListener(this); jMenuItem9.addActionListener(this); jMenuItem10.addActionListener(this); setJMenuBar(jMenuBar1); jMenuBar1.add(jMenu0); jMenuBar1.add(jMenu1); jMenuBar1.add(jMenu2); jMenuBar1.add(jMenu3); jMenuBar1.add(jMenu4); jMenu0.add(jMenuItem10); jMenu0.add(jMenuItem0); jMenu1.add(jMenuItem1); jMenu1.add(jMenuItem2); jMenu1.add(jMenuItem3); jMenu2.add(jMenuItem4); jMenu2.add(jMenuItem5); jMenu2.add(jMenuItem8); jMenu3.add(jMenuItem6); jMenu3.add(jMenuItem7); jMenu4.add(jMenuItem9); } publicvoidactionPerformed(ActionEventactionEvent) { if(actionEvent.getSource()==jMenuItem0) { System.exit(0); } if(actionEvent.getSource()==jMenuItem1) { AddEmployeeaddemployee=newAddEmployee(); this.remove(this.getContentPane()); this.setContentPane(addemployee); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem2) { ModifyEmployeeModifyEmp=newModifyEmployee(); this.remove(this.getContentPane()); this.setContentPane(ModifyEmp); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem3) { DeleteEmployeeDeleteEmp=newDeleteEmployee(); this.remove(this.getContentPane()); this.setContentPane(DeleteEmp); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem4) { AddSalaryAddSal=newAddSalary(); this.remove(this.getContentPane()); this.setContentPane(AddSal); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem5) { ModifySalaryModifySal=newModifySalary(); this.remove(this.getContentPane()); this.setContentPane(ModifySal); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem8) { SalaryInquireSalaryInq=newSalaryInquire(); this.remove(this.getContentPane()); this.setContentPane(SalaryInq); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem6) { InquireOnGHOnGH=newInquireOnGH(); this.remove(this.getContentPane()); this.setContentPane(OnGH); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem7) { InquireOnNameOnName=newInquireOnName(); this.remove(this.getContentPane()); this.setContentPane(OnName); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem9) { EmployeeHelpEmployeeH=newEmployeeHelp(); this.remove(this.getContentPane()); this.setContentPane(EmployeeH); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem10){ Layeredpanelayeredpane=newLayeredpane(); this.remove(this.getContentPane()); this.setContentPane(layeredpane); this.setVisible(true); } }}importjava.awt.*;importjava.awt.event.*;importjava.beans.Statement;importjava.sql.Connection;importjavax.swing.*;publicclassTeacherFrameextendsJFrameimplementsActionListener{ Connectionconn; Statementstmt; JPanelcontentPane; JLayeredPanecontentPane1; JMenuBarjMenuBar1=newJMenuBar(); JMenujMenu0=newJMenu("系統(tǒng)"); JMenuItemjMenuItem0=newJMenuItem("退出"); JMenuItemjMenuItem1=newJMenuItem("主界面"); JMenujMenu1=newJMenu("工資管理"); JMenuItemjMenuItem2=newJMenuItem("工資查詢"); JMenujMenu2=newJMenu("職工查詢"); JMenuItemjMenuItem4=newJMenuItem("按工號(hào)查詢"); JMenuItemjMenuItem5=newJMenuItem("按姓名查詢"); JMenujMenu3=newJMenu("幫助"); JMenuItemjMenuItem6=newJMenuItem("互動(dòng)"); JMenujMenu4=newJMenu("密碼設(shè)置"); JMenuItemjMenuItem7=newJMenuItem("增加密碼"); JMenuItemjMenuItem8=newJMenuItem("修改密碼"); publicTeacherFrame() { try{ setDefaultCloseOperation(EXIT_ON_CLOSE); jbInit(); } catch(Exceptionexception){ exception.printStackTrace(); } } privatevoidjbInit()throwsException { setContentPane(newLayeredpane()); setSize(newLayeredpane().getWidth(),newLayeredpane().getHeight()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("教師工資管理小系統(tǒng)"); setLocationRelativeTo(null); jMenuItem0.addActionListener(this); jMenuItem1.addActionListener(this); jMenuItem2.addActionListener(this); jMenuItem4.addActionListener(this); jMenuItem5.addActionListener(this); jMenuItem6.addActionListener(this); setJMenuBar(jMenuBar1); jMenuBar1.add(jMenu0); jMenuBar1.add(jMenu1); jMenuBar1.add(jMenu2); jMenuBar1.add(jMenu4); jMenuBar1.add(jMenu3); jMenu0.add(jMenuItem1); jMenu0.add(jMenuItem0); jMenu1.add(jMenuItem2); jMenu2.add(jMenuItem4); jMenu2.add(jMenuItem5); jMenu3.add(jMenuItem6); jMenu4.add(jMenuItem7); jMenu4.add(jMenuItem8); } publicvoidactionPerformed(ActionEventactionEvent) { if(actionEvent.getSource()==jMenuItem0) { System.exit(0); } if(actionEvent.getSource()==jMenuItem1) { Layeredpanelayeredpane=newLayeredpane(); this.remove(this.getContentPane()); this.setContentPane(layeredpane); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem2) { SalaryInquireSalaryInq=newSalaryInquire(); this.remove(this.getContentPane()); this.setContentPane(SalaryInq); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem4) { InquireOnGHOnGH=newInquireOnGH(); this.remove(this.getContentPane()); this.setContentPane(OnGH); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem5) { InquireOnNameOnName=newInquireOnName(); this.remove(this.getContentPane()); this.setContentPane(OnName); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem6) { EmployeeHelpEmployeeH=newEmployeeHelp(); this.remove(this.getContentPane()); this.setContentPane(EmployeeH); this.setVisible(true); } if(actionEvent.getSource()==jMenuItem7) { } if(actionEvent.getSource()==jMenuItem8) { } }}importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;publicclassActionCheck{privateUseruser;ActionCheck(Useruser){this.user=user;}publicbooleancheck(){booleanisAdmin=false;Connectionconn=null;PreparedStatementpstmt=null;ResultSetrs=null;Stringsql="";try{conn=DB.getConn();sql="select*fromEmployeewhereemployeeid=?andpassword=?";pstmt=DB.getPstmt(conn,sql);pstmt.setString(1,user.getUserName());pstmt.setString(2,user.getPassWord());rs=DB.getRs(pstmt);if(rs.next()){isAdmin=true;}}catch(SQLExceptione){e.printStackTrace();}finally{DB.close(rs);DB.close(pstmt);DB.close(conn);}returnisAdmin;}publicUsergetUser(){returnuser;}publicvoidsetUser(Useruser){this.user=user;}}importjava.awt.*;importjava.sql.*;importjavax.swing.*;importjava.awt.event.*;publicclassAddEmployeeextendsJPanelimplementsActionListener{ Connectioncon; Statementst; JButtonjButton1=newJButton("確定"); JLabeljLabel1=newJLabel("職工工號(hào)"); JLabeljLabel2=newJLabel("職工姓名"); JLabeljLabel3=newJLabel("職工性別"); JLabeljLabel4=newJLabel("職工年齡"); JLabeljLabel5=newJLabel("所屬院系"); JLabeljLabel6=newJLabel("家庭住址"); JLabeljLabel7=newJLabel("聯(lián)系電話"); JTextFieldjTextField1=newJTextField(); JTextFieldjTextField2=newJTextField(); JTextFieldjTextField3=newJTextField(); JTextFieldjTextField4=newJTextField(); JTextFieldjTextField5=newJTextField(); JTextFieldjTextField6=newJTextField(); JRadioButtonjRadioButton1=newJRadioButton("男"); JRadioButtonjRadioButton2=newJRadioButton("女"); ButtonGroupbuttonGroup1=newButtonGroup(); publicAddEmployee() { try{ jbInit(); } catch(Exceptionexception){ exception.printStackTrace(); } } privatevoidjbInit()throwsException { con=DB.getConn(); st=con.createStatement(); this.setLayout(null); jLabel1.setBounds(newRectangle(21,17,64,24)); jLabel2.setBounds(newRectangle(21,51,53,22)); jLabel3.setBounds(newRectangle(21,86,61,27)); jLabel4.setBounds(newRectangle(21,122,59,25)); jLabel5.setBounds(newRectangle(21,168,54,24)); jLabel6.setBounds(newRectangle(21,205,54,24)); jLabel7.setBounds(newRectangle(21,245,54,24)); jTextField1.setBounds(newRectangle(102,10,200,30)); jTextField2.setBounds(newRectangle(102,49,200,30)); jTextField3.setBounds(newRectangle(102,117,80,33)); jTextField4.setBounds(newRectangle(102,163,200,29)); jTextField5.setBounds(newRectangle(102,200,200,29)); jTextField6.setBounds(newRectangle(102,240,200,29)); jRadioButton1.setBounds(newRectangle(102,83,65,30)); jRadioButton2.setBounds(newRectangle(190,85,85,30)); jButton1.setBounds(newRectangle(130,280,150,32)); jRadioButton1.setSelected(true); jButton1.addActionListener(this); this.add(jLabel1); this.add(jTextField1); this.add(jLabel2); this.add(jTextField2); this.add(jLabel3); buttonGroup1.add(jRadioButton1); buttonGroup1.add(jRadioButton2); this.add(jRadioButton1); this.add(jRadioButton2); this.add(jLabel4); this.add(jTextField3); this.add(jLabel5); this.add(jTextField4); this.add(jLabel6); this.add(jTextField5); this.add(jLabel7); this.add(jTextField6); this.add(jButton1); } publicvoidactionPerformed(ActionEvente){ StringEmployeeID=jTextField1.getText(); StringEmployeeName=jTextField2.getText(); StringEmployeeSex=""; if(jRadioButton1.isSelected()) EmployeeSex+="男"; if(jRadioButton2.isSelected()) EmployeeSex+="女"; StringEmployeeAge=jTextField3.getText(); StringEmployeeCollege=jTextField4.getText(); StringEmployeeAddress=jTextField5.getText(); StringEmployeePhone=jTextField6.getText(); try{ st.execute("setdateformatymd"); st.executeUpdate("insertintoEmployeevalues('"+EmployeeID+"','"+""+"','"+EmployeeName+"','"+EmployeeSex+"','"+EmployeeAge+"','"+EmployeeCollege+"','"+EmployeeAddress+"','"+EmployeePhone+"')"); JOptionPane.showMessageDialog(this,"職工添加成功!"); jTextField1.setText(""); jTextField2.setText(""); jTextField3.setText(""); jTextField4.setText(""); jTextField5.setText(""); jTextField6.setText(""); } catch(Exceptionex){ JOptionPane.showMessageDialog(this,"職工添加失敗!"); ex.printStackTrace(); } }}importjava.awt.*;importjava.sql.*;importjavax.swing.*;importjava.awt.event.*;publicclassAddSalaryextendsJPanelimplementsActionListener{ Connectioncon; Statementst; Stringmonth=null; JLabeljLabel1=newJLabel("職工工號(hào)"); JLabeljLabel2=newJLabel("職工工資"); JLabeljLabel3=newJLabel("增加月份"); JTextFieldjTextField1=newJTextField(); JTextFieldjTextField2=newJTextField(); JRadioButtonjradiobutton1=newJRadioButton("一"); JRadioButtonjradiobutton2=newJRadioButton("二"); JRadioButtonjradiobutton3=newJRadioButton("三"); JRadioButtonjradiobutton4=newJRadioButton("四"); JRadioButtonjradiobutton5=newJRadioButton("五"); JRadioButtonjradiobutton6=newJRadioButton("六"); JRadioButtonjradiobutton7=newJRadioButton("七"); JRadioButtonjradiobutton8=newJRadioButton("八"); JRadioButtonjradiobutton9=newJRadioButton("九"); JRadioButtonjradiobutton10=newJRadioButton("十"); JRadioButtonjradiobutton11=newJRadioButton("十一"); JRadioButtonjradiobutton12=newJRadioButton("十二"); JButtonjButton1=newJButton("添加工資"); ButtonGroupbuttongroup=newButtonGroup(); StringEmployeeID=jTextField1.getText();StringEmployeeSalary=jTextField2.getText(); publicAddSalary() { try{ jbInit(); } catch(Exceptionexception){ exception.printStackTrace(); } } privatevoidjbInit()throwsException { con=DB.getConn(); st=con.createStatement(); this.setLayout(null); buttongroup.add(jradiobutton1); buttongroup.add(jradiobutton2); buttongroup.add(jradiobutton3); buttongroup.add(jradiobutton4); buttongroup.add(jradiobutton5); buttongroup.add(jradiobutton6); buttongroup.add(jradiobutton7); buttongroup.add(jradiobutton8); buttongroup.add(jradiobutton9); buttongroup.add(jradiobutton10); buttongroup.add(jradiobutton11); buttongroup.add(jradiobutton12); jLabel1.setBounds(newRectangle(21,17,64,24)); jLabel2.setBounds(newRectangle(21,63,53,22)); jradiobutton1.setBounds(newRectangle(21,138,40,20)); jradiobutton2.setBounds(newRectangle(64,138,40,20)); jradiobutton3.setBounds(newRectangle(107,138,40,20)); jradiobutton4.setBounds(newRectangle(150,138,40,20)); jradiobutton5.setBounds(newRectangle(193,138,40,20)); jradiobutton6.setBounds(newRectangle(236,138,40,20)); jradiobutton7.setBounds(newRectangle(21,160,40,20)); jradiobutton8.setBounds(newRectangle(64,160,40,20)); jradiobutton9.setBounds(newRectangle(107,160,40,20)); jradiobutton10.setBounds(newRectangle(150,160,40,20)); jradiobutton11.setBounds(newRectangle(193,160,55,20)); jradiobutton12.setBounds(newRectangle(250,160,55,20)); jLabel3.setBounds(21,105,64,24); jTextField1.setBounds(newRectangle(102,10,120,30)); jTextField2.setBounds(newRectangle(102,60,120,30)); jButton1.setBounds(newRectangle(102,200,100,32)); jButton1.addActionListener(this); this.add(jradiobutton1); this.add(jradiobutton2); this.add(jradiobutton3); this.add(jradiobutton4); this.add(jradiobutton5); this.add(jradiobutton6); this.add(jradiobutton7); this.add(jradiobutton8); this.add(jradiobutton9); this.add(jradiobutton10); this.add(jradiobutton11); this.add(jradiobutton12); this.add(jLabel1); this.add(jTextField1); this.add(jLabel2); this.add(jTextField2); this.add(jLabel3); this.add(jButton1); } publicvoidactionPerformed(ActionEvente) { StringEmployeeID=jTextField1.getText();StringEmployeeSalary=jTextField2.getText(); if(EmployeeID.equals("")|EmployeeSalary.equals("")){ JOptionPane.showMessageDialog(this,"內(nèi)容不允許為空"); }else{ try{ if(jradiobutton1.isSelected()) month="insertintoJanuary(employeeid,January)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton2.isSelected()) month="insertintoFebruary(employeeid,February)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton3.isSelected()) month="insertintoMarch(employeeid,March)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton4.isSelected()) month="insertintoApril(employeeid,April)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton5.isSelected()) month="insertintoMay(employeeid,May)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton6.isSelected()) month="insertintoJune(employeeid,June)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton7.isSelected()) month="JulyinsertintoJuly(employeeid,July)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton8.isSelected()) month="AugustinsertintoAugust(employeeid,August)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton9.isSelected()) month="insertintoSeptember(employeeid,September)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton10.isSelected()) month="insertintoOctober(employeeid,October)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton11.isSelected()) month="insertintoNovember(employeeid,November)values('"+EmployeeID+"','"+EmployeeSalary+"')"; elseif(jradiobutton12.isSelected()) month="insertintoDecember(employeeid,December)values('"+EmployeeID+"','"+EmployeeSalary+"')"; st.executeUpdate(month); JOptionPane.showMessageDialog(this,"工資添加成功!"); jTextField1.setText(""); jTextField2.setText(""); } catch(Exceptionex){ JOptionPane.showMessageDialog(this,"工資添加失?。?); ex.printStackTrace(); } } }}importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;publicclassDB{publicstaticConnectiongetConn(){Connectionconn=nu

溫馨提示

  • 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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論