java课程设计职工工资管理系统_第1页
java课程设计职工工资管理系统_第2页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

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

文档简介

一、设计目的… 2二、功能介绍… 2三、程序流程… 2四、设计步骤… 3五、设计总结… 7六、程序清单… 8七、参考文献… 17一、设计目的于面对对象的理论进行系统设计经过中的诸多详细问题有感性的认识和深入的理解;进而提升学生的学习爱好为其将来顺利进入毕业环节作必要的预备。二、功能介绍具有新用户注册功能。具有注册用户登录功能。具有职工工资的录入功能,要求只录入工资各项,自动计算每个职工工资总额。具有数据查询功能,能够实现查询全部信息和按条件执行查询。具有按条件删除数据功能。三、程序流程开头开头新用户登录?YN注册新用户输入用户名和密码进入系统选择操作录入功能查找功能删除功能向数据库添加记录可按职工号查询或查询所有数据按选中行的行号删除数据结束四、设计步骤、登陆界面输入账号和密码,点击登录就会进入职工Stringuser,booleanbool4.1、职工工资管理系统登陆成功后进入的界面如图4.2,界面有增删改查的功能。widgetSelected()DBHelperdbupdate()query()方式。4.2、全部查找功能点击右边的查询按钮能够查找出所有员工的工资信息如图4.3,经过自己封装DBHelperdb,sqlgetString()方式导出从数据库中查找到的数据,所得工资=根本工资+职位提成-50*-100*旷工天数,经过查找的数据和自己定义的公式得到所得工资。4.3、按条件查找功能在文本框中输入职工号,点击查找能找到对应职工的工资情况,如图4.4。用getText()textbooleanbool,记录数据库中是否有对应的职工号,假若查到则为true,并且在表格中先用removeAll()方式清空表的信息,然后用sqltext4.4、录入功能输入职工信息,点击录入修改数据库的信息,getText()textDBHelperdbupdate4.5、删除功能点击选中行,然后点击删除按钮就会将选种的行删除掉,例如删除图4.3table.getSelection()方式查找并int[]table.getSelectionIndices()方式查找并存储选中行的行号,用这两个信息分别删除数据库和界面的选中信息。4.6、注册功能点击注册键后进入如图4.7user,passwordpasspasspassworddispose()方式关闭此窗口。4.7五、设计总结员变量就无法把数据传递出去,我们学会了封装,将连接数据库的方式封装到DBHelper六、程序清单importimportimportimportimportimportimportimportimportimportimportpublicclassdengluextendsShell{booleanbool;privateTexttext_1;privateTexttext;publicstaticvoidmain(Stringargs[]){try{shell.open();shell.layout();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}}catch(Exceptione){e.printStackTrace();}}publicdenglu(Displaydisplay,intstyle){super(display,style);createContents();}protectedvoidcreateContents()setText("登陆界面");setSize(622,439);finalLabellabel=newLabel(thisSWT.BORDER);,label.setText("账号:");label.setBounds(90,112,60,27);finalLabellabel_1=newLabel(thisSWT.BORDER);,label_1.setText("密码:");label_1.setBounds(90,185,60,27);text=newText(this,SWT.BORDER);text.setBounds(208,112,125,27);text_1=newText(this,SWT.BORDER|SWT.PASSWORD);text_1.setBounds(208,185,125,27);finalButtonbutton=newButton(this,SWT.NONE);button.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(finalSelectionEvente){Stringuser=text.getText();Stringpassword=text_1.getText();DBHelperdb=newDBHelper();Stringsql="select密码fromuser_Tablewhere账号='"+user+"'";ResultSetrs=db.query(sql);try{while(rs.next()){Stringpass=rs.getString("密码");if(password.equals(pass)){bool=true;}else{bool=false;}if(bool==true){

try{zhigonggongzishell=newzhigonggongzi(display,shell.open();shell.layout();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}}catch(Exceptione2){e2.printStackTrace();}}}}catch(SQLExceptione1){//TODOAuto-generatedcatchblocke1.printStackTrace();}}});button.setText("登陆");button.setBounds(388,255,48,22);finalButtonbutton_1=newButton(thisSWT.NONE);,button_1.setText("注册");button_1.setBounds(388,306,48,22);finalLabellabel_2=newLabel(thisSWT.BORDER);,label_2.setText("欢迎使用员工工资管理系统");label_2.setBounds(90,37,271,27);//}@OverrideprotectedvoidcheckSubclass(){//DisablethecheckthatpreventssubclassingofSWTcomponents}}importimportimportimportimportimportimportimportimportimportimportimportimportimportpublicclasszhigonggongziextendsShell{privateTexttext;privateTabletable;publicstaticvoidmain(Stringargs[]){try{zhigonggongzishell=newzhigonggongzi(display,SWT.SHELL_TRIM);shell.open();shell.layout();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}}catch(Exceptione){e.printStackTrace();}}publiczhigonggongzi(Displaydisplay,intstyle){super(display,style);createContents();}protectedvoidcreateContents());setSize(697,458);table=newTable(this,SWT.FULL_SELECTION|SWT.BORDER);table.setLinesVisible(true);table.setHeaderVisible(true);table.setBounds(10,67,573,214);finalTableColumnnewColumnTableColumn=newTableColumn(table,SWT.NONE);newColumnTableColumn.setWidth(73);newColumnTableColumn.setText("职工号");finalTableColumnnewColumnTableColumn_1=newTableColumn(table,SWT.NONE);newColumnTableColumn_1.setWidth(76);newColumnTableColumn_1.setText("职工姓名");finalTableColumnnewColumnTableColumn_2=newTableColumn(table,SWT.NONE);newColumnTableColumn_2.setWidth(76);newColumnTableColumn_2.setText("根本工资");finalTableColumnnewColumnTableColumn_3=newTableColumn(table,SWT.NONE);newColumnTableColumn_3.setWidth(80);newColumnTableColumn_3.setText("职位提成");finalTableColumnnewColumnTableColumn_4=newTableColumn(table,SWT.NONE);newColumnTableColumn_4.setWidth(79);newColumnTableColumn_4.setText("迟到天数");finalTableColumnnewColumnTableColumn_5=newTableColumn(table,SWT.NONE);newColumnTableColumn_5.setWidth(83);newColumnTableColumn_5.setText("旷工天数");finalTableColumnnewColumnTableColumn_6=newTableColumn(table,SWT.NONE);newColumnTableColumn_6.setWidth(100);newColumnTableColumn_6.setText("所得工资");finalButtonbutton=newButton(this,SWT.NONE);button.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(finalSelectionEvente){try{shell.open();shell.layout();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}}catch(Exceptione2){e2.printStackTrace();}});

}a();button.setText("录入");button.setBounds(604,142,55,31);finalButtonbutton_1=newButton(this,SWT.NONE);button_1.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(finalSelectionEvente){TableItem[]item=table.getSelection();DBHelperdb=newDBHelper();for(inti=0;i<item.length;i++){Stringid=item[i].getText(0);Stringsql="deletefrom职工信息表where职工号='"+id+"'";db.update(sql);}});

}db.close();int[]a=table.getSelectionIndices();table.remove(a);button_1.setText("删除");button_1.setBounds(604,196,55,31);finalButtonbutton_2=newButton(this,SWT.NONE);button_2.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(finalSelectionEvente){a();}});button_2.setText("查询");button_2.setBounds(604,91,55,31);text=newText(thisSWT.BORDER);text.setBounds(209,314,89,31);finalLabellabel=newLabel(this,SWT.BORDER);,label.setText("按职工号查找:");label.setBounds(53,314,136,31);finalButtonbutton_3=newButton(this,SWT.NONE);button_3.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(finalSelectionEvente){table.removeAll();Stringid=text.getText();DBHelperdb=newDBHelper();Stringsql="select*from职工信息表";ResultSetrs=db.query(sql);booleanbool=true;if(bool){try{while(rs.next()){SWT.BORDER);

if(id.equals(rs.getString("职工号"))){bool=false;finalTableItemnewItemTableItem=newTableItem(table,newItemTableItem.setText(0,rs.getString("职工号"));newItemTableItem.setText(1,rs.getString("姓名"));newItemTableItem.setText(2,rs.getString("根本工资"));newItemTableItem.setText(3,rs.getString("职位提成"));newItemTableItem.setText(4,rs.getString("迟到天数"));));newItemTableItem.setText(5,rs.getString("旷工天数"));));doublemoney=money1+money2-day1*50-day2*100;if(money<0){money=0;}StringMoney=String.valueOf(money);newItemTableItem.setText(6,Money);}}}catch(SQLExceptione1){//TODOAuto-generatedcatchblocke1.printStackTrace();}}}});button_3.setText("查找");button_3.setBounds(347,312,73,33);finalLabellabel_1=newLabel(thisSWT.BORDER);,label_1.setText("职工工资管理系统");label_1.setBounds(189,24,177,31);//}publicvoida(){table.removeAll();DBHelperdb=newDBHelper();Stringsql="select*from职工信息表";ResultSetrs=db.query(sql);try{while(rs.next()){finalTableItemnewItemTableItem=newTableItem(table,SWT.BORDER);newItemTableItem.setText(0,rs.getString("职工号"));newItemTableItem.setText(1,rs.getString("姓名"));newItemTableItem.setText(2,rs.getString("根本工资"));newItemTableItem.setText(3,rs.getString("职位提成"));newItemTableItem.setText(4,rs.getString("迟到天数"));));newItemTableItem.setText(5,rs.getString("旷工天数"));));doublemoney=money1+money2-day1*50-day2*100;if(money<0){money=0;}StringMoney=String.valueOf(money);newItemTableItem.setText(6,Money);}}catch(SQLExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}@OverrideprotectedvoidcheckSubclass(){//DisablethecheckthatpreventssubclassingofSWTcomponents}}importimportimportimportimportimportimportimportimportpublicclassluruextendsShell{privateTexttext_5;privateTexttext_4;privateTexttext_3;privateTexttext_2;privateTexttext_1;privateTexttext;publicstaticvoidmain(Stringargs[]){try{shell.open();shell.layout();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}}catch(Exceptione){e.printStackTrace();}}publicluru(Displaydisplay,intstyle){super(display,style);createContents();}protectedvoidcreateContents()setText("职工工资录入界面");setSize(660,451);finalLabellabel=newLabel(this,SWT.BORDER);label.setText("职工号:");label.setBounds(87,82,87,26);finalLabellabel_1=newLabel(thisSWT.BORDER);,label_1.setText("姓名:");label_1.setBounds(87,119,87,24);finalLabellabel_2=newLabel(thisSWT.BORDER);,label_2.setText("根本工资:");label_2.setBounds(87,149,87,24);finalLabellabel_3=newLabel(thisSWT.BORDER);,label_3.setText("职位提成:");label_3.setBounds(87,179,87,26);finalLabellabel_4=newLabel(thisSWT.BORDER);,label_4.setText("迟到天数:");label_4.setBounds(87,219,87,26);finalLabellabel_5=newLabel(thisSWT.BORDER);,label_5.setText("旷工天数:");label_5.setBounds(87,258,87,26);finalLabellabel_6=newLabel(thisSWT.BORDER);,label_6.setText("职工工资录入界面");label_6.setBounds(209,25,177,35);text=newText(this,SWT.BORDER);text.setBounds(241,82,70,26);text_1=newText(this,SWT.BORDER);text_1.setBounds(241,119,70,24);text_2=newText(this,SWT.BORDER);text_2.setBounds(241,149,70,24);text_3=newText(this,SWT.BORDER);text_3.setBounds(241,179,70,26);text_4=newText(this,SWT.BORDER);text_4.setBounds(241,219,70,26);text_5=newText(this,SWT.BORDER);text_5.setBounds(241,260,70,26);finalButtonbutton=newButton(this,SWT.NONE);button.addSelectionListener(newSelectionAdapter(){publicvoidwidgetSelected(finalSelectionEvente){Strings1=text.getText();Strings2=text_1.getText();Strings3=text_2.getText();Strings4=text_3.getText();Strings5=text_4.getText();Strings6=text_5.getText();DBHelperdb=newDBHelper();Stringsql="insertinto旷工天数)values('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"')";db.update(sql);luru.this.dispose();}});button.setText("录入");button.setBounds(430,321,48,22);//}@OverrideprotectedvoidcheckSubclass(){//DisablethecheckthatpreventssubclassingofSWTcomponents}importimportimportimportimportimportimportimportimportpublicclasszhuceextendsShell{privateTexttext_2;privateTexttext_1;privateTexttext;publicstaticvoidmain(Stringargs[]){try{shell.open();shell.layout();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}}catch(Exceptione){e.printStackTrace();}}publiczhuce(Displaydisplay,intstyle){super(display,style);createContents();}protectedvoidcreateContents()setText("新用户注册界面");setSize(611,455);finalLabellabel=newLabel(thisSWT.BORDER);,label.setText("新用户注册界面");label.setBounds(161,49,163,22);finalLabellabel_1=newLabel(thisSWT.BORDER);,label_1.setText("账号:");label_1.setBounds(76,123,104,22)

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论