还剩23页未读,继续阅读
本资源只提供10页预览,全部文档请下载后查看!喜欢就下载吧,查找使用更方便
文本内容:
延安大学计算机学院实验报告专用纸实验室:软件工程实验室学号:实验日期2013年11月日第页,共页f.setVisibletrue;}publicvoidactionPerformedActionEvente{ifb
3.equalse.getSource{〃返回用户登录d=new用户登录;d.create;fodispose;}ifb2oequalsegetSource{//员工信息管理YGGLyg=newYGGL;ygocreate;fodispose;}ifbl.equalseogetSource{//工资管理GZGLgz=newGZGL;gZocreate;fodispose;}}错误!员工基本信息管理importjavaawt.Color;importjavaoawt.FlowLayout;importjava.awtoeventoActionEvent;importjavaoawtoevent.ActionListener;importjavaosqLConnection;importjava.sqLDriverManager;importjavasqlResultSet;importjavaosqloSQLException;importjava.sqlStatement;importjavaxswingJButton;importjavax.swing.JFrame;importjavaxoswingoJLabel;importjavax.swingoJOptionPane;importjavaxoswing.JPanel;importjavaxoswing.JScrollPane;importjavaxoswingoJSplitPane;importjavax.swing.JTable;importjavax.swing.JTextField;publicclassYGGLextendsJFrameimplementsActionListener{/*———-———-员工信息管理____—_______/JFramef=newJFrame员工信息管理”;JButtonbl=newJButton”添加新员工”;JButtonb2=newJButton修改”;JButtonb3=newJButton删除”;JButtonb4=newJButton查询所有”;JButtonb5=newJButton“返回”;JTextFieldtfl=newJTextField4;JTextFieldtf2=newJTextField4;JTextFieldtf3=newJTextField4;JTextFieldtf4=newJTextField4;JTextFieldtf5=newJTextField4;JTextFieldtf6=newJTextField4;JTextFieldtf7=newJTextField4;JTextFieldtf8=newJTextField4;JTextFieldtf9=newJTextField4;JTextFieldtflO=newJTextField4;JTextFieldtfl1=newJTextField4;JTextFieldtfl2=newJTextField4;JTextFieldtfl3=newJTextField4;JTextFieldtfl4=newJTextField4;String[]cloum={“编号,姓名;性别“,“学校,“专业“,“学历二”电话,“住址“,岗位”」基本工资7部门,“密码”};Object[][]row=newObject
[50]
[12];JTabletable=newJTablerowcloum;JScrollPanescrollpane=newJScrollPanetable;JSplitPanesplitpane=newJSplitPaneJSplitPaneoVERTICAL_SPLIT;voidcreate{JPanelp=JPanelf.getContentPane;posetLayoutnewFlowLayout;p.addscrollpane;paddsplitpane;JPanelpl=newJPanel;pl.addbl;pl.addb2;pl.addb3;pl.addb4;ploaddb5;JPanelp2=newJPanel;p2osetBackgroundColoroyellow;p2oaddscrollpane;p.setLayoutnewFlowLayoutQ;p.addnewJLabelpoaddnewJLabelv编号;p.addtfl;poaddnewJLabel姓名”;p.addtf2;poaddnewJLabel性别;poaddtf3;poaddnewJLabel毕业学校”;poaddtf4;p.addnewJLabel”所学专业“;p.addtf5;p.addnewJLabel学历;p.addtf6;p.addnewJLabel电话“;p.addtf7;poaddnewJLabelClifek;p.addtf8;p.addnewJLabel岗位”;poaddtf9;poaddnewJLabel基本工资”;p.addtflO;p.addnewJLabel,部门名称”;poaddtfll;poaddnewJLabel登录密码;p.addtfl2;p.addnewJLabel权限”;poaddtf13;p.addnewJLabel输入员工编号点击查询/删除;p.addtfl4;//splitpane.addplsplitpane.TOP;splitpane.addplsplitpane.TOP;splitpaneoaddp2splitpane.BOTTOM;splitpaneosetDividerLocation50;p.setBackgroundColoroGREEN;b
1.addActionListenerthis;b
2.addActionListenerthis;b3oaddActionListenerthis;b
4.addActionListenerthis;b
5.addActionListenerthis;fosetBounds200100530630;fosetResizabletrue;〃可以调整界面大小f.setVisibletrue;publicvoidactionPerformedActionEvente{/*———---———ZE.彳m息、---——----*/ifbloequalse.getSource{Connectioncon;Statementsql;try{ClassoforName^com.microsoftosqlserver.jdbcoSQLServerDriverH;}catchClassNotFoundExceptionel{JOptionPaneoshowMessageDialogthis”连接数据库失败!”;try{Stringurl=Hjdbc:sqlserver//localhost1433;DatabaseName=I资管理系统1n;StringuseHsa;Stringpass=7757xiongn;con=DriverManagergetConnectionurluserpass;sql=conocreateStatement;StringinsertStr=INSERTINTOJBXXEmpnoEmnameSexSchoolProfessionEducationPhoneAddressVALUESgetText+”T+tf2getText+”++tf
3.getText+”+tf
4.getText”+tf
5.getTextgetText+”+tf
7.getText+”J+tf8getText+n;”;sqLexecuteUpdateinsertStr;StringinsertStrl=INSERTINTOGWXXEmpnoJobSalaryDeptVALUESM+tfl.getText+”「+tf
9.getTextgetText+J+tfl1getText+”;sql.executeUpdateinsertStrl;StringinsertStr2=INSERTINTOlogininformationEmpnopasswordThegrantVALUESH+tfl.getText+”J+tfl
2.getText+T+tfl3getText+”;sql.executeUpdateinsertStr2;JOptionPaneoshowMessageDialogthis;con.close;}catchSQLExceptionel{JOptionPane.showMessageDialogthis”添加失败!”;}ifb
2.equalsegetSource{/*———————修改员工信息-一一一一____________*IConnectioncon;Statementsql;try{ClassofbrNamecommicrosoft.sqlserver.jdbcoSQLServerDriver;}catchClassNotFoundExceptionel{JOptionPaneoshowMessageDialogthis”连接数据库失败!”;}try{Stringurl=vjdbc:sqlserver://localhost1433;DatabaseName=工资管理系统1”;Stringuser=sa;Stringpass=H7757xiongH;con=DriverManagerogetConnectionurluserpass;sql=con.createStatement;StringupdateStr=UPDATEJBXXSETSex=H+tf
3.getText+”Emname=+tf
2.getText+”,School=Mf+tf4ogetText+”Profession=”+tf5getText+*J+Education=+tf
6.getText+n\Phone=H+tf
7.getText+nAddress=M+tf
8.getText5whereEmpno=M+tfl□getText+”;”;sqLexecuteUpdateupdateStr;StringupdateStr1=UPDATEGWXXSETSalary=n+tflO.getText+Dept=+tfll.getText+»Job=+tf9getText+whereEmpno=+tflgetText+H;”;sqloexecuteUpdateupdateStr1;Stringupdatestr2=UPDATElogininformationSETpassword=4-tf12ogetText+MThegrant=+tfl3getText+”whereEmpno=+tfl.getTextsqloexecuteUpdateupdatestr2;JOptionPane.showMessageDialogthis”修改成功!”;conoclose;}catchSQLExceptionel{JOptionPaneoshowMessageDialogthis修改失败!”;}}ifb
3.equalsegetSource{/*---一-册”除员工信息、-__—---―*/Connectioncon;Statementsql;tryClassoforNamencomomicrosoftosqlserverojdbc.SQLServerDrivef;}catchClassNotFoundExceptionel{JOptionPaneoshowMessageDialogthis连接数据库失败!”;tryStringurl=vjdbc sqlserver//localhost1433;DatabaseName=工资管理系统1”;Stringuser=nsan;Stringpass-7757xiong^^;con=DriverManagerogetConnectionurluserpass;sql=concreateStatementResultSetoTYPE_SCROLL_SENSTTIVEResultSetoCONCUR_READ_ONLY;sql.executeUpdate^DELETEFROMJBXXwhereEmpno=+tfl4getText+;”;sqloexecuteUpdateC^DELETEFROMGWXXwhereEmpno=+tfl
4.getTextsql.executeUpdateMDELETEFROMlogininformationwhereEmpno=+tfl4getText+”;JOptionPaneoshowMessageDialogthis删除;con.close;}catchSQLExceptionel{JOptionPaneoshowMessageDialogthis」删除失败!”;}}ifb4oequalse.getSource{/*-————--——查询全部员工信息-——-—————一--火/Connectioncon;Statementsql;ResultSetrs;tryClassoforNamecommicrosoftosqlserverojdbcoSQLServerDrivef;}catchClassNotFoundExceptionel{JOptionPane.showMessageDialogthis连接数据库失败!}try{Stringurl=njdbc sqlserver//localhost1433;DatabaseName=工资管理系统1”;Stringuser=sa”;Stringpass=7757xiong;con=DriverManager.getConnectionurluserpass;sql=conocreateStatementResultSetoTYPE_SCROLL_SENSITIVEResultSet.CONCUR_READ_ONLY;ifb
4.equalse.getSource{forinti=0;i〈50;i++forintj=0;j12;j++tableosetValueAtij;rs=sql.executeQueryselectdistinctJBXXEmpnoEmname,SexSchoolProfessionEducationPhoneAddress,JobSalaryDeptlogininformation.passwordfromJBXXGWXXlogininformationwhereJBXXEmpno=GWXXEmpnoandJBXX.Empno=logininfbrmation.Empno;;intk=一1;whilers.next{++k;StringEmpno=rs.getStringEmpno”;StringEmname=rsogetStringCEmname;StringSex=rsgetStringSex;StringSchool=rsgetStringSchooln;StringProfession=rs.getStringProfessiorT;StringEducation=rs.getStringEducationn;StringPhone=rs.getStringPhonen;StringAddress二rs.getStringAddress;StringJob=rsgetStringJob1;StringSalary=rs.getStringSalary”;StringDept=rs.getString“Dept”;Stringpassword=rs.getStringpassword;table.setValueAtEmpnok0;table.setValueAtEmnamek1;tableosetValueAtSexk2;table.setValueAtSchoolk3;table.setValueAtProfessionk4;tableosetValueAtEducationk5;table.setValueAtPhonek6;tableosetValueAtAddressk7;tableosetValueAtJobk8;table.setValueAtSalaryk9;tableosetValueAtD叩tk10;tableosetValueAtpasswordk11;}}}catchSQLExceptionel{JOptionPane.showMessageDialogthis”查询失败!”;}}ifb5oequalseogetSource{//返回GZGLZJMgl=newGZGLZJM;gl.create;f.dispose;}错误!考勤及加班信息管理importjava.awt.Color;importjava.awtFlowLayout;importjava.awtoevent.ActionEvent;importjavaoawt.eventoActionListener;importjava.sqloConnection;importjava.sqloDriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjavaosqloStatement;importjavaxswing.JButton;importjavax.swing.JFrame;importjavax.swingoJLabel;importjavax.swingoJOptionPane;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjavaxoswingoJSplitPane;importjavax.swing.JTable;importjavaxoswingoJTextField;publicclassGZGLextendsJFrameimplementsActionListener/*-——————-员工信息管理--—-—————--一_一一一一一—-------IJFramef=newJFrame考勤加班信息管理”;JButtonbl=newJButton^A;JButtonb2=newJButton修改”;JButtonb3=newJButton,册U除;JButtonb4=newJButton查询所有“;JButtonb5二newJButton返回”;JTextFieldtfl二newJTextField4;JTextFieldtf2二newJTextField4;JTextFieldtf3=newJTextField4;JTextFieldtf4=newJTextField4;JTextFieldtf5=newJTextField4;JTextFieldtf6=newJTextFieId4;JTextFieldtf7=newJTextField4;JTextFieldtf8=newJTextField4;JTextFieldtf9=newJTextField4;JTextFieldtflO=newJTextField4;String[]cloum={员工编号请假天数“,“旷工天数“,“迟到次数“,”晚班天数了周末加班节日加班”」春节加班“月份”};Object[][]row=newObject
[50]
[9];JTabletable=newJTablerowcloum;JScrollPanescrollpane=newJScrollPanetable;JSplitPanesplitpane=newJSplitPaneJSplitPane.VERTICAL_SPLIT;voidcreate{JPanelp=JPanelf.getContentPane;p.setLayoutnewFlowLayout;p.addscrollpane;p.addsplitpane;JPanelp1二newJPanel;pLaddbl;pl.addb2;pl.addb3;ploaddb4;pl.addb5;JPanelp2=newJPanel;p
2.setBackgroundColor.yellow;p2oaddscrollpane;p.setLayoutnewFlowLayout;p.addnewJLabelfn;p.addnewJLabel员工编号”;p.addtfl;poaddnewJLabel请假天数”;p.addtf2;poaddnewJLabelv旷工天数”;poaddtf3;poaddnewJLabel迟到次数”;p.addtf4;poaddnewJLabeln晚班天数”;poaddtf5;p.addnewJLabel周末加班”;poaddtf6;p.addnewJLabel节日加班”;p.addtf7;poaddnewJLabel春节加班”;poaddtf8;p.addnewJLabel,月份”;p.addtf9;p.addnewJLabel”输编号点查询删除”;poaddtflO;splitpane.addplsplitpane.TOP;splitpaneoaddp2splitpaneoBOTTOM;splitpaneosetDividerLocation50;posetBackgroundColor.GREEN;bloaddActionListenerthis;b2oaddActionListenerthis;b3oaddActionListenerthis;b4oaddActionListenerthis;b5oaddActionListenerthis;f.setBounds200100550630;fosetResizabletrue;〃可以调整界面大小f.setVisibletrue;}publicvoidactionPerformedActionEvente{/*—————-——添力口员工考勤与加班信息*/ifb
1.equalse.getSource{Connectioncon;Statementsql;tryClassoforName^com.microsoft.sqlserverojdbc.SQLServerDrivern;}catchClassNotFoundExceptionel{JOptionPaneoshowMessageDialogthis连接数据库失败!”;}try{Stringurl=vjdbc:sqlserver://localhost:1433;DatabaseName=工资管理系统1”;Stringuser=9saH;Stringpass=n7757xiongH;con=DriverManager.getConnectionurluserpass;sql=conocreateStatement;StringinsertStr=INSERTINTOKQXXEmpnoLeavedaysTruancydaysLatetimesThemonthVALUESgetText+“9+tf
2.getText+”+getText+\+tf
4.getText+n\n+tf
9.getText+”丁;sqloexecuteUpdateinsertStr;StringinsertStr1=INSERTINTOOVERTIMEINFORMATIONEmpnoNightWeekendFestivalSpecialThemonthVALUESp+tflogetText+”J+9+tf
5.getText+”J+tf6°getText+”J+tf
7.getText+”J+tf8°getText+nM+tf9ogetText+;sqloexecuteUpdateinsertStr1;JOptionPaneoshowMessageDialogthis”添加成功!”;con.closeQ;}catchSQLExceptionel{JOptionPaneoshowMessageDialogthis”制口5^!”;ifb2oequalse.getSource{/*--————一修改员工信息一__-―-*/Connectioncon;Statementsql;tryClass.forNamecommicrosoft.sqlserver.jdbcoSQLServerDrivern;}catchClassNotFoundExceptionel{JOptionPaneoshowMessageDialogthis库如收!”;Stringurl=jdbc sqlserver//localhost:1433;DatabaseName=工资管理系统1”;Stringuser=sa;Stringpass=7757xiong”;con=DriverManager.getConnectionurluserpass;sql=con.createStatement;StringupdateStr=UPDATEKQXXSETLeavedays=+tf2getText+“Truancydays=n9+tf
3.getTextLatetimes=9n+tf
4.getText+[Themonth=+tf9getText+HwhereEmpno=H+tflogetText+;”;sqloexecuteUpdateupdateStr;StringupdateStr1=UPDATEOVERTIMEINFORMATIONSETNight=n+tf
5.getTextnWeekend=+tf
6.getText+nFestival-M+tf
7.getText+\Special-+tf
8.getText+“Themonth=+tf9getText+nwhereEmpno=n+tflogetText+;”;sqloexecuteUpdateupdateStrl;JOptionPaneoshowMessageDialogthis修改成功!”;con.close;}catchSQLExceptionel{JOptionPane.showMessageDialogthis”修改失败!;}}ifb3oequalse.getSource{/*——―-----——-一一一-----一一一删」除员工信息、火/一一一■一一一一—_—_———/Connectioncon;Statementsql;tryClassofbrNamecom.microsoft.sqlserverojdbc.SQLServerDriver;}catchClassNotFoundExceptionel{JOptionPane.showMessageDialogthis”连接数据库失败!”;Stringurl=vjdbc sqlserver//localhost1433;DatabaseName=工资管理系统1”;StringuseLsa”;Stringpass=7757xiong”;con=DriverManagerogetConnectionurluserpass;sql=conocreateStatementResultSet.TYPE_SCROLL_SENSITIVEResultSetCONCUR_READ_ONLY;sql.executeUpdate9DELETEFROMKQXXwhereEmpno=+tf
10.getText;sql.executeUpdateHDELETEFROMOVERTIMEINFORMATIONwhereEmpno=+tflOgetText+;;JOptionPane.showMessageDialogthis”删除成功!;con.closeQ;}catchSQLExceptionel{JOptionPane.showMessageDialogthis”删除失败!”;ifb4oequalse.getSource{/*一一.需求分析工资管理信息系统对企业加强工资管理有着极其重要的作用,就一般的大型企业来说,它的设计内容非常复杂而且繁多,比如拥有工资计算功能,工资统计功能,报表输出功能,而且设计的模块也很多,比如工资管理模块,工资统计模块,报表设计模块,打印输出模块,模糊查询模块等等.在做这个管理系统时,我们既咨询了父母又结合了教师等不同行业人士的工资情况,发现该系统受些许因素牵制比如说公司大小,人员流动性,员工学历等通过我们的了解调查最终总结出系统功能如下ao整体结构合理模块化结构利于操作bo完整的数据输入,输出,维护拥有不错的自检性,用户输错或误输均有提示.拥有较强的容错性,某个用户的错误操作不会引起系统的瘫痪eo程序接口灵活,以便日后操作与维护.f.在不影响系统功能的前提下,美化操作界面.概念设计O1E-R图O2数据流图
(3)o逻辑设计基本信息(员工编号号,姓名,性别,毕业学校,所学专业学历,电话,住址,从事岗位).考勤信息表(员工编号,姓名,请假天数,矿工天数,月迟到次数,月份)加班信息表(员工编号,姓名,晚班加班(天),周末加班(天),春节加班(天),节假日加班(天),月份).岗位信息表(员工编号,姓名,从事岗位,基本工资,部门名称).部门信息表(部门编号,部门名称,部门经理,部门人数)根据基本表创建了如下视图加班津贴(员工编号,姓名,加班薪酬,月份)缺勤扣除表(员工编号,姓名,扣除工资,月份)月工资表(员工编号姓名,基本工资,扣除工资,加班薪酬,实得工资,月份)年终奖(员工编号,姓名,奖
(4)数据字典2o考勤信息表(KQXX)
3.加班信息表pVERTIMEINFQR][4ATIQN列名English__询全部员工信息--——-_*/Connectioncon;Statementsql;ResultSetrs;try{ClassoforNameucom.microsoftosqlserverojdbc.SQLServerDrivern;}catchClassNotFoundExceptionel{JOptionPane.showMessageDialogthis”连接数据库失败!”;}try{Stringurl=njdbc sqlserver://localhost:1433;DatabaseName=工资管理系统1”;Stringuser=9san;Stringpass=7757xiongH;con=DriverManagerogetConnectionurluserpass;sql=concreateStatementResultSet.TYPE_SCROLL_SENSITIVEResultSet.CONCUR_READ_ONLY;ifb
4.equalse.getSource{forinti=0;i50;i++forintj=0;j〈9;j++table.setValueAtn\ij;rs二sql.executeQueryf^electdistinct*fromKQXXOVERTIMEINFORMATIONwhereKQXX.Empno=OVERTIMEINFORMATIONoEmpno”;intk=-1;whilersonext{++k;StringEmpno=rsogetString1;StringLeavedays=rsogetStringLeavedays“;StringTruancydays=rs.getStringTruancydays;StringLatetimes=rs-getStringCTatetimes**;StringNight=rs.getStringNightH;StringWeekend=rs.getStringWeekend;StringFestival=rsogetStringFestival;StringSpecial=rsogetStringSpecial;StringThemonth=rsogetStringThemonth;tableosetValueAtEmpnok0;table.setValueAtLeavedaysk1;tableosetVaiueAtTruancydaysk2;table.setValueAtLatetimesk3;tableosetValueAtNightk4:table.setValueAWeekendk5;table.setValueAtFestivalk6;tableosetValueAtSpecialk7;tableosetValueAtThemonthk8;}}}catchSQLExceptionel{JOptionPane.showMessageDialogthis”查询失败!”;}}ifb5oequalseogetSource{〃返回GZGLZJMgl=newGZGLZJM;|gLcreate;f.dispose;}}}错误!员工个人工资查询importjava.awt.Color;importjava.awtFlowLayout;importjavaoawt.event.ActionEvent;importjava.awtoeventoActionListener;importjava.sqloConnection;importjavaosqloDriverManager;importjavasqLResultSet;importjavaosqloSQLException;importjavaosql.Statement;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swingoJOptionPane;importjavaxoswing.JPanel;importjavaxoswing.JScrollPane;importjavax.swingoJSplitPane;importjavax.swing.JTable;publicclassYGDLJMextends用户登录implementsActionListener{/*————---j/i--n一___n__————用户界面—---————--*/JFramef=newJFrame“工资管理”;JButtonbl=newJButton查询个人工资”;JButtonb2=newJButton修改密码”;JButtonb3=newJButton“;String[]cloum={”员工编号“,“姓名”“基本工资“,“加班薪酬扣除工资“,“实得工资”」月份”};Object[][]row=newObject
[50]
[7];JTabletable二newJTablerowcloum;JScrollPanescrollpane=newJScrollPanetable;JSplitPanesplitpane=newJSplitPaneJSplitPaneoVERTICAL_SPLIT;voidcreate{JPanelp=JPanelfgetContentPane;p.setLayoutnewFlowLayout;p.addscrollpane;poaddsplitpane;JPanelpl=newJPanel;pl.addbl;pl.addb2;pl.addb3;JPanelp2=newJPanelQ;p
2.setBackgroundColor.yellow;p
2.addscrollpane;JPanelp3=newJPanel;p.setLayoutnewFlowLayout;splitpaneoaddplsplitpaneoTOP;splitpane.addp2splitpane□BOTTOM;splitpaneosetDividerLocation50;//p.setBackgroundColoroCYAN;posetBackgroundColor.GREEN;b
1.addActionListenerthis;b2oaddActionListenerthis;b
3.addActionListenerthis;fosetBounds200100500550;fosetResizablefalse;//不可以调整界面大小f.setVisibletrue;publicvoidactionPerformedActionEvente{ifbloequalseogetSource{//查询个人工资Connectioncon;Statementsql;ResultSetrs;try{ClassoforNamecommicrosoft.sqlserver.jdbc□SQLServerDrivern;}catchClassNotFoundExceptionel{Systemooutoprintlnn+el;}try{Stringurl=Mjdbc:sqlserver://localhost1433;DatabaseName=匚资管理系统1”;Stringuser=san;Stringpass=7757xiong”;con=DriverManagerogetConnectionurluserpass;sql二concreateStatementResultSetoTYPE_SCROLL_SENSITIVEResultSet.CONCUR_READ_ONLY;ifbloequalsegetSource{forinti=0;i50;i++forintj=0;j〈7;j++table.setValueAt心ij;rs=sqloexecuteQueryselectdistinctSALARYEmpno,EmnameSalaryOvertimesalaryDeductionsGainsalaryThemonthfromSALARYlogininformationwhereSALARYoEmpno-n+tl+^andlogininfbrmation.password=”+t2+””;intk=—1;whilers.next{++k;StringEmpno=rs.getStringEmpno”;StringEmname=rs.getStringEmname;StringSalary=rsgetStringCSalary”;StringOvertimesalary=rsogetStringHOvertimesalaryn;StringDeductions=rsogetStringDeductions;StringGainsalary=rsogetStringGainsalary;StringThemonth=rs.getStringThemonth;table.setValueAtEmpnok0;tableosetValueAtEmnamek1;tableosetValueAtSalaryk2;table.setValueAtOvertimesalaryk3;table.setValueAtDeductionsk4;tableosetValueAtGainsalaryk5;tableosetValueAtThemonthk6;}}}catchSQLExceptionel{JOptionPane.showMessageDialogthis;}}ifb
2.equalse.getSource{〃修改密码修改密码xgmm=new修改密码;xgmm.create;}ifb
3.equalsegetSource{〃返回用户登录dl-new用户登录;dl.create;fodispose;}}}7员工登录密码修改importjava.awtColor;importjava.awt.FlowLayout;importjavaoawtoeventoActionEvent;importjavaawt.eventoActionListener;importjavaosqLConnection;importjava.sql.DriverManager;importjavaosqLSQLException;importjava.sql.Statement;importjavax.swingJButton;importjavaxswing.JFrame;importjavaxswing.JLabel;importjavax.swingoJOptionPane;importjavaxoswing.JPanel;importjavaxswing.JPasswordField;/*———————-修改密码-—■___*/class修改密码extends用户登录implementsActionListener{JFrameframe=newJFrame“密码修改”;JLabellabel1=newJLabel“原密码”;JLabellabel2=newJLabel新密码;JButtonButton1=newJButton确定”;JButtoncancelButton=newJButton“返回”;JPasswordFieldpassword=newJPasswordField9;JPasswordFieldnewpassword=newJPasswordField9;voidcreate{JPanelp=JPanelframeogetContentPane;p.setLayoutnewFlowLayout;paddlabel1;psetSize55;p.setLocation48;paddpassword;p.setSize100200;posetLocation600600;p.addlabel2;posetSize5020;p.setLocation4080;p.addnewpassword;posetSize10020;posetLocation80120;p.addButton1;p.addcancelButton;p.setBackgroundColoroyellow;p.setVisibletrue;Button
1.addActionListenerthis;cancelButton.addActionListenerthis;frame.setDefaultCloseOperationJFrame.EXIT_ON_CLOSE;frame.pack;frame.setBounds200100500220;frameosetVisibletrue;}publicvoidactionPerformedActionEvente{ife.getSource==Buttonl{Connectioncon;Statementsql;tryClassoforNamencom.microsoft.sqlserver.jdbcoSQLServerDrivern;}catchClassNotFoundExceptionel{JOptionPaneoshowMessageDialogthis”连接数据库失败!”;}try{Stringurl=njdbc:sqlserver://localhost1433;DatabaseName=工资管理系统1”;Stringuser=sa;Stringpass=7757xiongn;con=DriverManagerogetConnectionurluserpass;sql=con.createStatement;StringupdateStr=UPDATElogininformationSETpassword=H+newpasswordgetText+whereEmpno=+tl+;sqloexecuteUpdateupdateStr;JOptionPaneoshowMessageDialogthis”修改成功!”;con.close;}catchSQLExceptionel{JOptionPane.showMessageDialogthis”请输入原密码和新密码!”;}}ifegetSource==cancelButton〃返回{YGDLJMdl=newYGDLJM;dlocreate;frameodispose;}}五.出现的问题与解决方法.在建立数据库视图的时候提示某属性不能识别,因为多个基本表中都有此属性,应该在此属性名前边加上所属表名和小数点,建立成功.o在设计过程中连接数据库时出现连接错误,经过调试发现是登录密码未填写正确,修改后连接成功.
3.当使用者以管理员身份进入员工信息管理时会发现所有员工编号是乱序应该附加使用orderbyEmpnoasc
4.在查询添加修改删除界面进行操作时出现数据库连接失败,发现是连接数据库名未正确填写修改后发现依然不能执行,经过仔细检查发现SQL语句出现错误,经过认真修改,运行成功5o界面美化做得不充分应当看更多的资料学习更加优化的Java编写技术
6.设计不够人性化:a、修改密码时,只需访问原始密码即可修改导致数据安全性较低b、无论入库人员是何种身份在使用完数据后还必须单击查询才可显示出修改数据步骤繁琐六心得体会经过近两个月的编写与改进,我们基本完成了此次课程设计的内容发现只学课本上的内容是远远不够的,实验的重要性越发的突出,课程设计的必要性也不言而喻;课程设计一方面能够加强同学之间的团队合作共同学习,共同进步,另一方面能够锻炼我们的思维,在不断的错误与改进中进步,升华,并且加强了我们的动手实践操作能力在此次课程设计过程中我们遇到了许多问题,发现还有很多不足之处,通过查阅资料,翻看视频等途径,我们最终克服了这些困难.实验过程中,也对团队精神的进行了考察,让我们在合作起来更加默契在成功后一起体会喜悦的心情果然是团结就是力量,只有互相之间默契融洽的配合才能换来最终完美的结果此次设计也让我明白了思路即出路,有仕么不懂不明白的地方要及时请教或上网查询只要认真钻研,动脑思考,动手实践,就没有弄不懂的知识,收获颇丰
4.员工岗位及登录信息表GWXX
5.部门信息表BMXX6o登录信息表logininformation视图的创建
1.加班津贴表JBJT
2.缺勤扣除表QQKC
3.月工资表SALARY
4.年终奖NZJJ
5.系统的实现开发环境SQLserver2005及eclipse错误!用SQL语言创建数据库lo基本信息表JBXXselectJBXXoEmpnoJBXX.Emnamenight*70+weekend*80+festival*140+special*210ThemonthfromOVERTIMEINFORMATIONJBXXwhereOVERTIMEINFORMATIONoEmpno=JBXX.Empno.缺勤扣除表QQKCCreateviewQQKCEmpnoEmnameDeductionsThemonthAsselectJBXX.EmpnoJBXXoEmnameTruancydays*80+Leavedays*40+Latetimes*10ThemonthfromKQXXJBXXwhereJBXX.Empno=KQXXEmpno.月工资表SALARYCreateviewSALARY2EmpnoEmnameSalaryDeductionsOvertimesalaryGainsalaryThemonthAsselectdistinctJBXXoEmpnoJBXX.EmnameGWXXoSalaryDeductionsOvertimesalaryGWXX.Salary+Overtimesalary-DeductionsQQKCoThemonthfromKQXXGWXXQQKCJBJTJBXXOVERTIMEINFORMATIONwhereQQKC.Empno二JBJT.EmpnoandGWXX.Empno=JBXXoEmpnoandOVERTIMEINFORMATIONoEmpno=QQKCoEmpnoandQQKC.Empno=JBXX.EmpnoandKQXX.Themonth=OVERTIMEINFORMATION.ThemonthandJBXXEmpno二KQXXEmpnoandQQKC.Emname=JBJTEmnameandJBJTEmname=JBXX.Emname4年终奖NZJJCreateviewNZJJEmpnoEmnamejiangjinAsSelectJBXX.EmpnoJBXX.EmnamesumSALARY.Gainsalary+sumSALARYoOvertimesalary/12FromKQXXJBJTJBXXSALARYOVERTIMEINFORMATIONGroupbyJBXX.EmpnoJBXXoEmnameSALARYEmpnohavingJBXX.Empno=SALARYoEmpnoandJBXXoEmpno=SALARYEmpno错误!在eclipse中连接SQLserver数据库03编写界面设计的代码错误!运行系统与检验,调试系统四实验数据与程序清单Connection连接代码importjavaosql.*;publicclassconnection{publicstaticvoidmainString口srg{StringdriverName=^com.microsoftosqlserver.jdbc.SQLServerDriverJJ;//力口载JDBC驱动StringdbURL=jdbc sqlserver//localhost1433;DatabaseName=工资管理系统1”;//连接服务器和数据库sa叩leStringuser=sa”;〃默认用户名Stringpass=7757xiong;〃密码ConnectionCon=null;try{ClassoforNamedriverName;Con=DriverManagerogetConnectiondbURLuserpass;System.printin”数据库连接成功!;}catchExceptione{System.out.printin”数据库连接失败!”;eprintStackTrace;}finally{try{Con.close;}catchSQLExceptione{//eoprintStackTrace;}}}}错误!系统进入欢迎界面importjava.awt*;importjava.awtoevent.*;importjavax.swing*;classDBextendsJFrameimplementsActionListener{JFrameframe=newJFrame欢迎进入企业工资管理系统JLabellabel=newJLabelH\JLabeloCENTER;JButtonbuttonl=newJButton进入系统”;JButtonbutton2=newJButton”退出系统”;Imageiconim=newImageicon”
1.jpg;JLabelal=newJLabelim;voidCreate{JPanelpcontentPane=JPanelframeogetContentPane;pcontentPane.addlabel;pcontentPanesetLayoutnewFlowLayout;pcontentPane.addbutton1;pcontentPaneaddbutton2;pcontentPane.setVisibletrue;button1oaddActionListenerthis;button!addActionListenerthis;frameosetDefaultCloseOperationJFrame.EXIT_ON_CLOSE;frame.pack;frameosetBounds200100550230;frame.setVisibletrue;}publicstaticvoidmainStringf]args{DBdome=newDB;dome.Create;}publicvoidactionPerformedActionEvente{ifbuttonl.equalseogetSource{用户登录dl=new用户登录0;dLcreate;frame.dispose;}ifbutton
2.equalseogetSource{〃退出System.exit0;}}}错误!登陆界面importjavaawtColor;importjavaoawt.FlowLayout;importjava.awt.eventoActionEvent;importjava.awt.event.ActionListener;importjavaosqLConnection;importjava.sqloDriverManager;importjava.sql.ResultSet;importjava.sqlStatement;importjavaxoswingoImageicon;importjavax.swingJButton;importjavax.swing.JFrame;importjavaxswingJLabel;importjavaxoswing.JOptionPane;importjavaxoswingoJPanel;importjavaxoswing.JPasswordField;importjavax.swingoJTextField;/*---—————_———*/class用户登录extendsJFrameimplementsActionListener{Imageiconim=newImagelcon
2.jpg;JLabela2=newJLabelim;JFrameframe=newJFrame职工/管理员登陆”;JLabellabel1=newJLabel用户名”;JLabellabe12=newJLabel密码”;JButtonlogonButtonl=newJButton管理员登录;JButtonlogonButton2=newJButton,职工登录JButtoncancelButton=newJButton退出”;JTextFieldusername=newJTextField9;JPasswordFieldpassword=newJPasswordField9;staticStringtl;staticStringt2;voidcreate{JPanelp=JPanelframeogetContentPane;JPanelp1=newJPanel;posetLayoutnewFlowLayout;p.adda2;p.addlabell;p.setSize55;posetLocation48;p.addusername;posetSize100200;posetLocation800800;p.addlabel2;p.setSize5020;p.setLocation4080;poaddpassword;posetSize10020;p.setLocation80120;poaddlogonButtonl;p.addlogonButton2;p.addcancelButton;p.setBackgroundColor.yellow;posetVisibletrue;logonButton
1.addActionListenerthis;logonButton
2.addActionListenerthis;cancelButtonoaddActionListenerthis;frame.setDefaultCloseOperationJFrameEXIT_ON_CLOSE;frame.pack;frame.setBounds200100500260;frame.setVisibletrue;publicvoidactionPerformedActionEventetl=username.getText;t2=password.getText;ife.getSource==logonButton1{ifusername.getTextoequalsadmirT==truepassword.getTextequals9adminn==true{JOptionPaneoshowMessageDialogthis“登录成功!GZGLZJMgz=newGZGLZJM;gZocreate;frameodispose;}else{JOptionPaneoshowMessageDialognull”输入用户名或密码错误!”;}ife.getSource=logonButton2{try{Connectioncon;Statementps;ResultSetrs;Stringsql=null;ClassoforName^com.microsoftosqlserverojdbc.SQLServerDriver;Stringurl=njdbc sqlserver://localhost1433;DatabaseName=工资管理系统1”;Stringuser=sa;Stringpass=97757xiongn;con=DriverManagerogetConnectionurluserpass;sql=select*fromlogininformationwhereEmpno=+tl+”andpassword-”+t2+””;Statementsta=con.createStatement;rs=sta.executeQuerysql;ifrs.next{ifrsogetStringEmpnoequals1rsogetStringpassword.equalst2{YGDLJMyg=newYGDLJM;ygocreate;frame.dispose;JOptionPane.showMessageDialogthis登录成功!”;thisodispose;else{JOptionPane.showMessageDialogthis”输入用户名或密码错误!”;}}catchExceptionel{//TODOAuto-generatedcatchblockeloprintStackTrace;}}ifcancelButtonoequalse.getSource〃退出{System.exit0;}}O3管理员可管理选项importjava.awt.Color;importjava.awtoFlowLayout;importjava.awt.event.ActionEvent;importjavaoawt.eventoActionListener;importjavaxswing.Imageicon;importjavaxoswingoJButton;importjavax.swing.JFrame;importjavaxoswingoJLabel;importjavax.swing.JPanel;classGZGLZJMextendsJFrameimplementsActionListener{JFramef=newJFrame工资管理系统”;/*---一-跳转页面________*/JButtonbl=newJButtonHX资管理”;JButtonb2=newJButtonn员工信息管理”;JButtonb3=newJButtonv返回”;Imageiconim=newImageIcon
3.jpgM;JLabelal=newJLabelim;voidcreate{JPanelp=JPanelf.getContentPane;p.setLayoutnewFlowLayout;p.addal;p.addbl;paddb2;p.addb3;p.setBackgroundColoroyellow;posetVisibletrue;bl.addActionListenerthis;b2oaddActionListenerthis;b3oaddActionListenerthis;f.setBounds200100500200;姓名班级课程名称数据库系统概论任课教师实验项目名称工资管理系统(课程设计)指导教师实验组别第一组同组者教师评语及成绩实验成绩:教师签字(请按照实验报告的有关要求书写一般必须包括lo实验目的;2实验内容;
3.实验步骤与方法;4o实验数据与程序清单;5出现的问题及解决方法;
6.实验结果,结果分析与体会等内容.)一实验目的
(1)锻炼动手操作能力,以及团队合作意识;
(2)能熟练地运用SQL语句进行各种操作.掌握Java与SQLserver的连接技术,能将Java知识与数据库的知识熟练掌握并操作二实验内容工资管理系统系统功能的基本要求a)员工每个工种基本工资的设定b)加班津贴管理,根据加班时间和类型给予不同的加班津贴;c)按照不同工种的基本工资情况、员工的考勤情况产生员工的每月的月工资;d)员工年终奖金的生成,员工的年终奖金计算公式=(员工本年度的工资总和+津贴的总和)/12;e)企业工资报表能够查询单个员工的工资情况、每个部门的工资情况、按月的工资统计,并能够打印;数据库要求:在数据库中至少应该包含下列数据表a)员工考勤情况表;b)员工工种情况表,反映员工的工种、等级,基本工资等信息;c)员工津贴信息表,反映员工的加班时间,加班类别、加班天数、津贴情况等;d)员工基本信息表e)员工月工资表.三实验步骤与方法列名English列名数据聿型是否空值备注Fmnno吊丁编号intNOTNULLForeignkevNiuht晚班加班(天)intNULL歹U名English列名数据类型是否空值备注Empno员工编号intNOTNULLForeignkeyLeavedays请假天数intNULLTruancydays旷工天数intNULLLatetimes月迟到次数⑴intNULLThemonth月份intNOTNULLWeekend周末加班天intNULLFestival节日加班天intNULLSpecial春节加班天intNULLThemonth月份intNOTNULL列名English列名数据类型是否空值备注Empno员工编号intNOTNULLForeignkeyJob从事岗位varchar16NOTNULLSalary基本工资moneyNOTNULLDept部门名称varchar16NOTNULL列名English列名数据类型是否空值备注Deptno部门编号intNOTNULLPrimarykeyDept部门名称varchar16NOTNULLManager部门经理varchar8NULLEmpnum部门人数intNULL列名English列名数据类型是否空值备注Empno员工编号intNOTNULL登录用户名Password密码Varchar8NullThegrand权限Varchar8Null列名English列名数据类型是否空值备注Empno员工编号intNOTNULLEmname姓名varchar8NOTNULLOvertimesalary加班薪酬MoneyNULLThemonth月份intNOTNULL歹U名English列名数据类型是否空值备注Empno员工编号intNOTNULLEmname姓名varchar8NOTNULLDeductions扣除工资MoneyNULLThemonth月份intNOTNULL列名English列名数据类型是否空值备注Empno员工编号intNOTNULLEmname姓名varchar8NOTNULLSalary基本工资moneyNOTNULLDeductions扣除工资MoneyNULLOvertimesalary加班薪酬MoneyNULLGainsalary实得工资MoneyNULLThemonth月份intNOTNULL列名English列名数据类型是否空值备注Empno员工编号intNOTNULLEmname姓名varchar8NOTNULLJiangjin奖金moneyNULL。