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頁,還剩13頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、一、設(shè)計(jì)目的 2二、功能介紹 2三、程序流程 2四、設(shè)計(jì)步驟 3五、設(shè)計(jì)總結(jié) 7六、程序清單 8七、參考文獻(xiàn) 17一、設(shè)計(jì)目的通過課程設(shè)計(jì), 使學(xué)生提高理論聯(lián)系實(shí)際解決實(shí)際問題的能力;也使學(xué)生對基于面向?qū)ο蟮睦碚撨M(jìn)行系統(tǒng)設(shè)計(jì)過程中的諸多具體問題有感性的認(rèn)識和深入的理解;進(jìn)而提高學(xué)生的學(xué)習(xí)興趣為其將來順利進(jìn)入畢業(yè)環(huán)節(jié)作必要的準(zhǔn)備。二、功能介紹(1)具有新用戶注冊功能。(2)具有注冊用戶登錄功能。(3)具有職工工資的錄入功能, 要求只錄入工資各項(xiàng), 自動計(jì)算每個(gè)職工工資總額。(4)具有數(shù)據(jù)查詢功能,可以實(shí)現(xiàn)查詢?nèi)啃畔⒑桶礂l件執(zhí)行查詢。(5)具有按條件刪除數(shù)據(jù)功能。三、程序流程四、設(shè)計(jì)步驟4.1、

2、登陸界面進(jìn)入系統(tǒng)首先進(jìn)入登陸界面如圖 4.1,輸入賬號和密碼,點(diǎn)擊登錄就會進(jìn)入職工工資管理系統(tǒng),點(diǎn)擊注冊進(jìn)入新用戶注冊界面,定義了局部變量 String 類型的user,password 和 pass 分別記錄界面輸入的賬號,密碼和數(shù)據(jù)庫查找的密碼,定義了成員變量 boolean 型的 bool 記錄輸入賬號和密碼是否匹配。登陸界面Tirnltx歡迎使用員工工資管理系統(tǒng)麻號:嵬而密碼:*圖 4.1 登陸界面4.2、職工工資管理系統(tǒng)登陸成功后進(jìn)入的界面如圖 4.2,界面有增刪改查的功能。widgetSelected()方法創(chuàng)建button 的點(diǎn)擊事件,創(chuàng)建 DBHelper 類的對象 db 連接

3、數(shù)據(jù)庫,進(jìn)行查找,刪除修改功能,增刪改用 update()方法,查詢用 query()方法。圖 4.2 職工工資管理界面4.3、全部查找功能點(diǎn)擊右邊的查詢按鈕可以查找出所有員工的工資信息如圖 4.3,通過自己封裝的連接數(shù)據(jù)庫的類 DBHelper 類的對象 db,傳遞 sql 語句查找數(shù)據(jù)庫的所有信息,用getString()方法導(dǎo)出從數(shù)據(jù)庫中查找到的數(shù)據(jù),所得工資=基本工資+職位提成-50*遲到天數(shù)-100*曠工天數(shù),通過查找的數(shù)據(jù)和自己定義的公式得到所得工資。4.4、按條件查找功能在文本框中輸入職工號, 點(diǎn)擊查找能找到對應(yīng)職工的工資情況, 如圖 4.4o 用 getText()方法獲得 t

4、ext 文本框中的的輸入信息, 定義局部變量 boolean 型的數(shù)據(jù) bool,記錄數(shù)據(jù)庫中是否有對應(yīng)的職工號,如果查到則為 true,并且在表格中先用 removeAll()方法清空表的信息,然后用 sql 語句找出 text 中的職工號對應(yīng)的數(shù)據(jù)。圖 4.4 按條件查找界面錄入功能點(diǎn)擊錄入鍵進(jìn)入錄入界面如圖 4.5,輸入職工信息,點(diǎn)擊錄入修改數(shù)據(jù)庫的信息,并且能更新查找的結(jié)果。 用 getText()方法獲得 text 文本框的信息, 定義局部變量 String 類型的s1,s2,s3,s4,s5,s6 記錄六個(gè)文本框的信息,通過 DBHelper 的對象db 調(diào)用 update 方法把

5、信息傳入數(shù)據(jù)庫。刪除功能點(diǎn)擊選中行,然后點(diǎn)擊刪除按鈕就會將選種的行刪除掉,例如刪除圖 4.3 中第三行數(shù)據(jù)如圖 4.6。 定義局部變量 TableItem數(shù)組用 table.getSelection()方法查找并存儲選中行的信息,定義 int型數(shù)組用 table.getSelectionIndices()方法查找并存儲選中行的行號,用這兩個(gè)信息分別刪除數(shù)據(jù)庫和界面的選中信息。圖 4.5 錄入功能界面圖 4.6 刪除功能界面注冊功能點(diǎn)擊注冊鍵后進(jìn)入如圖 4.7 所示的界面,輸入新用戶賬號和密碼,如果兩次密碼輸入相同就注冊成功。 定義局部變量 String 類型的 user,password 和

6、pass 分別記錄三個(gè)文本框輸入的內(nèi)容,用 equals 方法判斷 pass 和 password 是否相同,如果相同,則注冊成功,并用 dispose()方法關(guān)閉此窗口。新用戶注冊界面匚叵區(qū)新用戶注冊界面賬號二新用戶密碼;*請確認(rèn)密碼:*1注冊圖 4.7 注冊功能界面五、設(shè)計(jì)總結(jié)這次課程設(shè)計(jì),我們知道了成員變量和局部變量的不同,有些變量如果不設(shè)成成員變量就無法把數(shù)據(jù)傳遞出去,我們學(xué)會了封裝,將連接數(shù)據(jù)庫的方法封裝到 DBHelper 類中,封裝的便利讓我們寫程序更快捷,但是界面的功能還不夠人性化。六、程序清單importjava.sql.ResultSet;importjava.sql.SQ

7、LException;importorg.eclipse.swt.SWT;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.widg

8、ets.Text;importcom.swtdesigner.SWTResourceManager;publicclassdengluextendsShellbool;Texttext_1;Texttext;staticvoidmain(Stringargs 口)Displaydisplay=Display.getDefault();denglushell=newdenglu(display,SWT.SHELL_TRIMshell.open();shell.layout();while(!shell.isDisposed()if(!display.readAndDispatch()displa

9、y.sleep();catch(Exceptione)e.printStackTrace();publicdenglu(Displaydisplay,intstyle)super(display,style);createContents();protectedvoidcreateContents()setText(登陸界面);setSize(622,439);finalLabellabel=newLabel(this,SWT.BORDERlabel.setFont(SWTResourceManager.getFont(,12,SWT.BOLD;label.setText(賬號:);label

10、.setBounds(90,112,60,27);finalLabellabel_1=newLabel(this,SWT.BORDERlabel_1.setFont(SWTResourceManager.getFont(,12,SWT.BOLD;label_1.setText(密碼:);label_1.setBounds(90,185,60,27);text=newText(this,SWT.BORDERtext.setBounds(208,112,125,27);text_1=newText(this,SWT.BORD目符 WT.PASSWORDtext_1.setBounds(208,18

11、5,125,27);finalButtonbutton=newButton(this,SWT.NONEbutton.addSelectionListener(newSelectionAdapter()publicvoidwidgetSelected(finalSelectionEvente)Stringuser=text.getText();Stringpassword=text_1.getText();booleanprivateprivatepublictryDBHelperdb=newDBHelper();Stringsql=select 密碼 fromuser_Tablewhere 賬

12、號=+user+ResultSetrs=db.query(sql);trywhile(rs.next()Stringpass=rs.getString(密碼);if(password.equals(pass)bool=true;else裝 bool=false;if(bool=true)tryDisplaydisplay=Display.getDefault();zhigonggongzishell=newzhigonggongzi(display,訂 SWTSHELL_TRIMshell.open();shell.layout();while(!shell.isDisposed()if(!d

13、isplay.readAndDispatch()display.sleep();線catch(Exceptione2)e2.printStackTrace();catch(SQLExceptione1)/TODOAuto-generatedcatchblocke1.printStackTrace(););button.setFont(SWTResourceManager.getFont(,12,SWT.BOLD);button.setText(登陸)button.setBounds(388,255,48,22);finalButtonbutton_1=newButton(this,SWT.NO

14、NEbutton_1.setFont(SWTResourceManager.getFont(,12,SWT.BOLIJ);button_1.setText(注冊);button_1.setBounds(388,306,48,22);finalLabellabel_2=newLabel(this,SWT.BORDERlabel_2.setFont(SWTResourceManager.getFont(,15,SWT.BOLD;label_2.setText(歡迎使用員工工資管理系統(tǒng));label_2.setBounds(90,37,271,27);/Overrideprotectedvoidch

15、eckSubclass()/DisablethecheckthatpreventssubclassingofSWTcomponentsimportjava.sql.ResultSet;importjava.sql.SQLException;importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.SelectionAdapter;importorg.eclipse.swt.events.SelectionEvent;importorg.eclipse.swt.widgets.Button;importorg.eclipse.swt.widge

16、ts.Display;importorg.eclipse.swt.widgets.Label;importorg.eclipse.swt.widgets.Shell;importorg.eclipse.swt.widgets.Table;importorg.eclipse.swt.widgets.TableColumn;importorg.eclipse.swt.widgets.TableItem;importorg.eclipse.swt.widgets.Text;importcom.swtdesigner.SWTResourceManager;publicclasszhigonggongz

17、iextendsShellprivateTexttext;privateTabletable;publicstaticvoidmain(Stringargs 口)tryDisplaydisplay=Display.getDefault();zhigonggongzishell=newzhigonggongzi(display,SWT.SHELL_TRIMshell.open();shell.layout();while(!shell.isDisposed()if(!display.readAndDispatch()display.sleep();catch(Exceptione)e.print

18、StackTrace();publiczhigonggongzi(Displaydisplay,intstyle)super(display,style);createContents();protectedvoidcreateContents()setText(職工工資管理系統(tǒng)界面);setSize(697,458);table=newTable(this,SWT.FULL_SELECTIO|ISWT.BORDERtable.setLinesVisible(true);table.setHeaderVisible(true);table.setBounds(10,67,573,214);fi

19、nalTableColumnnewColumnTableColumn=newTableColumn(table,SWT.NONEnewColumnTableColumn.setWidth(73);newColumnTableColumn.setText(職工號);finalTableColumnnewColumnTableColumn_1=newTableColumn(tablenewColumnTableColumn_1.setWidth(76);newColumnTableColumn_1.setText(職工姓名);finalTableColumnnewColumnTableColumn

20、_2=newTableColumn(tablenewColumnTableColumn_2.setWidth(76);newColumnTableColumn_2.setText(基本工資);finalTableColumnnewColumnTableColumn_3=newTableColumn(tablenewColumnTableColumn_3.setWidth(80);newColumnTableColumn_3.setText(職位提成);finalTableColumnnewColumnTableColumn_4=newTableColumn(tablenewColumnTabl

21、eColumn_4.setWidth(79);newColumnTableColumn_4.setText(遲到天數(shù));finalTableColumnnewColumnTableColumn_5=newTableColumn(tablenewColumnTableColumn_5.setWidth(83);newColumnTableColumn_5.setText(曠工天數(shù));finalTableColumnnewColumnTableColumn_6=newTableColumn(tablenewColumnTableColumn_6.setWidth(100);newColumnTab

22、leColumn_6.setText(所得工資);finalButtonbutton=newButton(this,SWT.NONEbutton.addSelectionListener(newSelectionAdapter()publicvoidwidgetSelected(finalSelectionEvente)tryDisplaydisplay=Display.getDefault();lurushell=newluru(display,SWT.SHELL_TRIMshell.open();shell.layout();while(!shell.isDisposed()if(!dis

23、play.readAndDispatch()display.sleep();catch(Exceptione2)e2.printStackTrace();a(););button.setFont(SWTResourceManager.getFont(,12,SWT.BOLD;button.setText(錄入);button.setBounds(604,142,55,31);finalButtonbutton_1=newButton(this,SWT.NONEbutton_1.addSelectionListener(newSelectionAdapter()publicvoidwidgetS

24、elected(finalSelectionEvente)TableItemitem=table.getSelection();DBHelperdb=newDBHelper();for(inti=0;iitem.length;i+)Stringid=itemi.getText(0);Stringsql=deletefrom 職工信息表 where 職工號=+id+db.update(sql);db.close();int 口 a=table.getSelectionIndices();,SWT.NONE,SWT.NONE,SWT.NONE,SWT.NONE,SWT.NONE,SWT.NONEt

25、able.remove(a););button_1.setFont(SWTResourceManager.getFont(,12,SWT.BOLD);button_1.setText(刪除);button_1.setBounds(604,196,55,31);finalButtonbutton_2=newButton(this,SWT.NONEbutton_2.addSelectionListener(newSelectionAdapter()publicvoidwidgetSelected(finalSelectionEvente)a(););button_2.setFont(SWTReso

26、urceManager.getFont(,12,SWT.BOLD);button_2.setText(查詢);button_2.setBounds(604,91,55,31);text=newText(this,SWT.BORDERtext.setBounds(209,314,89,31);finalLabellabel=newLabel(this,SWT.BORDERlabel.setFont(SWTResourceManager.getFont(,12,SWT.BOLD;label.setText(按職工號查找:);label.setBounds(53,314,136,31);finalB

27、uttonbutton_3=newButton(this,SWT.NONEbutton_3.addSelectionListener(newSelectionAdapter()publicvoidwidgetSelected(finalSelectionEvente)table.removeAll();Stringid=text.getText();DBHelperdb=newDBHelper();Stringsql=select*from 職工信息表;ResultSetrs=db.query(sql);booleanbool=true;if(bool)trywhile(rs.next()if

28、(id.equals(rs.getString(職工號)bool=false;finalTableitemnewltemTableltem=newitemTableitem.setText(0,rs.getString(職工號);newitemTableitem.setText(1,rs.getString(姓名);newitemTableitem.setText(2,rs.getString(基本工資);doublemoney1=Double.parseDouble(rs.getString(基本工資newitemTableitem.setText(3,rs.getString(職位提成);

29、doublemoney2=Double.parseDouble(rs.getString(職位提成newitemTableitem.setText(4,rs.getString(遲到天數(shù));intday1=integer.parseint(rs.getString(遲到天數(shù));newitemTableitem.setText(5,rs.getString(曠工天數(shù));intday2=integer.parseint(rs.getString(曠工天數(shù));doublemoney=money1+money2-day1*50-day2*100;if(money0)newTableltem(table

30、SWTBORDER););money=0;)StringMoney=String.valueOf(money);newItemTableItem.setText(6,Money);)catch(SQLExceptione1)/TODOAuto-generatedcatchblocke1.printStackTrace(););button_3.setFont(SWTResourceManager.getFont(,12,SWT.BOLD);button_3.setText(查找);button_3.setBounds(347,312,73,33);finalLabellabel_1=newLa

31、bel(this,SWT.BORDERlabel_1.setFont(SWTResourceManager.getFont(,15,SWT.BOLD;label_1.setText(職工工資管理系統(tǒng));label_1.setBounds(189,24,177,31);/publicvoida()table.removeAll();DBHelperdb=newDBHelper();Stringsql=select*from 職工信息表doublemoney1=Double.parseDouble(rs.getString(基本工資);newItemTableItem.setText(3,rs.g

32、etString(職位提成);doublemoney2=Double.parseDouble(rs.getString(職位提成);newItemTableItem.setText(4,rs.getString(遲到天數(shù));intday1=Integer.parseInt(rs.getString(遲到天數(shù));newItemTableItem.setText(5,rs.getString(曠工天數(shù));intday2=Integer.parseInt(rs.getString(曠工天數(shù));doublemoney=money1+money2-day1*50-day2*100;if(money0)m

33、oney=0;StringMoney=String.newItemTableItem.setText(6,Money);catch(SQLExceptione)/TODOAuto-generatedcatchblocke.printStackTrace();ResultSetrs=db.query(sql);trywhile(rs.next()finalTableitemnewltemTableltemnewItemTableItem.setText(0,rs.getString(newitemTableitem.setText(1,rs.getString(newItemTableItem.

34、setText(2,rs.getString(=newTableItem(table,SWT.BORDER職工號);姓名);基本工資);valueOf(money);OverrideprotectedvoidcheckSubclass()/DisablethecheckthatpreventssubclassingofSWTcomponents)importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.SelectionAdapter;importorg.eclipse.swt.events.SelectionEvent;importorg.

35、eclipse.swt.widgets.Button;importorg.eclipse.swt.widgets.Display;importorg.eclipse.swt.widgets.Label;importorg.eclipse.swt.widgets.Shell;importorg.eclipse.swt.widgets.Text;importcom.swtdesigner.SWTResourceManager;Displaydisplay=Display.getDefault();lurushell=newluru(display,SWT.SHELL_TRIMshell.open(

36、);shell.layout();while(!shell.isDisposed()if(!display.readAndDispatch()display.sleep();)catch(Exceptione)e.printStackTrace();publicluru(Displaydisplay,intstyle)super(display,style);createContents();protectedvoidcreateContents()setText(職工工資錄入界面);setSize(660,451);finalLabellabel=newLabel(this,SWT.BORD

37、ERlabel.setFont(SWTResourceManager.getFont(,12,SWT.BOLD;label.setText(職工號:);label.setBounds(87,82,87,26);finalLabellabel_1=newLabel(this,SWT.BORDERlabel_1.setFont(SWTResourceManager.getFont(,12,SWT.BOLD;label_1.setText(姓名:);label_1.setBounds(87,119,87,24);privateTexttext_5;privateTexttext_4;privateT

38、exttext_3;privateTexttext_2;privateTexttext_1;privateTexttext;publicstaticvoidmain(Stringargs)tryclassluruextendsShellpublictext=newText(this,SWT.BORDERtext.setBounds(241,82,70,26);text_1=newText(this,SWT.BORDERtext_1.setBounds(241,119,70,24);text_2=newText(this,SWT.BORDERtext_2.setBounds(241,149,70

39、,24);text_3=newText(this,SWT.BORDERtext_3.setBounds(241,179,70,26);text_4=newText(this,SWT.BORDERtext_4.setBounds(241,219,70,26);text_5=newText(this,SWT.BORDERtext_5.setBounds(241,260,70,26);finalButtonbutton=newButton(this,SWT.NONEbutton.addSelectionListener(newSelectionAdapter()publicvoidwidgetSel

40、ected(finalSelectionEvente)Strings1=text.getText();Strings2=text_1.getText();Strings3=text_2.getText();Strings4=text_3.getText();Strings5=text_4.getText();Strings6=text_5.getText();DBHelperdb=newDBHelper();Stringsql=insertinto 職,信息表(職,號,姓名,基本,費(fèi),職位提成,遲到天數(shù),曠工天數(shù))values(+s1+,+s2+,+s3+,+s4+,+s5+,+s6+);db

41、.update(sql);luru.this.dispose(););button.setFont(SWTResourceManager.getFont(,12,SWT.BOLD;button.setText(錄入);button.setBounds(430,321,48,22);finalLabellabel_2=newLabel(label_2.setFont(SWTResourceManager.label_2.setText(基本工資:”);label_2.setBounds(87,149,87,24);finalLabellabel_3=newLabel(label_3.setFon

42、t(SWTResourceManager.label_3.setText(職位提成:);label_3.setBounds(87,179,87,26);finalLabellabel_4=newLabel(label_4.setFont(SWTResourceManager.label_4.setText(遲到天數(shù):);label_4.setBounds(87,219,87,26);finalLabellabel_5=newLabel(label_5.setFont(SWTResourceManager.label_5.setText(曠工天數(shù):);label_5.setBounds(87,2

43、58,87,26);finalLabellabel_6=newLabel(label_6.setFont(SWTResourceManager.label_6.setText(職工工資錄入界面this,SWT.BORDERgetFont(”,12,SWT.BOLD;this,SWT.BORDERgetFont(”,12,SWT.BOLD;this,SWT.BORDERgetFont(,12,SWT.BOLD;this,SWT.BORDERgetFont(,12,SWT.BOLD;this,SWT.BORDERgetFont(,15,SWT.BOLD;);/)Overrideprotectedv

44、oidcheckSubclass()/DisablethecheckthatpreventssubclassingofSWTcomponents)importorg.eclipse.swt.SWT;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;

45、importorg.eclipse.swt.widgets.Shell;importorg.eclipse.swt.widgets.Text;importcom.swtdesigner.SWTResourceManager;publicclasszhuceextendsShellprivateTexttext_2;privateTexttext_1;privateTexttext;publicstaticvoidmain(Stringargs)tryDisplaydisplay=Display.getDefault();zhuceshell=newzhuce(display,SWT.SHELL

46、_TRI)Mshell.open();shell.layout();while(!shell.isDisposed()if(!display.readAndDispatch()display.sleep();)catch(Exceptione)e.printStackTrace();publiczhuce(Displaydisplay,intstyle)super(display,style);createContents();protectedvoidcreateContents()setText(新用戶注冊界面”);setSize(611,455);finalLabellabel=newLabel(this,SWT.BORDERlabel_2.setBounds(76,185,104,36);label.setFont(SWTResourceManager.label.setText(新用戶注冊界面);label

溫馨提示

  • 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

提交評論