人事管理系统 java课程设计说明书.docx

上传人:b****5 文档编号:6435722 上传时间:2023-01-06 格式:DOCX 页数:54 大小:217.66KB
下载 相关 举报
人事管理系统 java课程设计说明书.docx_第1页
第1页 / 共54页
人事管理系统 java课程设计说明书.docx_第2页
第2页 / 共54页
人事管理系统 java课程设计说明书.docx_第3页
第3页 / 共54页
人事管理系统 java课程设计说明书.docx_第4页
第4页 / 共54页
人事管理系统 java课程设计说明书.docx_第5页
第5页 / 共54页
点击查看更多>>
下载资源
资源描述

人事管理系统 java课程设计说明书.docx

《人事管理系统 java课程设计说明书.docx》由会员分享,可在线阅读,更多相关《人事管理系统 java课程设计说明书.docx(54页珍藏版)》请在冰豆网上搜索。

人事管理系统 java课程设计说明书.docx

人事管理系统java课程设计说明书

 

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

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

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

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

五、设计总结………………………………………………………………6

六、程序清单………………………………………………………………6

 

一、设计目的

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

按照教师给出的思路和计划进度安排独立完成课程设计

二、功能介绍

1、具有新用户注册功能。

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

3、具有数据的录入功能。

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

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

6、具有统计功能

7、本程序采用RCP技术,和SQL数据库。

三.程序流程

图1

四、设计步骤

(一)程序设计步骤

1.建立RCP工程并构建数据库

2.建立view和editor

3.构建基本框架,并主要修改Perspective和WorkbenchWindowAdvisor两个文件

4.构建需要的辅助文件

5.测试

(二)详细设计:

1.登录和注册

当登录名框和密码为空的时候,后边会显示×;当点击验证码的时候,调用Random函数产生随机验证码,点击登录的时候,从三个框中获得值,进行对数据库的操作。

部分代码如下:

Stringname=text.getText();Stringsql="select*fromuserswherename='"+name+"'";DBHelperdb=newDBHelper();ResultSetrs=db.query(sql);效果如图如下:

图2

当用户点击提交时,程序会将用户输入的信息通过SQL语句提交给数据库,如果数据库修改成功,会返回信息。

主要代码如下:

Stringsql="insertintousers(name,sex,password,phone)"+"values('"+text1.getText()+"','"+sex1+"','"+text2.getText()+"','"+text4.getText()+"')";DBHelperdb=newDBHelper();db.update(sql);

DBHelper是封装好的数据库的类,利用update()封装的executeUpdate(sql)

函数对数据库进行操作。

具体如下图:

图3

2.菜单功能部分

利用Link实现view里的菜单功能,用以下代码实现link的实例化:

finalLinkeclipseorgLink=newLink(composite,SWT.NONE),用eclipseorgLink.setText("查看职工信息");实现Link文字内容。

如下图:

图4

3.功能实现模块

同样是利用封装好的类DBHelper对数据库进行查询。

Stringsql="selectbid,bname,bjlfrombumen";ResultSetrs=newDBHelper().query(sql);rs是查询出来的结果集,利用while循环,将查询出来的结果添加到TableItem中,代码如下:

TableItemtableitem=newTableItem(table,SWT.NONE);tableitem.setText(newString[]{rs.getString("bid"),rs.getString("bname"),rs.getString("bjl")});

详细结果如下图:

图5

利用封装好的类DBHelper对数据库进行查询。

Stringsql="selecteidenamesex,age,ctime,xuli,zhuanye,bytime,school,wyu,hunyin,bnamefromemployeebumenwhereemployee.bid=bumen.bid";ResultSetrs=newDBHelper().query(sql),rs是查询出来的结果集,利用while循环,将查询出来的结果添加到TableItem中,代码如下:

TableItemtableitem=newTableItem(table,SWT.NONE);tableitem.setText(newString[]{rs.getString("eid"),rs.getString("ename"),rs.getString("sex"),rs.getString("age"),rs.getString("ctime"),rs.getString("xuli"),rs.getString("zhuanye"),rs.getString("bytime"),rs.getString("school"),rs.getString("wyu"),rs.getString("hunyin"),rs.getString("bname")});

详细结果如下图:

图6

利用封装好的DBHelper中的update()方法对用户输入的东西进行操作,若操作成功,利用SQL语句和相应的处理方法将信息存入数据库中。

Stringsql="insertintoemployee(ename,sex,age,ctime,xuli,zhuanye,bytime,school,wyu,hunyin,bid)"+"values('"+text1.getText()+"','"+sex1+"',"+text2.getText()+",'"+text4.getText()+"','"+text5.getText()+"','"+text6.getText()+"','"+text7.getText()+"','"+text8.getText()+"','"+text10.getText()+"','"+text9.getText()+"',"+bid+")";db.update(sql);如下图:

图7

用户可以输入查找条件,当按照查找按钮的时候,程序会根据查找条从数据库中

查找相应的信息,用户可以根据查找然后输入相应的修改信息,点击提交就会将数据库中的信息进行修改,主要的修改代码如下:

Stringsql="selecteidenamesex,age,ctime,wyu,xuli,hunyinfromemployeewhereename='"+name+"'";DBHelperdb=newDBHelper();ResultSetrs=db.query(sql);修改完事之后,程序会自动刷新表格信息,显示修改之后信息。

如下图:

图8

用户可以输入要删除信息,当按照查找按钮的时候,程序会根据查找条从数据库中查找相应的信息,根据查找的信息删除需要的信息,如果没有找到,就会弹出提示框。

主要代码:

Stringsql="deleteemployeewhereeid="+sign;DBHelperdb=newDBHelper();db.update(sql);效果如下图:

五、设计总结

经过将近一周的课程设计,对java有了更深一层次的认识,感觉java很强大,

Java用sun公司诞生到现今,一直很流行,很受欢迎。

Java语言具有面向对象、分布式的、简单、健壮、安全、结构中立、可移植、多线程、动态等特点。

Java提供了丰富的类库,摒弃了C++中容易引发程序错去的地方等优点,是在这次设计中彻底爱上了java这门语言,以后会更加努力的,将java这门语言学通乃至学精。

虽然课程设计结束了,但是java的学习却没有结束,以后更加努力的。

六.部分主要程序清单

1.RCP中需要修改的ApplicationWorkbenchAdvisor文件

importorg.eclipse.swt.SWT;

importorg.eclipse.swt.widgets.Display;

importorg.eclipse.ui.application.IWorkbenchWindowConfigurer;

importorg.eclipse.ui.application.WorkbenchAdvisor;

importorg.eclipse.ui.application.WorkbenchWindowAdvisor;

importviews.Loginshell;

publicclassApplicationWorkbenchAdvisorextendsWorkbenchAdvisor{

privatestaticfinalStringPERSPECTIVE_ID="rsgl.perspective";

publicstaticbooleantag=false;

publicWorkbenchWindowAdvisorcreateWorkbenchWindowAdvisor(IWorkbenchWindowConfigurerconfigurer){

try{

Displaydisplay=Display.getDefault();

Loginshellshell=newLoginshell(display,SWT.SHELL_TRIM);

shell.open();

shell.layout();

while(!

shell.isDisposed()){

if(!

display.readAndDispatch())

display.sleep();

}

}catch(Exceptione){

e.printStackTrace();

}

if(tag){

returnnewApplicationWorkbenchWindowAdvisor(configurer);

}else{

returnnull;

}

}

publicStringgetInitialWindowPerspectiveId(){

returnPERSPECTIVE_ID;

}

}

2.RCP中需要修改的Perspective文件

importorg.eclipse.ui.IPageLayout;

importorg.eclipse.ui.IPerspectiveFactory;

importviews.Menus;

importviews.MyInfo;

publicclassPerspectiveimplementsIPerspectiveFactory{

publicvoidcreateInitialLayout(IPageLayoutlayout){

layout.addView(Menus.ID,IPageLayout.LEFT,0.45f,layout.getEditorArea());

layout.addView(MyInfo.ID,IPageLayout.BOTTOM,0.6f,Menus.ID);

}

}

3.功能部分程序

3.1

importjava.sql.ResultSet;

importjava.sql.SQLException;

importjava.util.Random;

importorg.eclipse.jface.dialogs.MessageDialog;

importorg.eclipse.swt.SWT;

importorg.eclipse.swt.events.MouseAdapter;

importorg.eclipse.swt.events.MouseEvent;

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;

importrsgl.Activator;

importrsgl.ApplicationWorkbenchAdvisor;

importcom.swtdesigner.ResourceManager;

importcom.swtdesigner.SWTResourceManager;

importcommon.DBHelper;

importcommon.Property;

publicclassLoginshellextendsShell{

privateTexttext_2;

privateTexttext_1;

privateTexttext;

publicstaticvoidmain(Stringargs[]){

try{

Displaydisplay=Display.getDefault();

Loginshellshell=newLoginshell(display,SWT.SHELL_TRIM);

shell.open();

shell.layout();

while(!

shell.isDisposed()){

if(!

display.readAndDispatch())

display.sleep();

}

}catch(Exceptione){

e.printStackTrace();

}

}

/**

*Createtheshell

*@paramdisplay

*@paramstyle

*/

publicLoginshell(Displaydisplay,intstyle){

super(display,style);

createContents();

setBackgroundImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/a-副本.jpg"));

setBackground(SWTResourceManager.getColor(255,255,255));

setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/groupimage.gif"));

setBackgroundMode(SWT.INHERIT_DEFAULT);

setText("用户登陆");

}

/**

*Createcontentsofthewindow

*/

protectedvoidcreateContents(){

setSize(507,400);

finalLabellabel=newLabel(this,SWT.NONE);

label.setBackground(SWTResourceManager.getColor(255,255,255));

label.setText("登录名:

");

label.setBounds(148,195,47,17);

text=newText(this,SWT.BORDER);

text.setBounds(220,192,116,20);

finalLabellabel1=newLabel(this,SWT.NONE);

label1.setBackground(SWTResourceManager.getColor(255,255,255));

label1.setText("密码:

");

label1.setBounds(148,235,39,17);

text_1=newText(this,SWT.BORDER|SWT.PASSWORD);

finalLabellabel4=newLabel(this,SWT.NONE);

text_1.addMouseListener(newMouseAdapter(){

publicvoidmouseDown(finalMouseEvente){

label4.setBackground(SWTResourceManager.getColor(255,255,255));

if(text.getText().trim()!

=""){

label4.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/4.PNG"));

}else{

label4.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/3.PNG"));

}

label4.setBounds(342,195,23,17);

}

});

text_1.setBounds(220,232,116,20);

finalLabellabel2=newLabel(this,SWT.NONE);

label2.setBackground(SWTResourceManager.getColor(255,255,255));

label2.setText("验证码:

");

label2.setBounds(148,274,47,17);

text_2=newText(this,SWT.BORDER);

finalLabellabel3=newLabel(this,SWT.NONE);

label3.setForeground(SWTResourceManager.getColor(255,0,0));

label3.setFont(SWTResourceManager.getFont("@方正舒体",18,SWT.BOLD,true,false));

finalLabellabel4_1=newLabel(this,SWT.NONE);

text_2.addMouseListener(newMouseAdapter(){

publicvoidmouseDown(finalMouseEvente){

String[]a2={"0","1","2","3","4","5","6","7","8",

"9","a","b","c","d","e","f","g","h","i","j",

"k","l","m","n","o","p","q","r","s","t","u",

"v","w","x","y","z"};

Randomr=newRandom();

Stringresult="";

while(result.length()<4){

inttemp=r.nextInt(36);

result=result+a2[temp];

}

label3.setText(result);

System.out.println(label3.getText());

label4_1.setBackground(SWTResourceManager.getColor(255,255,255));//获取label的背景色

if(text_1.getText().trim()!

=""){

label4_1.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/4.PNG"));

}else{

label4_1.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/3.PNG"));

}

label4_1.setBounds(342,235,23,17);

label3.setBackground(SWTResourceManager.getColor(255,255,255));

label3.setBounds(386,271,72,27);

}

});

text_2.setBounds(220,271,116,20);

finalButtonbutton=newButton(this,SWT.NONE);

finalLabellabel4_2=newLabel(this,SWT.NONE);

button.addSelectionListener(newSelectionAdapter(){

publicvoidwidgetSelected(finalSelectionEvente){

//System.out.println(text_1.getText().trim());

System.out.println(text_2.getText());

if(text_1.getText().trim()!

=""&&text_2.getText().equals(label3.getText())){

label4_2.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/4.PNG"));

}else{

label4_2

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

当前位置:首页 > 高等教育 > 医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1