java课程设计报告--雇员管理系统.docx_第1页
java课程设计报告--雇员管理系统.docx_第2页
java课程设计报告--雇员管理系统.docx_第3页
java课程设计报告--雇员管理系统.docx_第4页
java课程设计报告--雇员管理系统.docx_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

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

文档简介

*大学*专业 java课程设计题 目: 雇员管理系统 班 级: * 姓 名: * 学 号: * 同组姓名: * 起 迄 日 期: 地点: 指导教师: 评阅意见:成绩评定:评阅人: 日期:完成日期: 目录一、课程设计的目的2二、课程设计的要求32.1 课设问题:员工管理系统32.2 设计思路:3三、设计概要3四、详细设计34.1 基本模块设计34.1.1gui界面设计44.1.2 查阅模块设计44.1.3 工资管理模块44.1.4 创建个人信息数据库64.2 雇员信息管理主界面设计与实现74.3 雇员信息管理业务层的设计164.4 雇员信息管理的数据访问层设计实现234.5 java修改程序源代码26五、设计总结27六、参考文献27七、附录28一、课程设计的目的随着现代社会的快速发展,我们已进入信息化时代,管理系统在人们的生活中的应用越来越广泛,它已深入到我们工作、学习、生活的各个方面。为了适应时代的发展,本次课程设计的主要任务是设计一个学生员工系统并完成一些基本操作。其目的是:1)复习、巩固java语言的基础知识,进一步加深对java语言的理解和掌握;2)课程设计为学生提供了一个既动手又动脑,独立实践的机会,将课本上的理论知识和实际有机的结合起来,锻炼学生的分析解决实际问题的能力。提高学生适应实际,实践编程的能力;3)培养学生在项目开发中的团队合作精神、创新意识及能力;4)熟练掌握采用普通的java客户端形式与oracle,access,sql server数据库进行连接来进行数据的增、删、改操作;5)采用gui设计,掌握java的gui开发和jdbc的用法;6)对javagui设计有一个整体的了解与把握。二、课程设计的要求2.1 课设问题:员工管理系统要求完成:(1)完成员工的添加、删除、查询、修改功能(2)使用界面操作(3)使用文件完成2.2 设计思路:首先设计面板,然后往面板里添加组件,点击各个组件来实现;要求对员工信息的添加、删除、查询、修改功能。三、设计概要1)gui界面设计。2)业务逻辑设计。3)数据库访问层设计。4)数据表结构的设计。四、详细设计4.1 基本模块设计查询(query)数据库database查阅模块工资管理模块改删增gui界面设计 4.1.1gui界面设计根据需要,界面应该提供如下功能:雇员编号、姓名、电子邮件、电话号码、雇用日期、从事工作编号、薪水、有关薪水的升降等操作、所属主管的编号、部门编号等。界面规划如下:4.1.2 查阅模块设计通过主界面的“前一条”、“下一条”按钮可以查阅整个员工工资及信息情况。例如单击“下一条”按钮,则数据库显示如图:4.1.3 工资管理模块单击主界面上的提升工资或“降低工资”,并选择工资变动的等级,然后单击”提交”按钮,就可以对员工的薪水进行设置,如图:通过上图可以修改员工的一些个人信息,包括个人的电子邮件、电话号码、雇用日期、从事工作、主管编号、部门编号等。提交成功后,系统提示提交成功,如图所示:提交后,“等级变动”学则“二级”,员工的薪水降低500,如图:eclipse的console中显示如下:若是保存失败,则弹出对话框,提示用户保存出错,如图所示:4.1.4 创建个人信息数据库本次我们小组采用access数据库,首先创建空数据库employees:另外通过java代码来进行插入、删除、修改才做,插入信息如下:4.2 雇员信息管理主界面设计与实现主界面布局如图所示:主界面设计开发的实现代码如下:package gui;import records.*; import javax.swing.*;import java.awt.*;import java.awt.event.actionevent;import java.awt.event.actionlistener; import java.util.*;suppresswarnings(serial)public class displayui extends jframepublic static vector emplist = null;public static int currentposition = 0;private jtextfield txtemployee_id;private jtextfield txtfirstname;private jtextfield txtlastname;private jtextfield txtemail; private jtextfield txttel;private jtextfield txtemployeedate;private jtextfield txtemployeejob;private jtextfield txtsalary;private jtextfield txtmanagerid;private jtextfield txtdepartmentid;private checkbox rdbpromote;private checkbox rdbdemote;private jcombobox cmbbox;private checkboxgroup chkgroup;private void addcontroltopane()this.setsize(800,600);/设置布局管理器gridbagconstraints cons = new gridbagconstraints();this.setlayout(new gridbaglayout();/依次放置控件cons.gridx = 0;cons.gridy = 0;cons.gridwidth = 1;cons.gridheight = 1;jlabel lblemployee_id = new jlabel(雇员编号:);this.add( lblemployee_id,cons );cons.gridx = 1;cons.gridy = 0;cons.gridwidth = 1; cons.gridheight = 1;txtemployee_id = new jtextfield(10);/txtemployee_id.seteditable(false);/只用于显示,不可编辑this.add(txtemployee_id,cons);cons.gridx = 0;cons.gridy = 1;cons.gridwidth = 1;cons.gridheight = 1;jlabel lblfirstname = new jlabel(姓:);this.add(lblfirstname,cons);cons.gridx = 1;cons.gridy = 1;cons.gridwidth = 1;cons.gridheight = 1;txtfirstname = new jtextfield(10);/txtfirstname.seteditable(false);this.add( txtfirstname,cons );cons.gridx = 2;cons.gridy = 1;cons.gridwidth = 1;cons.gridheight = 1;jlabel lbllastname = new jlabel(名:);lbllastname.setalignmentx(0);this.add( lbllastname,cons );cons.gridx = 3;cons.gridy = 1;cons.gridwidth = 1;cons.gridheight = 1;txtlastname = new jtextfield(10);/txtlastname.seteditable(false);this.add( txtlastname , cons);cons.gridx = 0;cons.gridy = 2;cons.gridwidth = 1;cons.gridheight = 1;jlabel lblemail = new jlabel(电子邮件:);this.add( lblemail, cons);cons.gridx = 1;cons.gridy = 2;cons.gridwidth = 1;cons.gridheight = 1;txtemail = new jtextfield(10);this.add( txtemail, cons);cons.gridx = 2;cons.gridy = 2;cons.gridwidth = 1;cons.gridheight = 1;jlabel lbltel = new jlabel(电话号码:);this.add( lbltel, cons);cons.gridx = 3;cons.gridy = 2;cons.gridwidth = 1;cons.gridheight = 1;txttel = new jtextfield(10);this.add(txttel, cons);cons.gridx = 0;cons.gridy = 3;cons.gridwidth = 1;cons.gridheight = 1;jlabel lblemployeedate = new jlabel(雇用日期:);this.add( lblemployeedate, cons);cons.gridx = 1;cons.gridy = 3;cons.gridwidth = 1;cons.gridheight = 1;txtemployeedate = new jtextfield(10);this.add( txtemployeedate, cons);cons.gridx = 2;cons.gridy = 3;cons.gridwidth = 1;cons.gridheight = 1;jlabel lblemployeejob = new jlabel(从事工作:);this.add( lblemployeejob, cons);cons.gridx = 3;cons.gridy = 3;cons.gridwidth = 1;cons.gridheight = 1;txtemployeejob = new jtextfield(10);this.add( txtemployeejob, cons);cons.gridx = 0;cons.gridy = 4;cons.gridwidth = 1;cons.gridheight = 1;jlabel lblmanagerid = new jlabel(主管编号:);this.add( lblmanagerid, cons);cons.gridx = 1;cons.gridy = 4;cons.gridwidth = 1;cons.gridheight = 1;txtmanagerid = new jtextfield(10);this.add( txtmanagerid, cons);cons.gridx = 2;cons.gridy = 4;cons.gridwidth = 1;cons.gridheight = 1;jlabel lbldepartmentid = new jlabel(部门编号:);this.add( lbldepartmentid, cons);cons.gridx = 3;cons.gridy = 4;cons.gridwidth = 1;cons.gridheight = 1;txtdepartmentid = new jtextfield(10);this.add( txtdepartmentid, cons);cons.gridx = 0;cons.gridy = 5;cons.gridwidth = 1;cons.gridheight = 1;jlabel lblsalary = new jlabel(薪水:);this.add( lblsalary , cons);cons.gridx = 1;cons.gridy = 5;cons.gridwidth = 1;cons.gridheight = 1;txtsalary = new jtextfield(10);txtsalary.seteditable(false);this.add( txtsalary , cons);cons.gridx = 0;cons.gridy = 6;cons.gridwidth = 1;cons.gridheight = 1;rdbpromote = new checkbox(提升工资);this.add( rdbpromote,cons );cons.gridx = 1;cons.gridy = 6;cons.gridwidth = 1;cons.gridheight = 1;rdbdemote = new checkbox(降低工资);this.add(rdbdemote,cons);chkgroup = new checkboxgroup();rdbpromote.setcheckboxgroup( chkgroup );rdbdemote.setcheckboxgroup( chkgroup );chkgroup.setselectedcheckbox( null );cons.gridx = 2;cons.gridy = 6;cons.gridwidth = 1;cons.gridheight = 1;jlabel lblgrade = new jlabel(变动等级:);this.add(lblgrade,cons);cons.gridx = 3;cons.gridy = 6;cons.gridwidth = 1;cons.gridheight = 1;cmbbox = new jcombobox(new string,一级,二级,三级);this.add( cmbbox, cons);/当下拉列表框选项内容发生变化时,调 /用displaysalary函数,正确显示当前设 /定的薪水数目cmbbox.addactionlistener( new actionlistener()public void actionperformed(actionevent e)displaysalary(););cons.gridx = 0;cons.gridy = 7;cons.gridwidth = 1;cons.gridheight = 1;jbutton btnsubmit = new jbutton(提交);this.add( btnsubmit, cons);/注册事件,处理提交情况btnsubmit.setactioncommand(submit);btnsubmit.addactionlistener( new actionlistener()/suppresswarnings(unchecked)public void actionperformed(actionevent e)if( e.getactioncommand().equals(submit) )/读取数据并保存if( txtemployee_id.gettext().equals() = false)employee emp = new employee();/显示雇员的相关信息emp.setemployee_id( integer.parseint( txtemployee_id.gettext() ) );emp.setfirstname( txtfirstname.gettext() );emp.setlastname( txtlastname.gettext() );emp.setemail( txtemail.gettext() );emp.setphone_number( txttel.gettext() );emp.setjob_id( txtemployeejob.gettext() );emp.setsalary( float.parsefloat(txtsalary.gettext();emp.setmanager_id( integer.parseint(txtmanagerid.gettext() );emp.setdepartment_id( txtdepartmentid.gettext() );emplist.setelementat( emp, displayui.currentposition);/向数据库中保存记录boolean iret= (employee)(emplist.elementat( displayui.currentposition ).updateemployeeinfo();if( iret = true)joptionpane.showmessagedialog(null, 更新成功, 正确, joptionpane.information_message);elsejoptionpane.showmessagedialog(null, 更新失败, 错误, joptionpane.error_message);elsejoptionpane.showmessagedialog(null,更新失败,错误,joptionpane.error_message););cons.gridx = 1;cons.gridy = 7;cons.gridwidth = 1;cons.gridheight = 1;jbutton btnprex = new jbutton(前一条);this.add( btnprex, cons);/注册事件btnprex.setactioncommand(prexrecord);btnprex.addactionlistener( new actionlistener()public void actionperformed(actionevent e)if( e.getactioncommand().equals(prexrecord) )if( displayui.emplist = null | displayui.emplist.size() = 0 )return;/注意,在实现记录查阅的时,要考虑到第一条记录和最后一条记录的情形。这里如果/当前是第一条记录。则前一条记录自动跳到最后一条记录:而最后一条记录的下一条/就是第一条记录。因此,把emplist看成是一个循环队列。/前一个位置int position = (displayui.currentposition - 1 + displayui.emplist.size() % (displayui.emplist.size();displayui.currentposition = position;/system.out.println(current postioin : + displayui.currentposition);displaydataonui( (employee)(displayui.emplist.elementat( displayui.currentposition );chkgroup.setselectedcheckbox( null );cmbbox.setselectedindex(0););cons.gridx = 2;cons.gridy = 7;cons.gridwidth = 1;cons.gridheight = 1;jbutton btnnext = new jbutton(下一条);this.add( btnnext, cons);/注册事件btnnext.setactioncommand(nextrecord);btnnext.addactionlistener( new actionlistener()public void actionperformed(actionevent e)if( displayui.emplist = null | displayui.emplist.size() 0)employee emp = (employee)this.emplist.elementat(0);this.txtemployee_id.settext( integer.tostring( emp.getemployee_id() );this.txtfirstname.settext( ( emp.getfirstname() );this.txtlastname.settext( emp.getlastname() );this.txtemail.settext( emp.getemail() );this.txttel.settext( emp.getphone_number() );this.txtemployeedate.settext( emp.gethire_date().tostring() );this.txtemployeejob.settext( emp.getjob_id() );this.txtsalary.settext( float.tostring( emp.getsalary();this.txtmanagerid.settext( integer.tostring(emp.getmanager_id();this.txtdepartmentid.settext( emp.getdepartment_id();private void displaydataonui(employee emp)this.txtemployee_id.settext( integer.tostring( emp.getemployee_id() );this.txtfirstname.settext( ( emp.getfirstname() );this.txtlastname.settext( emp.getlastname() );this.txtemail.settext( emp.getemail() );this.txttel.settext( emp.getphone_number().tolowercase() );this.txtemployeedate.settext( emp.gethire_date() );this.txtemployeejob.settext( emp.getjob_id() );this.txtsalary.settext( float.tostring( emp.getsalary();this.txtmanagerid.settext( integer.tostring(emp.getmanager_id();this.txtdepartmentid.settext( emp.getdepartment_id();private void displaysalary()if( chkgroup.getselectedcheckbox() = rdbpromote & cmbbox.getselectedindex() 0 ) /升薪(employee)emplist.elementat(displayui.currentposition).promotesalary( cmbbox.getselectedindex() - 1 );/显示txtsalary.settext( float.tostring(employee)emplist.elementat(displayui.currentposition).getsalary() );if( chkgroup.getselectedcheckbox() = rdbdemote & cmbbox.getselectedindex() 0)/降薪(employee)emplist.elementat(displayui.currentposition).demotesalary( cmbbox.getselectedindex() - 1);/显示txtsalary.settext( float.tostring(employee)emplist.elementat(displayui.currentposition).getsalary() );/* * param args */最后是main函数,依次调用addcontroltopane函数,对整个界面进行布局,然后执行/fillemplist函数,在此函数中,会调用业务层的功能,提取雇员的信息记录,最后/将提取出来的数据显示在界面上,这是通过initdisplaydata函数实现的。public static void main(string args) / todo auto-generated method stubdisplayui ui = new displayui();ui.addcontroltopane();ui.fillemplist();ui.initdisplaydata();4.3 雇员信息管理业务层的设计package records;import accessdb.*; public class employee private int employee_id;private string fistname;private string lastname;private string email;private string phone_number;private string hire_date;private string job_id;private float salary = 0;private string department_id;private int manager_id;private boolean hired = false;public int getemployee_id() return employee_id;public void setemployee_id(int employee_id) employee_id = employee_id;public void setfirstname(string fn)this.fistname = fn;public string getfirstname()if( this.fistname = null )return null;return this.fistname;public void setlastname(string ln)this.lastname = ln;public string getlastname()if( this.lastname = null )return null;return this.lastname;public string getemail() if( this.email = null )return null;return email;public void setemail(string email) email = email;public string getphone_number() if( phone_number = null )return ;return phone_number;public void setphone_number(string phone_number) phone_number = phone_number;public string gethire_date() return this.hire_date;public void sethire_date(string hire_date) hire_date = hire_date;public string getjob_id() return job_id;public void setjob_id(string job_id) job_id = job_id;/* * author administrator * param salary 设置薪水数目 * return bool 设置成功返回true,否则返回false */public boolean setsalary(float salary)if( salary 0 )this.salary = salary;return true;elsethis.salary = 0;return false;/* * author administrator * return 获取薪水数目 */public float getsalary()if( this.salary = 0 )return this.salary;elsereturn 0;public string getdepartment_id() return department_id;public void setdepartment_id(string department_id) department_id = department_id;public int getmanager_id() return manager_id;public void setmanager_id(int manager_id) manager_id = manager_id;/* * author administrator * param * return * 设置员工被雇佣状态 */public void hire()if( this.hired = false )this.hired = true;return;/* * author administrator * param * return * 设置员工被解雇状态 */public void fire()if( this.hired = true )this.hired = false;return;/* * author administrator * param degree 为员工提升薪水,根据提升等级加薪 */public void promotesalary(int degree)switch(degree)case -1:break;case promotedegree.promoteleve0:this.salary = this.getsalary()+100;break;case promotedegree.promoteleve1:this.salary = this.getsalary()+ 500;break;case promotedegree.promoteleve2:this.salary = this.getsalary() + 1000;break;default:break;/* * author administrator * param degree 根据员工的违规等级扣薪水 */public void demotesalary(int degree)switch(degree)case -1:break;case demotedegree.demotelevel0:if( this.getsalary() = 100.0 )this.salary = 0;elsethis.salary = this.getsalary() - 100;break;case demotedegree.demotelevel1:if( this.getsalary() = 500.0 )this.salary = 0;elsethis.salary = this.getsalary()- 500;break;case demotedegree.demotelevel2:if( this.getsalary() = 1000.0 )this.salary = 0;elsethis.salary = this.getsalary() - 1000;break;default:break;public boolean updateemployeeinfo()string updatesql = update employees + set first_name= + this.fistname + , last_name =+ this.lastname +, email= + this.email + , phone_number = + this.phone_number + , job_id= + this.job_id + , salary= + this.sala

温馨提示

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

评论

0/150

提交评论