




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、一、設計目的 2二、功能介紹 2三、程序流程 2四、設計步驟 3五、設計總結 7六、程序清單 8七、參考文獻 17一、設計目的通過課程設計, 使學生提高理論聯(lián)系實際解決實際問題的能力;也使學生對基于面向對象的理論進行系統(tǒng)設計過程中的諸多具體問題有感性的認識和深入的理解;進而提高學生的學習興趣為其將來順利進入畢業(yè)環(huán)節(jié)作必要的準備。二、功能介紹(1)具有新用戶注冊功能。(2)具有注冊用戶登錄功能。(3)具有職工工資的錄入功能, 要求只錄入工資各項, 自動計算每個職工工資總額。(4)具有數(shù)據查詢功能,可以實現(xiàn)查詢全部信息和按條件執(zhí)行查詢。(5)具有按條件刪除數(shù)據功能。三、程序流程四、設計步驟4.1、
2、登陸界面進入系統(tǒng)首先進入登陸界面如圖 4.1,輸入賬號和密碼,點擊登錄就會進入職工工資管理系統(tǒng),點擊注冊進入新用戶注冊界面,定義了局部變量 String 類型的user,password 和 pass 分別記錄界面輸入的賬號,密碼和數(shù)據庫查找的密碼,定義了成員變量 boolean 型的 bool 記錄輸入賬號和密碼是否匹配。登陸界面Tirnltx歡迎使用員工工資管理系統(tǒng)麻號:嵬而密碼:*圖 4.1 登陸界面4.2、職工工資管理系統(tǒng)登陸成功后進入的界面如圖 4.2,界面有增刪改查的功能。widgetSelected()方法創(chuàng)建button 的點擊事件,創(chuàng)建 DBHelper 類的對象 db 連接
3、數(shù)據庫,進行查找,刪除修改功能,增刪改用 update()方法,查詢用 query()方法。圖 4.2 職工工資管理界面4.3、全部查找功能點擊右邊的查詢按鈕可以查找出所有員工的工資信息如圖 4.3,通過自己封裝的連接數(shù)據庫的類 DBHelper 類的對象 db,傳遞 sql 語句查找數(shù)據庫的所有信息,用getString()方法導出從數(shù)據庫中查找到的數(shù)據,所得工資=基本工資+職位提成-50*遲到天數(shù)-100*曠工天數(shù),通過查找的數(shù)據和自己定義的公式得到所得工資。4.4、按條件查找功能在文本框中輸入職工號, 點擊查找能找到對應職工的工資情況, 如圖 4.4o 用 getText()方法獲得 t
4、ext 文本框中的的輸入信息, 定義局部變量 boolean 型的數(shù)據 bool,記錄數(shù)據庫中是否有對應的職工號,如果查到則為 true,并且在表格中先用 removeAll()方法清空表的信息,然后用 sql 語句找出 text 中的職工號對應的數(shù)據。圖 4.4 按條件查找界面錄入功能點擊錄入鍵進入錄入界面如圖 4.5,輸入職工信息,點擊錄入修改數(shù)據庫的信息,并且能更新查找的結果。 用 getText()方法獲得 text 文本框的信息, 定義局部變量 String 類型的s1,s2,s3,s4,s5,s6 記錄六個文本框的信息,通過 DBHelper 的對象db 調用 update 方法把
5、信息傳入數(shù)據庫。刪除功能點擊選中行,然后點擊刪除按鈕就會將選種的行刪除掉,例如刪除圖 4.3 中第三行數(shù)據如圖 4.6。 定義局部變量 TableItem數(shù)組用 table.getSelection()方法查找并存儲選中行的信息,定義 int型數(shù)組用 table.getSelectionIndices()方法查找并存儲選中行的行號,用這兩個信息分別刪除數(shù)據庫和界面的選中信息。圖 4.5 錄入功能界面圖 4.6 刪除功能界面注冊功能點擊注冊鍵后進入如圖 4.7 所示的界面,輸入新用戶賬號和密碼,如果兩次密碼輸入相同就注冊成功。 定義局部變量 String 類型的 user,password 和
6、pass 分別記錄三個文本框輸入的內容,用 equals 方法判斷 pass 和 password 是否相同,如果相同,則注冊成功,并用 dispose()方法關閉此窗口。新用戶注冊界面匚叵區(qū)新用戶注冊界面賬號二新用戶密碼;*請確認密碼:*1注冊圖 4.7 注冊功能界面五、設計總結這次課程設計,我們知道了成員變量和局部變量的不同,有些變量如果不設成成員變量就無法把數(shù)據傳遞出去,我們學會了封裝,將連接數(shù)據庫的方法封裝到 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 職,信息表(職,號,姓名,基本,費,職位提成,遲到天數(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)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 新型頁巖氣開采技術2025年環(huán)境影響評估與效益分析報告:環(huán)境風險評估與技術創(chuàng)新
- 深入探討樂理的關鍵術語試題及答案
- 婚姻輔導測試題及答案
- 數(shù)學擴展思維試題及答案
- 有機合成操作練習題目及答案
- 綜采鉗工考試題及答案
- 山東輕工職業(yè)學院《工程安全健康與環(huán)境管理》2023-2024學年第二學期期末試卷
- 新興醫(yī)藥領域2025年CRO外包模式下的個性化治療方案研究
- 西安培華學院《計算機輔助飛機制造》2023-2024學年第二學期期末試卷
- 江西省余干縣重點達標名校2025年初三第八次聯(lián)考語文試題含解析
- 砌石截水墻施工方案
- 海岸工程學設計計算書
- 大學美育知到智慧樹章節(jié)測試課后答案2024年秋長春工業(yè)大學
- 創(chuàng)新設計前沿知到智慧樹章節(jié)測試課后答案2024年秋浙江大學
- 《城市級實景三維數(shù)據規(guī)范》
- 厚積薄發(fā) 行穩(wěn)致遠-六年級期中家長會【課件】
- 《中西藥物的合理配伍與禁忌探究》6400字(論文)
- 2024年10月高等教育自學考試14169設計基礎試題及答案
- 地鐵導向標識安裝施工方案
- 政務新媒體管理培訓
- 智能垃圾分類答辯
評論
0/150
提交評論