JAVA课程设计-员工信息管理系统Word版.doc

上传人:rrsccc 文档编号:11042178 上传时间:2021-06-21 格式:DOC 页数:31 大小:246.50KB
返回 下载 相关 举报
JAVA课程设计-员工信息管理系统Word版.doc_第1页
第1页 / 共31页
JAVA课程设计-员工信息管理系统Word版.doc_第2页
第2页 / 共31页
JAVA课程设计-员工信息管理系统Word版.doc_第3页
第3页 / 共31页
JAVA课程设计-员工信息管理系统Word版.doc_第4页
第4页 / 共31页
JAVA课程设计-员工信息管理系统Word版.doc_第5页
第5页 / 共31页
点击查看更多>>
资源描述

《JAVA课程设计-员工信息管理系统Word版.doc》由会员分享,可在线阅读,更多相关《JAVA课程设计-员工信息管理系统Word版.doc(31页珍藏版)》请在三一文库上搜索。

1、传播优秀Word版文档 ,希望对您有帮助,可双击去除!课程设计(论文)任务书学 院理学院专 业信息与计算科学学生姓名班级学号0809010223课程名称JAVA程序设计课程设计课程设计(论文)题目员工信息管理系统设计题目:使用JAVA语言及Eclipse开发工具设计并实现员工信息管理系统。设计任务:1、设计一个员工管理系统2、利用图形用户界面实现程序的运行3、实现员工信息的添加、删除、查询、和修改等功能4、应用文件的相关知识来完成计划与进度安排:十七周:周一、周四选题进行程序的设计十八周:周一设计的辅导;周四课程设计检查答辩成绩:指导教师(签字): 2010年7月8日 专业负责人(签字):20

2、10年7月18日主管院长(签字): 2010年7月19日摘 要JAVA不仅是一门最为流行的计算机语言,而且已经形成一种专门的技术,带来了20世纪末和本世纪初网络科技和网络经济超常发展。JAVA的与平台无关性、高可靠性、安全机制和内嵌网络支持等特性使它成为编写网络应用程序的首选工具之一。从另一方面来看,软件开发的规模也日渐扩大,对软件质量的要求越来越高,与之相对应的是,各种软件技术和工具层出不穷,各种软件开发、软件质量控制、软件管理法方法学业日渐成熟。面对软件发展的这一现状和趋势,无论是拥有计算机基础知识的学生还是IT领域的起步者,熟练掌握一门语言都是至关重要的。JAVA是一个面向对象的程序设计

3、软件,它将重点放在数据和对象的接口上,与C+相比的主要不同在于多继承,在JAVA中,取而代之的是简单的接口,以及JAVA的元类模型。这也很大程度上给我们初学编程的人带来很呆的方便,也使我们更容易掌握JAVA编程的一些基本要领和深层知识。该程序是利用文件来实现的,程序的重要作用是对员工信息进行管理,包括员工信息的添加、查询、修改、删除。通过该课程设计,使同学们进一步理解概JAVA的基本概念、理论和方法,初步掌握JDK、Eclipse的调试和应用,以及程序中错误的解决方法,明确JAVA在实际程序设计中的应用。使课堂中学习到理论得到应用,练习文件形式在JAVA程序设计中的应用。关键词:面向对象、软件

4、开发、继承、员工管理目 录1 设计目的12 设计问题13 概要设计14 详细设计14.1 定义员工类14.2 主程序34.3 实现员工信息的录入64.4 实现员工信息的修改114.5 实现员工信息的查询184.6 实现员工信息的删除225 设计总结26参考文献27致 谢27员工管理系统一、设计目的通过该课程设计,使同学们进一步理解概JAVA的基本概念、理论和方法,初步掌握JDK、Eclipse的调试和应用,以及程序中错误的解决方法,明确JAVA在实际程序设计中的应用。使课堂中学习到理论得到应用,练习文件形式在JAVA程序设计中的应用。二、设计问题设计题目:员工管理系统设计要求:(1)完成员工信

5、息的添加、删除、查询、修改功能(2)使用用户界面操作(3)使用文件形式完成设计思路:首先设计界面进入面板,在面板中添加菜单选项,并将要实现的功能选项添加其中,然后对这些选项实施监听,实现其功能。通过文件类型知识的应用,实现对员工信息的管理。三、概要设计面板设计:首先设计一个容器,然后再容器中添加菜单,在菜单中添加选项,并在容器中加入面板,面板布局设置为CardLayout,最后将面板添加进容器。功能实现:在录入、查询、修改和删除界面中使用JButton、JLabel、ButtonGroup、JRadioButton、JTextField、Choice为界面中加入相应的组件,并对其进行监听,同时

6、附加了文件流的处理。四、详细设计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) this.name=name; public Str

7、ing 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

8、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 ActionListenerEmploy

9、eeSituation 基本信息录入=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 JMenuI

10、tem(录入员工基本信息); 修改=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);

11、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

12、.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) 基本信息录入=ne

13、w 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 Win

14、dowAdapter() 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()=查询) 基本信息

15、查询.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

16、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 EmployeeSitu

17、ation(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(女); 录入=ne

18、w 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.createHorizont

19、alBox(); 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(工资:,J

20、Label.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 BorderL

21、ayout(); 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.lengt

22、h()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_ME

23、SSAGE); 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() s

24、ex=男.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.clo

25、se(); 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(部门.g

26、etSelectedIndex(); 工资.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

27、 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(研发部);部

28、门.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); 开始修改.addAc

29、tionListener(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.cre

30、ateHorizontalBox(); 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 J

31、Label(工资:,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(

32、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=

33、员工号.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(

34、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

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

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1