




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、目 錄一、課程設計目的1二、系統設計1三、數據庫邏輯結構設計2四、系統功能模塊圖4五、源程序代碼11六、課程設計總結30七、存在的問題及不足30一、 課程設計目的通過數據庫課程設計,培養學生數據庫設計的綜合能力。從需求分析和數據庫邏輯、物理設計,到功能分析和應用程序的最終實現,讓學生親自動手參與一個具有一定規模的數據庫應用系統的設計和開發,真正理解和掌握數據庫設計和開發的思路和方法,并更好的理解和消化課本所學的知識,為今后的實際應用打下良好的基礎。二、 系統設計本課程設計(個人記賬系統)是用vb+sql設計完成的。在本系統里可以對家庭人員基本信息以及家庭賬目的收入支出進行簡單維護。主要功能包括
2、對家庭人員信息以及家庭收支的添加、修改、刪除、查找、統計等功能。三、數據庫邏輯結構設計1.sql數據庫設計表格設計:userinfo表,記錄用戶信息familyinfo表,記錄家庭人員信息 income表,記錄收入方面信息 pay表,記錄支出方面信息 account表,匯總收支信息 allaccount表,計算總收支及結余存儲過程定義countall存儲過程,統計account表中的收支信息,并對收支金額進行求和,算出結余插入到allaccount表中。觸發器:familyinfo表上定義update觸發器完成對income和pay上收支人員的一致性更新。income表上定義insert,de
3、lete及update觸發器,完成對于account表上的各個數據的一致性更新。pay表上定義insert,delete及update觸發器,完成對于account表上的各個數據的一致性更新。account表上定義insert,delete及update觸發器,調用countall存儲過程完成對于allacount表上數據的統計更新。四、系統功能模塊圖1、數據源連接2、界面設計登陸界面:注冊界面:收入管理界面:界面中分為三個部分,第一部分收入信息,第二部分顯示當前總收支及與結余,并隨著用戶添加修改刪除的操作及時更新,第三部分是操作信息,包括查詢、添加、修改、刪除。住處管理界面:界面中分為三個部
4、分,第一部分收入信息,第二部分顯示當前總收支及與結余,并隨著用戶添加修改刪除的操作及時更新,第三部分是操作信息,包括查詢、添加、修改、刪除。收支界面顯示:家庭人員信息顯示:五、附:源程序代碼 sql代碼觸發器 pay表上de_pay create trigger de_payon payfor deleteasdeclare new_time char(20)declare new_item char(20)declare new_mon intdeclare new_rela char(20)declare new_expl char(200)select new_time=支出時間 fro
5、m deletedselect new_item=支出項目 from deletedselect new_mon=支出金額 from deletedselect new_rela=支出人員 from deletedselect new_expl=支出說明 from deleteddelete from account where 錄入時間=new_time and 收支金額=new_mon and 收支項目=new_item and 收支人員=new_rela and 收支說明=new_explout_trcreate trigger out_tron payfor insertasdecla
6、re new_time char(20)declare new_item char(20)declare new_mon intdeclare new_rela char(20)declare new_expl char(200)select new_time=支出時間 from insertedselect new_item=支出項目 from insertedselect new_mon=支出金額 from insertedselect new_rela=支出人員 from insertedselect new_expl=支出說明 from insertedinsert into acco
7、unt(錄入時間,收支類型,收支金額,收支項目,收支人員,收支說明)values(new_time,支出,new_mon,new_item,new_rela,new_expl) up_paycreate trigger up_payon payfor updateasdeclare new_time char(20)declare new_item char(20)declare new_mon intdeclare new_rela char(20)declare new_expl char(200)declare old_time char(20)declare old_item char
8、(20)declare old_mon intdeclare old_rela char(20)declare old_expl char(200)select old_time=支出時間 from deletedselect old_item=支出項目 from deletedselect old_mon=支出金額 from deletedselect old_rela=支出人員 from deletedselect old_expl=支出說明 from deletedselect new_time=支出時間 from insertedselect new_item=支出項目 from in
9、sertedselect new_mon=支出金額 from insertedselect new_rela=支出人員 from insertedselect new_expl=支出說明 from insertedupdate account set 錄入時間=new_time where 錄入時間=old_timeupdate account set 收支金額=new_mon where 收支金額=old_monupdate account set 收支項目=new_item where 收支項目=old_itemupdate account set 收支人員=new_rela where
10、收支人員=old_relaupdate account set 收支說明=new_expl where 收支說明=old_explincome 表上create trigger de_incomeon incomefor deleteasdeclare new_time char(20)declare new_item char(20)declare new_mon intdeclare new_rela char(20)declare new_expl char(200)select new_time=收入日期 from deletedselect new_item=收入項目 from de
11、letedselect new_mon=收入金額 from deletedselect new_rela=收入人員 from deletedselect new_expl=收入說明 from deleteddelete from account where 錄入時間=new_time and 收支金額=new_mon and 收支項目=new_item and 收支人員=new_rela and 收支說明=new_explcreate trigger in_tron incomefor insertasdeclare new_time char(20)declare new_item char
12、(20)declare new_mon intdeclare new_rela char(20)declare new_expl char(200)select new_time=收入日期 from insertedselect new_item=收入項目 from insertedselect new_mon=收入金額 from insertedselect new_rela=收入人員 from insertedselect new_expl=收入說明 from insertedinsert into account(錄入時間,收支類型,收支金額,收支項目,收支人員,收支說明)values(
13、new_time,收入,new_mon,new_item,new_rela,new_expl) create trigger up_incomeon incomefor updateasdeclare new_time char(20)declare new_item char(20)declare new_mon intdeclare new_rela char(20)declare new_expl char(200)declare old_time char(20)declare old_item char(20)declare old_mon intdeclare old_rela c
14、har(20)declare old_expl char(200)select old_time=收入日期 from deletedselect old_item=收入項目 from deletedselect old_mon=收入金額 from deletedselect old_rela=收入人員 from deletedselect old_expl=收入說明 from deletedselect new_time=收入日期 from insertedselect new_item=收入項目 from insertedselect new_mon=收入金額 from insertedse
15、lect new_rela=收入人員 from insertedselect new_expl=收入說明 from insertedupdate account set 錄入時間=new_time where 錄入時間=old_timeupdate account set 收支金額=new_mon where 收支金額=old_monupdate account set 收支項目=new_item where 收支項目=old_itemupdate account set 收支人員=new_rela where 收支人員=old_relaupdate account set 收支說明=new_
16、expl where 收支說明=old_explfamilyinfo表上create trigger up_familyon dbo.familyinfofor updateasdeclare new_rela char(20)declare old_rela char(20)select new_rela=家庭人員 from insertedselect old_rela=家庭人員 from deletedupdate income set 收入人員=new_rela where 收入人員=old_relaupdate pay set 支出人員=new_rela where 支出人員=old
17、_relaaccount表上create trigger de_accounton accountfor deleteasexec countallcreate trigger in_accounton accountfor insert asexec countallcreate trigger up_accounton accountfor updateasexec countall存儲過程create proc countallasdeclare sum_income intdeclare sum_pay intdeclare sum_count intdeclare old_incom
18、e intdeclare old_pay intdeclare old_sum intselect old_income=總收入,old_pay=總支出,old_sum=結余 from allaccountselect sum_income=sum(收支金額) from account where 收支類型=收入select sum_pay=sum(收支金額) from account where 收支類型=支出set sum_count=sum_income-sum_payupdate allaccount set 總收入=sum_income where 總收入=old_incomeupd
19、ate allaccount set 總支出=sum_pay where 總支出=old_payupdate allaccount set 結余=sum_count where 結余=old_sumvb代碼模塊public cn as adodb.connectionpublic rs as adodb.recordset菜單private sub command1_click()菜單.hide收入管理.showend subprivate sub command2_click()菜單.hide支出管理.showend subprivate sub command3_click()菜單.hid
20、e收支顯示.showend subprivate sub command4_click()菜單.hide登錄.showend subprivate sub command5_click()if msgbox(你確定要退出嗎?, vbokcancel, 提示) = vbok then endend ifend subprivate sub command6_click()菜單.hide家庭人員.showend sub登錄private sub command1_click()set cn = new adodb.connectionset rs = new adodb.recordsetcn.o
21、pen dsn=keep_accountrs.open select * from userinfo where username= & text1 & & and password= & text2 & , cn, adopenstatic, adlockoptimisticif rs.recordcount 0 then 菜單.show 登錄.hideelse msgbox 密碼錯誤或用戶名不存在!請重新輸入。 a = a + 1 密碼沒輸入一次a的數值就增加1 text1.text = text2.text = if a 2 then 三次輸入錯誤,程序強制退出 msgbox 三次輸入錯
22、誤,強制退出! end end ifend ifend subprivate sub command2_click()登錄.hide注冊.showend subprivate sub command3_click()if msgbox(你確定要退出嗎?, vbokcancel, 提示) = vbok then endend ifend sub家庭人員public sub export()text1.text = rs.fields(家庭人員)text2.text = rs.fields(年齡)text3.text = rs.fields(政治面貌)text4.text = rs.fields(
23、職業)text5.text = rs.fields(說明)end subpublic sub import()rs.fields(家庭人員) = text1.textrs.fields(年齡) = text2.textrs.fields(政治面貌) = text3.textrs.fields(職業) = text4.textrs.fields(說明) = text5.textend subpublic sub clear()text1.text = text2.text = text3.text = text4.text = text5.text = end subprivate sub co
24、mmand1_click()on error goto flagrs.movefirstcall exportexit subflag: msgbox 數據庫空或當前已是第一條!end subprivate sub command10_click()if msgbox(你確定要退出嗎?, vbokcancel, 提示) = vbok then endend ifend subprivate sub command2_click()on error goto flagrs.movepreviousif rs.bof then msgbox 當前已是第一條記錄!, , 提示 rs.movefirs
25、telse call exportend ifexit subflag: msgbox 數據庫無記錄或當前已是第一條!end subprivate sub command3_click()on error goto flagrs.movenextif rs.eof then msgbox 當前已是最后一條記錄!, , 提示 rs.movelastelse call exportend ifexit subflag: msgbox 數據庫無記錄或當前已是最后一條記錄!end subprivate sub command4_click()on error goto flagrs.movelastc
26、all exportexit subflag: msgbox 數據庫無記錄或當前已是最后一條記錄!end subprivate sub command5_click()on error goto flagif rs.recordcount 0 then rs.movelast rs.addnew call import rs.updateelse rs.addnew call import rs.updateend if收入管理.combo3.additem (text1.text)收入管理.hide支出管理.combo3.additem (text1.text)支出管理.hidecall c
27、learrs.closers.open select * from familyinfo, cn, adopenstatic, adlockoptimisticrs.movelastexit subflag: msgbox 請檢查你輸入的格式是否正確.end subprivate sub command6_click()if msgbox(你確定要修改該條記錄?, vbokcancel, 提示) = vbok then rs.delete rs.update rs.addnew call import rs.updateend ifrs.closers.open select * from f
28、amilyinfo, cn, adopenstatic, adlockoptimisticend subprivate sub command7_click()on error goto flagdim a as integerdim b as integera = 收入管理.combo3.listcount - 1b = 支出管理.combo3.listcount - 1if msgbox(你確定要刪除這一條記錄?, vbokcancel, 提示) = vbok then rs.delete rs.update rs.moveprevious call export 收入管理.combo3.
29、removeitem a 收入管理.hide 支出管理.combo3.removeitem bend ifrs.closers.open select * from familyinfo, cn, adopenstatic, adlockoptimisticexit subflag: msgbox 數據庫無記錄或已刪除記錄!end subprivate sub command8_click()on error goto flagif combo2.text = 全部顯示 then set 家庭人員顯示.datagrid1.datasource = rs 家庭人員顯示.showelse if t
30、ext6.text = then msgbox 請輸入查找信息! else rs.close rs.open select * from familyinfo where & combo2.text & = & text6 & , cn, adopenstatic, adlockoptimistic 按用戶指定的方式,與用戶提供的信息查詢 if rs.recordcount 0 then call export else msgbox 對不起,記錄中沒有你要查找的項! end if end ifend ifrs.closers.open select * from familyinfo, cn
31、, adopenstatic, adlockoptimisticexit subflag: msgbox 請檢查你輸入的格式是否正確:end subprivate sub command9_click()家庭人員.hide菜單.showend subprivate sub form_load()set cn = new adodb.connectionset rs = new adodb.recordsetcn.open dsn=keep_accountrs.open select * from familyinfo, cn, adopenstatic, adlockoptimisticcal
32、l exportend sub收入管理private sub command1_click()on error goto flagrs.movefirstcall exportexit subflag: msgbox 數據庫空或當前已是第一條!end subprivate sub command10_click()if msgbox(你確定要退出嗎?, vbokcancel, 提示) = vbok then endend ifend subprivate sub command2_click()on error goto flagrs.movepreviousif rs.bof then ms
33、gbox 當前已是第一條記錄!, , 提示 rs.movefirstelse call exportend ifexit subflag: msgbox 數據庫無記錄或當前已是第一條!end subprivate sub command3_click()on error goto flagrs.movenextif rs.eof then msgbox 當前已是最后一條記錄!, , 提示 rs.movelastelse call exportend ifexit subflag: msgbox 數據庫無記錄或當前已是最后一條記錄!end subprivate sub command4_clic
34、k()on error goto flagrs.movelastcall exportexit subflag: msgbox 數據庫無記錄或當前已是最后一條記錄!end subprivate sub command5_click()on error goto flagif rs.recordcount 0 then rs.movelast rs.addnew call import rs.updateelse rs.addnew call import rs.updateend ifcall clearrs.closers.open select * from allaccount, cn,
35、 adopenstatic, adlockoptimisticlabel10.caption = rs.fields(總收入)label11.caption = rs.fields(總支出)label12.caption = rs.fields(結余)rs.closers.open select * from income, cn, adopenstatic, adlockoptimisticrs.movelastexit subflag: msgbox 請檢查你輸入的格式是否正確. & vbcrlf & 收入金額為數字格式 & vbcrlf & 時期請按:(年)-(月)-(日)輸入 & vb
36、crlf & 其他為文本格式end subprivate sub command6_click()if msgbox(你確定要修改該條記錄?, vbokcancel, 提示) = vbok then rs.delete rs.update rs.addnew call import rs.updateend ifrs.closers.open select * from allaccount, cn, adopenstatic, adlockoptimisticlabel10.caption = rs.fields(總收入)label11.caption = rs.fields(總支出)lab
37、el12.caption = rs.fields(結余)rs.closers.open select * from income, cn, adopenstatic, adlockoptimisticend subprivate sub command7_click()on error goto flagif msgbox(你確定要刪除這一條記錄?, vbokcancel, 提示) = vbok then rs.delete rs.update rs.moveprevious call exportend ifrs.closers.open select * from allaccount,
38、cn, adopenstatic, adlockoptimisticlabel10.caption = rs.fields(總收入)label11.caption = rs.fields(總支出)label12.caption = rs.fields(結余)rs.closers.open select * from income, cn, adopenstatic, adlockoptimisticexit subflag: msgbox 數據庫無記錄或已刪除記錄!end subprivate sub command8_click()on error goto flagif combo2.te
39、xt = 全部顯示 then set 收入顯示.datagrid1.datasource = rs 收入顯示.showelse if text6.text = then msgbox 請輸入查找信息! else rs.close rs.open select * from income where & combo2.text & = & text6 & , cn, adopenstatic, adlockoptimistic 按用戶指定的方式,與用戶提供的信息查詢 if rs.recordcount 0 then call export else msgbox 對不起,記錄中沒有你要查找的項!
40、 end if end ifend ifrs.closers.open select * from income, cn, adopenstatic, adlockoptimisticexit subflag: msgbox 請檢查你輸入的格式是否正確: & vbcrlf & 日期請按(年)-(月)-(日)格式輸入.end subprivate sub command9_click()收入管理.hide菜單.showend subprivate sub form_load()set cn = new adodb.connectionset rs = new adodb.recordsetcn.
41、open dsn=keep_accountrs.open select * from allaccount, cn, adopenstatic, adlockoptimisticlabel10.caption = rs.fields(總收入)label11.caption = rs.fields(總支出)label12.caption = rs.fields(結余)rs.closers.open select * from income, cn, adopenstatic, adlockoptimisticcall exportend sub收支顯示private sub command1_c
42、lick()收支顯示.hide菜單.showend subprivate sub command2_click()if msgbox(你確定要退出嗎?, vbokcancel, 提示) = vbok then endend ifend subprivate sub form_load()set cn = new adodb.connectionset rs = new adodb.recordsetcn.open dsn=keep_accountrs.open select * from account, cn, adopenstatic, adlockoptimisticset datagr
43、id1.datasource = rsend sub支出管理public sub export()text1.text = rs.fields(支出時間)combo1.text = rs.fields(支出項目)text3.text = rs.fields(支出金額)combo3.text = rs.fields(支出人員)text5.text = rs.fields(支出說明)end subpublic sub import()rs.fields(支出時間) = text1.textrs.fields(支出項目) = combo1.textrs.fields(支出金額) = text3.te
44、xtrs.fields(支出人員) = combo3.textrs.fields(支出說明) = text5.textend subpublic sub clear()text1.text = combo1.text = text3.text = combo3.text = text5.text = end subprivate sub command1_click()on error goto flagrs.movefirstcall exportexit subflag: msgbox 數據庫空或當前已是第一條!end subprivate sub command10_click()if
45、msgbox(你確定要退出嗎?, vbokcancel, 提示) = vbok then endend ifend subprivate sub command2_click()on error goto flagrs.movepreviousif rs.bof then msgbox 當前已是第一條記錄!, , 提示 rs.movefirstelse call exportend ifexit subflag: msgbox 數據庫無記錄或當前已是第一條!end subprivate sub command3_click()on error goto flagrs.movenextif rs
46、.eof then msgbox 當前已是最后一條記錄!, , 提示 rs.movelastelse call exportend ifexit subflag: msgbox 數據庫無記錄或當前已是最后一條記錄!end subprivate sub command4_click()on error goto flagrs.movelastcall exportexit subflag: msgbox 數據庫無記錄或當前已是最后一條記錄!end subprivate sub command5_click()on error goto flagif rs.recordcount 0 then r
47、s.movelast rs.addnew call import rs.updateelse rs.addnew call import rs.updateend ifcall clearrs.closers.open select * from allaccount, cn, adopenstatic, adlockoptimisticlabel10.caption = rs.fields(總收入)label11.caption = rs.fields(總支出)label12.caption = rs.fields(結余)rs.closers.open select * from incom
48、e, cn, adopenstatic, adlockoptimisticrs.movelastexit subflag: msgbox 請檢查你輸入的格式是否正確. & vbcrlf & 收入金額為數字格式 & vbcrlf & 時期請按:(年)-(月)-(日)輸入 & vbcrlf & 其他為文本格式end subprivate sub command6_click()if msgbox(你確定要修改該條記錄?, vbokcancel, 提示) = vbok then rs.delete rs.update rs.addnew call import rs.updateend ifrs.c
49、losers.open select * from allaccount, cn, adopenstatic, adlockoptimisticlabel10.caption = rs.fields(總收入)label11.caption = rs.fields(總支出)label12.caption = rs.fields(結余)rs.closers.open select * from income, cn, adopenstatic, adlockoptimisticend subprivate sub command7_click()on error goto flagif msgbox(你確定要刪除這一條記錄?, vbokcancel, 提示) = vbok then rs.delete rs.update rs.moveprevious call exportend ifrs.closers.open select * from allaccount, cn, adopenstatic, adlockoptimisticlabel10.caption = rs.fields(總收入)label11.caption = rs.fields(總支出)label12.caption = rs.fields(結余)rs.closers.open select * fr
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 激光癌癥診斷儀項目投資可行性研究分析報告(2024-2030版)
- 2023-2029年中國粗糧餅干行業發展監測及投資前景展望報告
- 2025年 鍋爐水處理作業G3證考試練習題附答案
- 2025年中國無花果行業市場調研分析及投資戰略咨詢報告
- 2025年 扶風縣職業教育中心招聘考試筆試試題附答案
- 2023-2028年中國制造執行系統行業發展前景預測及投資戰略咨詢報告
- 2025年中國導爪行業市場發展前景及發展趨勢與投資戰略研究報告
- 紅薯系列產品加工項目可行性研究報告
- 中國高端禮品酒行業市場全景分析及發展趨勢預測報告
- 公司輝縣市生活垃圾焚燒發電項目環境影響報告書的批復
- 大學紡織職業生涯規劃書
- 消防員職業發展規劃方案
- 意外險采購服務投標方案
- DB14-T 2869-2023 建筑消防設施檢測規程
- 二手車鑒定評估報告書(范本)
- 高校校園閑置資源的共享平臺實施方案
- 2022年中山市公安局三鄉分局輔警招聘考試真題
- 深圳市房地產登記申請表
- 充電樁工程施工方案模板
- 中華人民共和國漁撈日志
- 員工宿舍衛生評比方案
評論
0/150
提交評論