JAVA課程設(shè)計(jì)員工信息管理系統(tǒng)_第1頁
JAVA課程設(shè)計(jì)員工信息管理系統(tǒng)_第2頁
JAVA課程設(shè)計(jì)員工信息管理系統(tǒng)_第3頁
JAVA課程設(shè)計(jì)員工信息管理系統(tǒng)_第4頁
JAVA課程設(shè)計(jì)員工信息管理系統(tǒng)_第5頁
已閱讀5頁,還剩25頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、課程設(shè)計(jì)(論文)任務(wù)書學(xué) 院理學(xué)院專 業(yè)信息與計(jì)算科學(xué)學(xué)生姓名班級學(xué)號0809010223課程名稱java程序設(shè)計(jì)課程設(shè)計(jì)課程設(shè)計(jì)(論文)題目員工信息管理系統(tǒng)設(shè)計(jì)題目:使用java語言及eclipse開發(fā)工具設(shè)計(jì)并實(shí)現(xiàn)員工信息管理系統(tǒng)。設(shè)計(jì)任務(wù):1、設(shè)計(jì)一個(gè)員工管理系統(tǒng)2、利用圖形用戶界面實(shí)現(xiàn)程序的運(yùn)行3、實(shí)現(xiàn)員工信息的添加、刪除、查詢、和修改等功能4、應(yīng)用文件的相關(guān)知識來完成計(jì)劃與進(jìn)度安排:十七周:周一、周四選題進(jìn)行程序的設(shè)計(jì)十八周:周一設(shè)計(jì)的輔導(dǎo);周四課程設(shè)計(jì)檢查答辯成績:指導(dǎo)教師(簽字): 2010年7月8日 專業(yè)負(fù)責(zé)人(簽字):2010年7月18日主管院長(簽字): 2010年7月19

2、日摘 要java不僅是一門最為流行的計(jì)算機(jī)語言,而且已經(jīng)形成一種專門的技術(shù),帶來了20世紀(jì)末和本世紀(jì)初網(wǎng)絡(luò)科技和網(wǎng)絡(luò)經(jīng)濟(jì)超常發(fā)展。java的與平臺無關(guān)性、高可靠性、安全機(jī)制和內(nèi)嵌網(wǎng)絡(luò)支持等特性使它成為編寫網(wǎng)絡(luò)應(yīng)用程序的首選工具之一。從另一方面來看,軟件開發(fā)的規(guī)模也日漸擴(kuò)大,對軟件質(zhì)量的要求越來越高,與之相對應(yīng)的是,各種軟件技術(shù)和工具層出不窮,各種軟件開發(fā)、軟件質(zhì)量控制、軟件管理法方法學(xué)業(yè)日漸成熟。面對軟件發(fā)展的這一現(xiàn)狀和趨勢,無論是擁有計(jì)算機(jī)基礎(chǔ)知識的學(xué)生還是it領(lǐng)域的起步者,熟練掌握一門語言都是至關(guān)重要的。java是一個(gè)面向?qū)ο蟮某绦蛟O(shè)計(jì)軟件,它將重點(diǎn)放在數(shù)據(jù)和對象的接口上,與c+相比的主要

3、不同在于多繼承,在java中,取而代之的是簡單的接口,以及java的元類模型。這也很大程度上給我們初學(xué)編程的人帶來很呆的方便,也使我們更容易掌握java編程的一些基本要領(lǐng)和深層知識。該程序是利用文件來實(shí)現(xiàn)的,程序的重要作用是對員工信息進(jìn)行管理,包括員工信息的添加、查詢、修改、刪除。通過該課程設(shè)計(jì),使同學(xué)們進(jìn)一步理解概java的基本概念、理論和方法,初步掌握jdk、eclipse的調(diào)試和應(yīng)用,以及程序中錯誤的解決方法,明確java在實(shí)際程序設(shè)計(jì)中的應(yīng)用。使課堂中學(xué)習(xí)到理論得到應(yīng)用,練習(xí)文件形式在java程序設(shè)計(jì)中的應(yīng)用。關(guān)鍵詞:面向?qū)ο?、軟件開發(fā)、繼承、員工管理目 錄1 設(shè)計(jì)目的12 設(shè)計(jì)問題1

4、3 概要設(shè)計(jì)14 詳細(xì)設(shè)計(jì)14.1 定義員工類14.2 主程序34.3 實(shí)現(xiàn)員工信息的錄入64.4 實(shí)現(xiàn)員工信息的修改114.5 實(shí)現(xiàn)員工信息的查詢184.6 實(shí)現(xiàn)員工信息的刪除225 設(shè)計(jì)總結(jié)26參考文獻(xiàn)27致 謝27員工管理系統(tǒng)一、設(shè)計(jì)目的通過該課程設(shè)計(jì),使同學(xué)們進(jìn)一步理解概java的基本概念、理論和方法,初步掌握jdk、eclipse的調(diào)試和應(yīng)用,以及程序中錯誤的解決方法,明確java在實(shí)際程序設(shè)計(jì)中的應(yīng)用。使課堂中學(xué)習(xí)到理論得到應(yīng)用,練習(xí)文件形式在java程序設(shè)計(jì)中的應(yīng)用。二、設(shè)計(jì)問題設(shè)計(jì)題目:員工管理系統(tǒng)設(shè)計(jì)要求:(1)完成員工信息的添加、刪除、查詢、修改功能(2)使用用戶界面操作(

5、3)使用文件形式完成設(shè)計(jì)思路:首先設(shè)計(jì)界面進(jìn)入面板,在面板中添加菜單選項(xiàng),并將要實(shí)現(xiàn)的功能選項(xiàng)添加其中,然后對這些選項(xiàng)實(shí)施監(jiān)聽,實(shí)現(xiàn)其功能。通過文件類型知識的應(yīng)用,實(shí)現(xiàn)對員工信息的管理。三、概要設(shè)計(jì)面板設(shè)計(jì):首先設(shè)計(jì)一個(gè)容器,然后再容器中添加菜單,在菜單中添加選項(xiàng),并在容器中加入面板,面板布局設(shè)置為cardlayout,最后將面板添加進(jìn)容器。功能實(shí)現(xiàn):在錄入、查詢、修改和刪除界面中使用jbutton、jlabel、buttongroup、jradiobutton、jtextfield、choice為界面中加入相應(yīng)的組件,并對其進(jìn)行監(jiān)聽,同時(shí)附加了文件流的處理。四、詳細(xì)設(shè)計(jì)1、定義員工類:pub

6、lic 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;

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

8、rth; 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; mo

9、difysituation 基本信息修改=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 jmenu

10、item(修改員工基本信息); 查詢=new jmenuitem(查詢員工基本信息); 刪除=new jmenuitem(刪除員工基本信息); bar=new jmenubar(); filemenu=new jmenu(菜單選項(xiàng)); filemenu.add(錄入); filemenu.add(修改); filemenu.add(查詢); filemenu.add(刪除); bar.add(filemenu); setjmenubar(bar); label=new jlabel(歡迎進(jìn)入員工信息管理系統(tǒng),jlabel.center); label.setfont(new font(sans

11、serif,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.s

12、etbackground(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);

13、基本信息修改=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 wi

14、ndowclosing(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 i

15、f(e.getsource()=刪除) card.show(pcenter,刪除界面); public static void main(string args) new employeemanager(); 3、實(shí)現(xiàn)員工信息的錄入:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.*;public class employeesituation extends jpanel implements actionlistener hashtable 基本

16、信息表=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=

17、file; 員工號=new jtextfield(10); 姓名=new jtextfield(10); 部門=new choice(); 部門.add(請選擇); 部門.add(研發(fā)部); 部門.add(銷售部); 部門.add(人事部); 部門.add(安全部); 工資=new jtextfield(10); group=new buttongroup(); 男=new jradiobutton(男,true); 女=new jradiobutton(女,false); group.add(男); group.add(女); 錄入=new jbutton(錄入); 重置=new jbutt

18、on(重置); 錄入.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 jlabe

19、l(性別:,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(工資)

20、; 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,border

21、layout.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 fileinp

22、utstream(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=基本信息將

23、被錄入!; int ok=joptionpane.showconfirmdialog(this,m,確認(rèn),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=女.

24、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(); 員工號.s

25、ettext(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(); 工資.sette

26、xt(null); 4、實(shí)現(xiàn)員工信息的修改: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 開始修改,錄入

27、修改,重置;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(研發(fā)部);部門.add(銷售部);部門.add(人事部);部門.a

28、dd(安全部); 工資=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); 錄入修改.ad

29、dactionlistener(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.ad

30、d(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); b

31、ox5.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(pce

32、nter,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.len

33、gth()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(); 部門.getselect

34、editem(); 工資.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(部門.getselecte

35、ditem(); 工資.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=員工號.g

36、ettext();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,que

37、stion,警告,joptionpane.question_message); string m=基本信息將被修改!; int ok=joptionpane.showconfirmdialog(this,m,確認(rèn),joptionpane.yes_no_option, joptionpane.information_message); if(ok=joptionpane.yes_option) string name=姓名.gettext(); string discipling=部門.getselecteditem(); string grade=工資.gettext(); string se

38、x=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,員工); o

39、uttwo.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_message

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論