java课程设计职工工资管理系统.docx

上传人:b****6 文档编号:16079850 上传时间:2023-07-10 格式:DOCX 页数:29 大小:111.03KB
下载 相关 举报
java课程设计职工工资管理系统.docx_第1页
第1页 / 共29页
java课程设计职工工资管理系统.docx_第2页
第2页 / 共29页
java课程设计职工工资管理系统.docx_第3页
第3页 / 共29页
java课程设计职工工资管理系统.docx_第4页
第4页 / 共29页
java课程设计职工工资管理系统.docx_第5页
第5页 / 共29页
java课程设计职工工资管理系统.docx_第6页
第6页 / 共29页
java课程设计职工工资管理系统.docx_第7页
第7页 / 共29页
java课程设计职工工资管理系统.docx_第8页
第8页 / 共29页
java课程设计职工工资管理系统.docx_第9页
第9页 / 共29页
java课程设计职工工资管理系统.docx_第10页
第10页 / 共29页
java课程设计职工工资管理系统.docx_第11页
第11页 / 共29页
java课程设计职工工资管理系统.docx_第12页
第12页 / 共29页
java课程设计职工工资管理系统.docx_第13页
第13页 / 共29页
java课程设计职工工资管理系统.docx_第14页
第14页 / 共29页
java课程设计职工工资管理系统.docx_第15页
第15页 / 共29页
java课程设计职工工资管理系统.docx_第16页
第16页 / 共29页
java课程设计职工工资管理系统.docx_第17页
第17页 / 共29页
java课程设计职工工资管理系统.docx_第18页
第18页 / 共29页
java课程设计职工工资管理系统.docx_第19页
第19页 / 共29页
java课程设计职工工资管理系统.docx_第20页
第20页 / 共29页
亲,该文档总共29页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

java课程设计职工工资管理系统.docx

《java课程设计职工工资管理系统.docx》由会员分享,可在线阅读,更多相关《java课程设计职工工资管理系统.docx(29页珍藏版)》请在冰点文库上搜索。

java课程设计职工工资管理系统.docx

java课程设计职工工资管理系统

 

一、设计目的…………………………………………………………………2

二、功能介绍…………………………………………………………………2

三、程序流程…………………………………………………………………2

四、设计步骤…………………………………………………………………3

五、设计总结…………………………………………………………………7

六、程序清单…………………………………………………………………8

七、参考文献…………………………………………………………………17

 

一、设计目的

通过课程设计,使学生提高理论联系实际解决实际问题的能力;也使学生对基于面向对象的理论进行系统设计过程中的诸多具体问题有感性的认识和深入的理解;进而提高学生的学习兴趣为其将来顺利进入毕业环节作必要的准备。

二、功能介绍

(1)具有新用户注册功能。

(2)具有注册用户登录功能。

(3)具有职工工资的录入功能,要求只录入工资各项,自动计算每个职工工资总额。

(4)具有数据查询功能,可以实现查询全部信息和按条件执行查询。

(5)具有按条件删除数据功能。

三、程序流程

开始

新用户登录?

输入用户名和密码

进入系统选择操作

录入功能

查找功能

删除功能

注册新用户

向数据库添加记录

可按职工号查询或查询所有数据

按选中行的行号删除数据

结束

Y

N

四、设计步骤

4.1、登陆界面

进入系统首先进入登陆界面如图4.1,输入账号和密码,点击登录就会进入职工工资管理系统,点击注册进入新用户注册界面,定义了局部变量String类型的user,password和pass分别记录界面输入的账号,密码和数据库查找的密码,定义了成员变量boolean型的bool记录输入账号和密码是否匹配。

图4.1登陆界面

4.2、职工工资管理系统

登陆成功后进入的界面如图4.2,界面有增删改查的功能。

widgetSelected()

方法创建button的点击事件,创建DBHelper类的对象db连接数据库,进行查找,删除修改功能,增删改用update()方法,查询用query()方法。

图4.2职工工资管理界面

4.3、全部查找功能

点击右边的查询按钮可以查找出所有员工的工资信息如图4.3,通过自己封装的连接数据库的类DBHelper类的对象db,传递sql语句查找数据库的所有信息,用getString()方法导出从数据库中查找到的数据,所得工资=基本工资+职位提成-50*迟到天数-100*旷工天数,通过查找的数据和自己定义的公式得到所得工资。

图4.3全部查找界面

4.4、按条件查找功能

在文本框中输入职工号,点击查找能找到对应职工的工资情况,如图4.4。

用getText()方法获得text文本框中的的输入信息,定义局部变量boolean型的数据bool,记录数据库中是否有对应的职工号,如果查到则为true,并且在表格中先用removeAll()方法清空表的信息,然后用sql语句找出text中的职工号对应的数据。

图4.4按条件查找界面

4.5、录入功能

点击录入键进入录入界面如图4.5,输入职工信息,点击录入修改数据库的信息,并且能更新查找的结果。

用getText()方法获得text文本框的信息,定义局部变量String类型的s1,s2,s3,s4,s5,s6记录六个文本框的信息,通过DBHelper的对象db调用update方法把信息传入数据库。

图4.5录入功能界面

4.6、删除功能

点击选中行,然后点击删除按钮就会将选种的行删除掉,例如删除图4.3中第三行数据如图4.6。

定义局部变量TableItem[]数组用table.getSelection()方法查找并存储选中行的信息,定义int[]型数组用table.getSelectionIndices()方法查找并存储选中行的行号,用这两个信息分别删除数据库和界面的选中信息。

图4.6删除功能界面

4.7、注册功能

点击注册键后进入如图4.7所示的界面,输入新用户账号和密码,如果两次密码输入相同就注册成功。

定义局部变量String类型的user,password和pass分别记录三个文本框输入的内容,用equals方法判断pass和password是否相同,如果相同,则注册成功,并用dispose()方法关闭此窗口。

图4.7注册功能界面

五、设计总结

这次课程设计,我们知道了成员变量和局部变量的不同,有些变量如果不设成成员变量就无法把数据传递出去,我们学会了封装,将连接数据库的方法封装到DBHelper类中,封装的便利让我们写程序更快捷,但是界面的功能还不够人性化。

 

六、程序清单

importjava.sql.ResultSet;

importjava.sql.SQLException;

importorg.eclipse.swt.SWT;

importorg.eclipse.swt.events.SelectionAdapter;

importorg.eclipse.swt.events.SelectionEvent;

importorg.eclipse.swt.widgets.Button;

importorg.eclipse.swt.widgets.Display;

importorg.eclipse.swt.widgets.Label;

importorg.eclipse.swt.widgets.Shell;

importorg.eclipse.swt.widgets.Text;

importcom.swtdesigner.SWTResourceManager;

publicclassdengluextendsShell{

booleanbool;

privateTexttext_1;

privateTexttext;

publicstaticvoidmain(Stringargs[]){

try{

Displaydisplay=Display.getDefault();

denglushell=newdenglu(display,SWT.SHELL_TRIM);

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(this,SWT.BORDER);

label.setFont(SWTResourceManager.getFont("",12,SWT.BOLD));

label.setText("账号:

");

label.setBounds(90,112,60,27);

finalLabellabel_1=newLabel(this,SWT.BORDER);

label_1.setFont(SWTResourceManager.getFont("",12,SWT.BOLD));

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{

Displaydisplay=Display.getDefault();

zhigonggongzishell=newzhigonggongzi(display,SWT.SHELL_TRIM);

shell.open();

shell.layout();

while(!

shell.isDisposed()){

if(!

display.readAndDispatch())

display.sleep();

}

}catch(Exceptione2){

e2.printStackTrace();

}

}

}

}catch(SQLExceptione1){

//TODOAuto-generatedcatchblock

e1.printStackTrace();

}

}

});

button.setFont(SWTResourceManager.getFont("",12,SWT.BOLD));

button.setText("登陆");

button.setBounds(388,255,48,22);

finalButtonbutton_1=newButton(this,SWT.NONE);

button_1.setFont(SWTResourceManager.getFont("",12,SWT.BOLD));

button_1.setText("注册");

button_1.setBounds(388,306,48,22);

finalLabellabel_2=newLabel(this,SWT.BORDER);

label_2.setFont(SWTResourceManager.getFont("",15,SWT.BOLD));

label_2.setText("欢迎使用员工工资管理系统");

label_2.setBounds(90,37,271,27);

//

}

@Override

protectedvoidcheckSubclass(){

//DisablethecheckthatpreventssubclassingofSWTcomponents

}

}

importjava.sql.ResultSet;

importjava.sql.SQLException;

importorg.eclipse.swt.SWT;

importorg.eclipse.swt.events.SelectionAdapter;

importorg.eclipse.swt.events.SelectionEvent;

importorg.eclipse.swt.widgets.Button;

importorg.eclipse.swt.widgets.Display;

importorg.eclipse.swt.widgets.Label;

importorg.eclipse.swt.widgets.Shell;

importorg.eclipse.swt.widgets.Table;

importorg.eclipse.swt.widgets.TableColumn;

importorg.eclipse.swt.widgets.TableItem;

importorg.eclipse.swt.widgets.Text;

importcom.swtdesigner.SWTResourceManager;

publicclasszhigonggongziextendsShell{

privateTexttext;

privateTabletable;

publicstaticvoidmain(Stringargs[]){

try{

Displaydisplay=Display.getDefault();

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(){

setText("职工工资管理系统界面");

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{

Displaydisplay=Display.getDefault();

lurushell=newluru(display,SWT.SHELL_TRIM);

shell.open();

shell.layout();

while(!

shell.isDisposed()){

if(!

display.readAndDispatch())

display.sleep();

}

}catch(Exceptione2){

e2.printStackTrace();

}

a();

}

});

button.setFont(SWTResourceManager.getFont("",12,SWT.BOLD));

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

Stringid=item[i].getText(0);

Stringsql="deletefrom职工信息表where职工号='"+id+"'";

db.update(sql);

}

db.close();

int[]a=table.getSelectionIndices();

table.remove(a);

}

});

button_1.setFont(SWTResourceManager.getFont("",12,SWT.BOLD));

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.setFont(SWTResourceManager.getFont("",12,SWT.BOLD));

button_2.setText("查询");

button_2.setBounds(604,91,55,31);

text=newText(this,SWT.BORDER);

text.setBounds(209,314,89,31);

finalLabellabel=newLabel(this,SWT.BORDER);

label.setFont(SWTResourceManager.getFont("",12,SWT.BOLD));

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职工信息表";

Resul

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2