java教师工资管理系统完整代码_第1页
java教师工资管理系统完整代码_第2页
java教师工资管理系统完整代码_第3页
java教师工资管理系统完整代码_第4页
java教师工资管理系统完整代码_第5页
已阅读5页,还剩52页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

教师工资管理系统:开发团队:206和207时间:2012年4月8日数据库配置:sqlserver2000创建数据库SalaryManagement在其下创建数据表logindata、创建数据表Employee创建数据表January创建数据表February创建数据表March创建数据库April创建数据表May创建数据表June创建数据表July创建数据表August创建数据表September创建数据表October创建数据表November创建数据表December开发工具JDK1.6.21和eclipse,数据库驱动jdbc配置和导入省略。程序代码如下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("注册");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,"账号或密码错误","警告",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,"账号或密码错误","警告",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("职工工号"); JLabeljLabel2=newJLabel("登陆密码"); JLabeljLabel3=newJLabel("职工姓别"); JLabeljLabel4=newJLabel("职工性名"); JLabeljLabel5=newJLabel("职工年龄"); JLabeljLabel6=newJLabel("所属院系"); JLabeljLabel7=newJLabel("家庭住址"); JLabeljLabel8=newJLabel("联系电话"); JTextFieldjTextField1=newJTextField(); JPasswordFieldjTextField2=newJPasswordField(); JTextFieldjTextField3=newJTextField(); JTextFieldjTextField4=newJTextField(); JTextFieldjTextField5=newJTextField(); JTextFieldjTextField6=newJTextField(); JTextFieldjTextField7=newJTextField(); JRadioButtonjRadioButton1=newJRadioButton("男"); JRadioButtonjRadioButton2=newJRadioButton("女"); ButtonGroupbuttonGroup1=newButtonGroup(); JButtonjButton1=newJButton("注册"); JButtonjButton2=newJButton("取消"); publicLogonFrame() { try{ bInit(); } catch(Exceptionexception){ exception.printStackTrace(); } } privatevoidbInit()throwsException { con=DB.getConn(); st=con.createStatement(); this.setTitle("注册界面"); 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,"内容不允许为空","警告",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("系统"); JMenuItemjMenuItem0=newJMenuItem("退出"); JMenuItemjMenuItem10=newJMenuItem("主界面"); JMenujMenu1=newJMenu("职工管理"); JMenuItemjMenuItem1=newJMenuItem("添加职工"); JMenuItemjMenuItem2=newJMenuItem("修改职工"); JMenuItemjMenuItem3=newJMenuItem("删除职工"); JMenujMenu2=newJMenu("工资管理"); JMenuItemjMenuItem4=newJMenuItem("添加工资"); JMenuItemjMenuItem5=newJMenuItem("修改工资"); JMenuItemjMenuItem8=newJMenuItem("工资查询"); JMenujMenu3=newJMenu("职工查询"); JMenuItemjMenuItem6=newJMenuItem("按工号查询"); JMenuItemjMenuItem7=newJMenuItem("按姓名查询"); JMenujMenu4=newJMenu("帮助"); JMenuItemjMenuItem9=newJMenuItem("互动"); 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("教师工资管理小系统"); 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("系统"); JMenuItemjMenuItem0=newJMenuItem("退出"); JMenuItemjMenuItem1=newJMenuItem("主界面"); JMenujMenu1=newJMenu("工资管理"); JMenuItemjMenuItem2=newJMenuItem("工资查询"); JMenujMenu2=newJMenu("职工查询"); JMenuItemjMenuItem4=newJMenuItem("按工号查询"); JMenuItemjMenuItem5=newJMenuItem("按姓名查询"); JMenujMenu3=newJMenu("帮助"); JMenuItemjMenuItem6=newJMenuItem("互动"); JMenujMenu4=newJMenu("密码设置"); 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("教师工资管理小系统"); 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("职工工号"); JLabeljLabel2=newJLabel("职工姓名"); JLabeljLabel3=newJLabel("职工性别"); JLabeljLabel4=newJLabel("职工年龄"); JLabeljLabel5=newJLabel("所属院系"); JLabeljLabel6=newJLabel("家庭住址"); JLabeljLabel7=newJLabel("联系电话"); 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("职工工号"); 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,"内容不允许为空"); }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. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论