![java教师工资管理系统完整代码_第1页](http://file4.renrendoc.com/view/4961c38b20badde6fc7e669345dd06bd/4961c38b20badde6fc7e669345dd06bd1.gif)
![java教师工资管理系统完整代码_第2页](http://file4.renrendoc.com/view/4961c38b20badde6fc7e669345dd06bd/4961c38b20badde6fc7e669345dd06bd2.gif)
![java教师工资管理系统完整代码_第3页](http://file4.renrendoc.com/view/4961c38b20badde6fc7e669345dd06bd/4961c38b20badde6fc7e669345dd06bd3.gif)
![java教师工资管理系统完整代码_第4页](http://file4.renrendoc.com/view/4961c38b20badde6fc7e669345dd06bd/4961c38b20badde6fc7e669345dd06bd4.gif)
![java教师工资管理系统完整代码_第5页](http://file4.renrendoc.com/view/4961c38b20badde6fc7e669345dd06bd/4961c38b20badde6fc7e669345dd06bd5.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
教师工资管理系统:开发团队:206和207时间:2012年4月8日数据库配置:sqlserver2000|hbSQLServerEntrrrrise艾件回噪佰也)查看凹工具叫杏口叫卷助凶牛SEHX昭X固[B尘回宰隽或目匿田_控制WR目混H勺|MlcroEafig0LSflrv&rs
4目迎Sarver担-Qj)(Loa»sl)OfindoMEED数矣阵=Hl-'"'+++-i--i-
-i-:aBooifi'tc'r6dh_JFJI[:ri-astarFiGdcJ.ri^db3Torthwind.pob=SaLficryNutagcnant2工军利|, 34个项目名称所有者类型创定日期April■Jta3012-4-E:Og:5Li:48^1AucusldbaED12-4-BO9:5L:13J=jBecemberdtio5012-4-00951:27营dtjropertieEdbo£012-4-5£215:55||l==|EnpLD/afrdba用户2CIT-4-6>>;:':M ■■■[==|Februarydh>a用尸2012-l-BOQ:5L:-1W^jj|JanumTdbaEF2012-4-BM:52:D3ZJUdbgE「2D12-4-BO9:52:E2JunedblHFZO12-4-B09J2:3G^=llogLJidatai=i_. =dba用FIZS3r-HZO12-4-T15:2L:DTMT)创建数据库SalaryManagement在其下创建数据表logindata>鬲设计表alocinda-ts"—位置是"SalaryKanage&Bii-t"中.M(local)"上长.号TZ卜char10password ctm'107—列悦攵 A创建数据表Employee:tlEBpl.QyeeCT『位置是"SaJ-arylanagEicnt™中.*(local)m上IE ;取氐走坦|云度|尢许至[►cn^laydAidbJi&t]□passwordchar10如1收皿m¥£urc]iar20enjilayees^xekir2sfljilaycci砂ckfiTAenjl-ayetc■:>11eggckar10建nplay4e印ddrezz"rarizlt-ar50 cnjlayaAidlleh.ar2D■y
笛设计表HJanuary",位置是*Salacylanaeeaent"中."(local)"上n■创建数据表February创建数据表March上I设计表 f位置是aSalziryKanugcncnt"中、a(loca.1)"上列莒壬度分牛空□h.irIBMarchcharIB■/—创建数据库April7m设计表"April">隹置是aSalarylanage»ent"中、a(local)"上数■类型长度允许空char18Aprilchar18设计表ray”,世置是**SalaryKanageunt"中、-(local)",上,匚anplDyaiaidNaychiTchar1816创建数据表June设计表"June"I位置是aSalarylanage*ent"中、a(local)"上列名数据类型长度允许空|employeeidch:±riaJut比charIE创建数据表July设计表-July",位置昌'=aSalarylanageMent"中、"(local)"上列名数据类型长度允:■午空empluyeeidcharIEJulycharIE—创建数据表Augustjm设计表"August"r位置是"Salarylanage>ent"中、™(local)"上列名数据类型长度允许空汽1empluyeeidi:h:±r18AugniEt185创建数据表September
设计表'"Octoljer"9位置是**SalaryBanageaent"中、M(local)"上列名| 数据类型 |长度允许空|悝enipluyeeidC:h:iT 13UctijberC:h:iT 18阿诜计表阿诜计表HSepte>ber"»位置是"SalarylanagBMent"中、H(local)"_t列名数据类型长度允祥空ch:±r18Septernberch:±r187创建数据表October创建数据表November设计表HNove*ber">位置是HSalarylanageMent"中、a(local)"上 数■关型K度充计空1enpliiiyeeidchar18ITEivemLerchar18创建数据表December设计表aDece>ber">\览置是aSalaryBanageaent"中、a(local)"上 列名数据类型长度允许三empluyeeidDecembercharchar18187开发工具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(radiobuttonl);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);buttonGroupl.add(jRadioButtonl);buttonGroup1.add(jRadioButton2);this.add(jRadioButtonl);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("insert into Employeevalues('n+EmployeeID+n','n+EmployeePassword+n','n+EmployeeName+n','n+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(jMenuBarl);jMenuBar1.add(jMenu0);jMenuBarl.add(jMenul);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);}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("insert into Employeevalues('"+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(jradiobuttonll);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("")IEmployeeSalary.equals("")){JOptionPane.showMessageDialog(this,"内容不允许为空");}else{try{if(jradiobutton1.isSelected())month="insert intovalues('n+EmployeeID+n','n+EmployeeSalary+nif(jradiobutton1.isSelected())month="insert intovalues('n+EmployeeID+n','n+EmployeeSalary+n')n;elseif(jradiobutton2.isSelected())month="insertintovalues('n+EmployeeID+n','n+EmployeeSalary+n')n;elseif(jradiobutton3.isSelected())month="insert intovalues('n+EmployeeID+n','n+EmployeeSalary+n')n;elseif(jradiobutton4.isSelected())month="insert intovalues('n+EmployeeID+n','n+EmployeeSalary+n')n;elseif(jradiobutton5.isSelected())month="insert intovalues('n+EmployeeID+n','n+EmployeeSalary+n')n;elseif(jradiobutton6.isSelected())month="insert intovalues('n+EmployeeID+n','n+EmployeeSalary+n')n;elseif(jradiobutton7.isSelected())month="Julyinsert intovalues('n+EmployeeID+n','n+EmployeeSalary+n')n;elseif(jradiobutton8.isSelected())month="Augustinsertintovalues('n+EmployeeID+n','n+EmployeeSalary+n')n;elseif(jradiobutton9.isSelected())January(employeeid,January)February(employeeid,February)March(employeeid,March)April(employeeid,April)May(employeeid,May)June(employeeid,June)July(employeeid,July)August(employeeid,August)month="insertintoSeptember(employeeid,September)month="insertintovalues('"+EmployeeID+"','"+EmployeeSalary+"')";elseif(jradiobutton10.isSelected())month="insert into October(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=null;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");conn=DriverManager.getConnection("jdbc:odbc:SalaryManagement”,"sa","youpassword");}catch(ClassNotFoundExceptione){e.printStackTrace();}catch(SQLExceptione){e.printStackTrace();}returnconn;}publicstaticStatementgetStmt(Connectionconn){Statementstmt=null;try{stmt=conn.createStatement();}catch(SQLExceptione){e.printStackTrace();}returnstmt;publicstaticPreparedStatementgetPstmt(Connectionconn,Stringsql){PreparedStatementpstmt=null;try{pstmt=conn.prepareStatement(sql);}catch(SQLExceptione){e.printStackTrace();}returnpstmt;}publicstaticResultSetgetRs(PreparedStatementpstmt){ResultSetrs=null;try{rs=pstmt.execu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 教材资源之课程教案:项目三任务一认识客户满意
- 兴趣教学法在初中体育教学中的应用-第1篇
- 危险化学品仓库隐患排查及安全检查清单
- 集体生活成就我-2024-2025学年道德与法治七年级上册(统编版)
- 黄金卷8(解析版)
- 4.2《怜悯是人的天性》课件-2024-2025学年高二语文素质教育大讲堂(统编版选择性必修中册)
- 适用于新高考新教材备战2025届高考历史一轮总复习第2单元三国两晋南北朝的民族交融与隋唐统一多民族封建国家的发展课时练第8讲三国至隋唐的文化课件
- 猕猴桃病虫害综合防治课件
- 克罗恩病并发症肛瘘护理
- cvc常见并发症护理
- DBJ41T 100-2015 河南省砌块墙体自保温体系技术规程2-(高清版)
- 工程量确认单
- 小学数学二年级上册单元分析
- 医学课件桡骨茎突部狭窄性腱鞘炎
- 三体系审核检查表
- 小学英语作业设计与实施方案
- 胃脘痛中医护理效果评价表
- 回流焊接精品课件
- 确定位置张齐华 完整版课件
- 绿化工程质量保证体系及措施
- 新学期开学工作汇报ppt模板
评论
0/150
提交评论