JAVA课程设计--员工信息管理系统.doc_第1页
JAVA课程设计--员工信息管理系统.doc_第2页
JAVA课程设计--员工信息管理系统.doc_第3页
JAVA课程设计--员工信息管理系统.doc_第4页
JAVA课程设计--员工信息管理系统.doc_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

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

文档简介

课程设计(论文)任务书学 院理学院专 业信息与计算科学学生姓名班级学号0809010223课程名称java程序设计课程设计课程设计(论文)题目员工信息管理系统设计题目:使用java语言及eclipse开发工具设计并实现员工信息管理系统。设计任务:1、设计一个员工管理系统2、利用图形用户界面实现程序的运行3、实现员工信息的添加、删除、查询、和修改等功能4、应用文件的相关知识来完成计划与进度安排:十七周:周一、周四选题进行程序的设计十八周:周一设计的辅导;周四课程设计检查答辩成绩:指导教师(签字): 2010年7月8日 专业负责人(签字):2010年7月18日主管院长(签字): 2010年7月19日摘 要java不仅是一门最为流行的计算机语言,而且已经形成一种专门的技术,带来了20世纪末和本世纪初网络科技和网络经济超常发展。java的与平台无关性、高可靠性、安全机制和内嵌网络支持等特性使它成为编写网络应用程序的首选工具之一。从另一方面来看,软件开发的规模也日渐扩大,对软件质量的要求越来越高,与之相对应的是,各种软件技术和工具层出不穷,各种软件开发、软件质量控制、软件管理法方法学业日渐成熟。面对软件发展的这一现状和趋势,无论是拥有计算机基础知识的学生还是it领域的起步者,熟练掌握一门语言都是至关重要的。java是一个面向对象的程序设计软件,它将重点放在数据和对象的接口上,与c+相比的主要不同在于多继承,在java中,取而代之的是简单的接口,以及java的元类模型。这也很大程度上给我们初学编程的人带来很呆的方便,也使我们更容易掌握java编程的一些基本要领和深层知识。该程序是利用文件来实现的,程序的重要作用是对员工信息进行管理,包括员工信息的添加、查询、修改、删除。通过该课程设计,使同学们进一步理解概java的基本概念、理论和方法,初步掌握jdk、eclipse的调试和应用,以及程序中错误的解决方法,明确java在实际程序设计中的应用。使课堂中学习到理论得到应用,练习文件形式在java程序设计中的应用。关键词:面向对象、软件开发、继承、员工管理目 录1 设计目的12 设计问题13 概要设计14 详细设计14.1 定义员工类14.2 主程序34.3 实现员工信息的录入64.4 实现员工信息的修改114.5 实现员工信息的查询184.6 实现员工信息的删除225 设计总结26参考文献27致 谢2730员工管理系统一、设计目的通过该课程设计,使同学们进一步理解概java的基本概念、理论和方法,初步掌握jdk、eclipse的调试和应用,以及程序中错误的解决方法,明确java在实际程序设计中的应用。使课堂中学习到理论得到应用,练习文件形式在java程序设计中的应用。二、设计问题设计题目:员工管理系统设计要求:(1)完成员工信息的添加、删除、查询、修改功能(2)使用用户界面操作(3)使用文件形式完成设计思路:首先设计界面进入面板,在面板中添加菜单选项,并将要实现的功能选项添加其中,然后对这些选项实施监听,实现其功能。通过文件类型知识的应用,实现对员工信息的管理。三、概要设计面板设计:首先设计一个容器,然后再容器中添加菜单,在菜单中添加选项,并在容器中加入面板,面板布局设置为cardlayout,最后将面板添加进容器。功能实现:在录入、查询、修改和删除界面中使用jbutton、jlabel、buttongroup、jradiobutton、jtextfield、choice为界面中加入相应的组件,并对其进行监听,同时附加了文件流的处理。四、详细设计1、定义员工类:public class employee implements java.io.serializable string number,name,discipling,grade,borth,sex; public employee() public void setnumber(string number) this.number=number; public string getnumber() return number; public void setname(string name) =name; public string getname() return name; public void setdiscipling(string discipling) this.discipling=discipling; public string getdisciping() return discipling; public void setgrade(string grade) this.grade=grade; public string getgrade() return grade; public void setborth(string borth) this.borth=borth; public string getborth() return borth; public void setsex(string sex) this.sex=sex; public string getsex() return sex; 2、主程序:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.hashtable;public class employeemanager extends jframe implements actionlisteneremployeesituation 基本信息录入=null; modifysituation 基本信息修改=null; inquest 基本信息查询=null; delete 基本信息删除=null; jmenubar bar; jmenu filemenu; jmenuitem 录入,修改,查询,删除; container con=null; hashtable 基本信息=null; file file=null; cardlayout card=null; jlabel label=null; jpanel pcenter; public employeemanager() 录入=new jmenuitem(录入员工基本信息); 修改=new jmenuitem(修改员工基本信息); 查询=new jmenuitem(查询员工基本信息); 删除=new jmenuitem(删除员工基本信息); bar=new jmenubar(); filemenu=new jmenu(菜单选项); filemenu.add(录入); filemenu.add(修改); filemenu.add(查询); filemenu.add(删除); bar.add(filemenu); setjmenubar(bar); label=new jlabel(欢迎进入员工信息管理系统,jlabel.center); label.setfont(new font(sansserif,font.bold+font.italic,25); label.setforeground(color.red); 基本信息=new hashtable(); 录入.addactionlistener(this); 修改.addactionlistener(this); 查询.addactionlistener(this); 删除.addactionlistener(this); card=new cardlayout(); con=getcontentpane(); pcenter=new jpanel(); pcenter.setlayout(card); pcenter.setbackground(color.yellow); file=new file(基本信息.txt); if(!file.exists() try fileoutputstream out=new fileoutputstream(file); objectoutputstream objectout=new objectoutputstream(out); objectout.writeobject(基本信息); objectout.close(); out.close(); catch(ioexception e) 基本信息录入=new employeesituation(file); 基本信息修改=new modifysituation(file); 基本信息查询=new inquest(this,file); 基本信息删除=new delete(file); pcenter.add(欢迎语界面,label); pcenter.add(录入界面,基本信息录入); pcenter.add(修改界面,基本信息修改); pcenter.add(删除界面,基本信息删除); con.add(pcenter,borderlayout.center); con.validate(); addwindowlistener(new windowadapter() public void windowclosing(windowevent e) system.exit(0); ); setvisible(true); setbounds(100,50,420,380); validate(); public void actionperformed(actionevent e) if(e.getsource()=录入) card.show(pcenter,录入界面); else if(e.getsource()=修改) card.show(pcenter,修改界面); else if(e.getsource()=查询) 基本信息查询.setvisible(true); else if(e.getsource()=删除) card.show(pcenter,删除界面); public static void main(string args) new employeemanager(); 3、实现员工信息的录入:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.*;public class employeesituation extends jpanel implements actionlistener hashtable 基本信息表=null; jtextfield 员工号,姓名,工资; choice 部门; jradiobutton 男,女; employee 员工=null; buttongroup group=null; jbutton 录入,重置; fileinputstream inone=null; objectinputstream intwo=null; fileoutputstream outone=null; objectoutputstream outtwo=null; file file=null; public employeesituation(file file) this.file=file; 员工号=new jtextfield(10); 姓名=new jtextfield(10); 部门=new choice(); 部门.add(请选择); 部门.add(研发部); 部门.add(销售部); 部门.add(人事部); 部门.add(安全部); 工资=new jtextfield(10); group=new buttongroup(); 男=new jradiobutton(男,true); 女=new jradiobutton(女,false); group.add(男); group.add(女); 录入=new jbutton(录入); 重置=new jbutton(重置); 录入.addactionlistener(this); 重置.addactionlistener(this); box box1=box.createhorizontalbox(); box1.add(new jlabel(员工号:,jlabel.center); box1.add(员工号); box box2=box.createhorizontalbox(); box2.add(new jlabel(姓名:,jlabel.center); box2.add(姓名); box box3=box.createhorizontalbox(); box3.add(new jlabel(性别:,jlabel.center); box3.add(男); box3.add(女); box box4=box.createhorizontalbox(); box4.add(new jlabel(部门:,jlabel.center); box4.add(部门); box box6=box.createhorizontalbox(); box6.add(new jlabel( ,jlabel.center); box box5=box.createhorizontalbox(); box5.add(new jlabel(工资:,jlabel.center); box5.add(工资); box boxh=box.createverticalbox(); boxh.add(box1); boxh.add(box2); boxh.add(box3); boxh.add(box5); boxh.add(box6); boxh.add(box4); boxh.add(box.createverticalglue(); jpanel pcenter=new jpanel(); pcenter.add(boxh); pcenter.setbackground(color.yellow); setlayout(new borderlayout(); add(pcenter,borderlayout.center); jpanel psouth=new jpanel(); psouth.add(录入); psouth.add(重置); psouth.setbackground(color.yellow); add(psouth,borderlayout.south); validate(); public void actionperformed(actionevent e) if(e.getsource()=录入) string number=; number=员工号.gettext(); if(number.length()0) try inone=new fileinputstream(file); intwo=new objectinputstream(inone); 基本信息表=(hashtable)intwo.readobject(); inone.close(); intwo.close(); catch(exception ee) if(基本信息表.containskey(number) string warning=该员工基本信息已存在,请到修改页面修改!; joptionpane.showmessagedialog(this,warning,警告,joptionpane.warning_message); else string m=基本信息将被录入!; int ok=joptionpane.showconfirmdialog(this,m,确认,joptionpane.yes_no_option, joptionpane.information_message); if(ok=joptionpane.yes_option) string name=姓名.gettext(); string discipling=部门.getselecteditem(); string grade=工资.gettext(); string sex=null; if(男.isselected() sex=男.gettext(); else sex=女.gettext(); 员工=new employee(); 员工.setnumber(number); 员工.setname(name); 员工.setdiscipling(discipling); 员工.setgrade(grade); 员工.setsex(sex); try outone=new fileoutputstream(file); outtwo=new objectoutputstream(outone); 基本信息表.put(number,员工); outtwo.writeobject(基本信息表); outtwo.close(); outone.close(); 员工号.settext(null); 姓名.settext(null); 工资.settext(null); catch(exception ee) system.out.println(ee); else string warning=必须要输入员工号!; joptionpane.showmessagedialog(this,warning,警告,joptionpane.warning_message); if(e.getsource()=重置) 员工号.settext(null); 姓名.settext(null); 部门.remove(部门.getselectedindex(); 工资.settext(null); 4、实现员工信息的修改:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.*;public class modifysituation extends jpanel implements actionlistener hashtable 基本信息表=null; jtextfield 员工号,姓名,工资; choice 部门;jradiobutton 男,女;buttongroup group=null;jbutton 开始修改,录入修改,重置;fileinputstream inone=null;objectinputstream intwo=null;fileoutputstream outone=null;objectoutputstream outtwo=null;file file=null; public modifysituation(file file)this.file=file;员工号=new jtextfield(10);姓名=new jtextfield(10); 部门=new choice();部门.add(请选择);部门.add(研发部);部门.add(销售部);部门.add(人事部);部门.add(安全部); 工资=new jtextfield(10); group=new buttongroup(); 男=new jradiobutton(男,true); 女=new jradiobutton(女,false); group.add(男); group.add(女); 开始修改=new jbutton(开始修改); 录入修改=new jbutton(录入修改); 录入修改.setenabled(false); 重置=new jbutton(重置); 员工号.addactionlistener(this); 开始修改.addactionlistener(this); 录入修改.addactionlistener(this); 重置.addactionlistener(this); box box1=box.createhorizontalbox(); box1.add(new jlabel(输入要修改信息的员工号:,jlabel.center); box1.add(员工号); box1.add(开始修改); box box2=box.createhorizontalbox(); box2.add(new jlabel(姓名:,jlabel.center); box2.add(姓名); box box3=box.createhorizontalbox(); box3.add(new jlabel(性别:,jlabel.center); box3.add(男); box3.add(女); box box4=box.createhorizontalbox(); box4.add(new jlabel(部门:,jlabel.center); box4.add(部门); box box6=box.createhorizontalbox(); box6.add(new jlabel( ,jlabel.center); box box5=box.createhorizontalbox(); box5.add(new jlabel(工资:,jlabel.center); box5.add(工资); box boxh=box.createverticalbox(); boxh.add(box1); boxh.add(box2); boxh.add(box3); boxh.add(box5); boxh.add(box6); boxh.add(box4); boxh.add(box.createverticalglue(); jpanel pcenter=new jpanel(); pcenter.add(boxh); pcenter.setbackground(color.yellow); setlayout(new borderlayout(); add(pcenter,borderlayout.center); jpanel psouth=new jpanel(); psouth.add(录入修改); psouth.add(重置); psouth.setbackground(color.yellow); add(psouth,borderlayout.south); validate();public void actionperformed(actionevent e) if(e.getsource()=开始修改|e.getsource()=员工号)string number=;number=员工号.gettext();if(number.length()0) try inone=new fileinputstream(file); intwo=new objectinputstream(inone); 基本信息表=(hashtable)intwo.readobject(); inone.close(); intwo.close(); catch(exception ee) if(基本信息表.containskey(number) 录入修改.setenabled(true); employee stu=(employee)基本信息表.get(number); 姓名.settext(stu.getname(); 部门.getselecteditem(); 工资.settext(stu.getgrade(); if(stu.getsex().equals(男) 男.setselected(true); else 女.setselected(true); else 录入修改.setenabled(false); string warning=该员工号不存在!; joptionpane.showmessagedialog(this,warning,警告,joptionpane.warning_message); 员工号.settext(null); 姓名.settext(null); 部门.remove(部门.getselecteditem(); 工资.settext(null); else 录入修改.setenabled(false); string warning=必须要输入员工号!; joptionpane.showmessagedialog(this,warning,警告,joptionpane.warning_message); 员工号.settext(null); 姓名.settext(null); 部门.remove(部门.getselecteditem(); 工资.settext(null); else if(e.getsource()=录入修改) string number=;number=员工号.gettext();if(number.length()0)try inone=new fileinputstream(file); intwo=new objectinputstream(inone); 基本信息表=(hashtable)intwo.readobject(); inone.close(); intwo.close(); catch(exception ee) if(基本信息表.containskey(number) string question=该员工基本信息已存在,您想修改他(她)的基本信息吗?; joptionpane.showmessagedialog(this,question,警告,joptionpane.question_message); string m=基本信息将被修改!; int ok=joptionpane.showconfirmdialog(this,m,确认,joptionpane.yes_no_option, joptionpane.information_message); if(ok=joptionpane.yes_option) string name=姓名.gettext(); string discipling=部门.getselecteditem(); string grade=工资.gettext(); string sex=null; if(男.isselected() sex=男.gettext(); else sex=女.gettext(); employee 员工=new employee(); 员工.setnumber(number); 员工.setname(name); 员工.setdiscipling(discipling); 员工.setgrade(grade); 员工.setsex(sex); try outone=new fileoutputstream(file); outtwo=new objectoutputstream(outone); 基本信息表.put(number,员工); outtwo.writeobject(基本信息表); outtwo.close(); outone.close(); 员工号.settext(null); 姓名.settext(null); 部门.remove(部门.getselecteditem(); 工资.settext(null); catch(exception ee) system.out.println(ee); 录入修改.setenabled(false); else if(ok=joptionpane.no_option) 录入修改.setenabled(true); else string warning=该员工号没有基本信息,不能修改!; joptionpane.showmessagedialog(this,warning,警告,joptionpane.warning_mess

温馨提示

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

评论

0/150

提交评论