《數據庫原理》課程設計報告農產品信息管理系統_第1頁
《數據庫原理》課程設計報告農產品信息管理系統_第2頁
《數據庫原理》課程設計報告農產品信息管理系統_第3頁
《數據庫原理》課程設計報告農產品信息管理系統_第4頁
《數據庫原理》課程設計報告農產品信息管理系統_第5頁
已閱讀5頁,還剩41頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、 數據庫原理課程設計報告 農產品信息管理系統系 部: 計算機與信息科學系 學生姓名: 指導教師: 專 業: 計算機與信息科學 班 級: 信本0902班 完成時間: 2011年6月15日 目 錄1 引 言12 設計目的與任務23 數據庫設計33.1 需求分析33.1.1 數據需求33.1.2 數據字典43.2 概念設計63.2.1 實體集63.2.2 e-r圖73.2.3 概念模型73.3 邏輯設計83.3.1 物理模型83.3.2 關系模型93.4 數據庫實現103.4.1建立數據庫模式及視圖103.4.2源代碼124 結 論405 致 謝416 參考文獻427 附 錄431 引 言隨著計算機

2、行業的興起,信息管理技術在現實生活中得到了越來越廣泛的應用,信息管理系統的實施在技術上已逐步成熟。信息管理系統是一個不斷發展的新型學科,任何一個單位要生存要發展,要高效率地把內部活動有機地組織起來,就必須建立與自身特點相適應的管理系統。對于農產品生產機構而言,能有一個完善的農產品信息的管理系統來方便快捷的完成對農產品信息和倉庫管理員信息的查詢、修改和管理,在提高管理效率和查找農產品信息效率上是不可缺少的。對于我們而言,通過完成每期的課程設計,不但可以不斷的提升自己的動手能力,加強的我們的團隊合作精神,培養我們敏捷的思維能力。還可以提升我們對專業認識,更好的理解和掌握我們的專業知識。2 設計目的

3、與任務通過本次課程設計,學習數據庫設計工具的使用,掌握數據庫設計的流程和基本方法。熟練vb與數據庫之間的鏈接,完成對某一小型數據庫設計和相應文檔的編寫工作。從而更加深入地掌握數據庫系統分析與設計的基本概念和基本方法,提高從事數據庫系統建設和管理工作的基本技能和能力。本課程設計要求設計一個農產品信息管理系統,能對數據庫中的農產品信息隨時進行新增、修改和刪除。數據庫中包含農產品信息表,職員信息表和倉庫信息表和用戶表。同時創建基本視圖,實現對數據的查詢、新增、修改和刪除。用戶登錄需驗證用戶的身份,對于不合權限的用戶,拒絕其登錄本系統。3 數據庫設計3.1 需求分析3.1.1 數據需求通過與農產品信息

4、管理系統數據庫用戶的交談、團隊的分析、市場需求等方式,獲得了農產品信息管理系統的數據需求。有多個用戶可以訪問該數據庫,為了數據庫的安全,對于每個用戶登錄前都需通過身份認證,認證通過后方能進入該系統。一個農產品公司可生產多種農產品,不同農產品存放在不同的倉庫,每個倉庫有固定的管理員。每個農產品信息包含產品編號、倉庫號、產品名、入庫時間、庫存量和總值。每個倉庫信息包含倉庫號、面積和電話號碼。每位管理員信息包括管理員號、姓名、性別、出生年月和聯系方式。圖3.11農產品信息管理系統數據流圖3.1.2 數據字典 以下將對本數據庫設計中的各個數據表名稱進行解釋。表3.1農產品信息管理清單表名解釋農產品信息

5、表用來記錄農產品的相關信息用戶用來記錄登錄用戶的用戶名和密碼職員表用來記錄管理員的相關信息倉庫信息表用來記錄倉庫里農產品的相關信息表3.2農產品信息表農產品信息表是否主鍵屬性名數據類型長度可 空約 束缺省值備 注是產品編號char(10)10倉庫號char(10)10產品名char(10)10入庫時間char(20)10庫存量char(10)20總 值 char(10)10表3.3用戶信息表用戶是否主鍵屬性名數據類型長度可空約 束缺省值備 注是用戶名char(10)10密碼char(20)20表3.4職員信息表職員信息表是否主鍵屬性名數據類型長度可空約 束缺省值備 注是管理員號char(10)

6、10姓名char(10)10性別char(2)2出生年月char(40)40聯系方式char(14)14表3.5倉庫信息表倉庫信息表是否主鍵屬性名數據類型長度可 空約 束缺省值備 注是倉庫號char(10)10面 積char(20)10電話號碼char(14)103.2 概念設計3.2.1 實體集 本數據庫e-r圖設計中包含4個實體,其中4個實體都是強實體集。實體的具體屬性可見下表。表3.6農產品信息管理系統實體集農產品信息管理系統實體集實體集屬性農產品信息表產品編號、倉庫號、產品名、入庫時間、庫存量、總值職員信息表管理員號、姓名、性別、出生年月、聯系方式倉庫信息表倉庫號、面積、電話號碼用戶用

7、戶名、密碼3.2.2 e-r圖圖3.22 農產品信息管理系統數據庫e-r圖3.2.3 概念模型由圖3.1的e-r圖中實體之間的聯系,利用powerdesigner工具概念模型。最終概念模型圖如圖2所示圖3.23農產品信息管理系統數據庫概念模型 3.3 邏輯設計3.3.1 物理模型根據圖3.2的概念模型圖,可以利用powerdesigner導出農產品管理系統數據庫的物理模型圖。圖3.31農產品信息管理系統數據庫物理模型3.3.2 關系模型根據關系模式轉換規則,把圖1e-r圖轉換為關系模式,如下所示(有實下劃線的為主碼):農產品信息=(產品編號,倉庫號,產品名,入庫時間,庫存量,總值)倉庫信息=(

8、倉庫號,面積,電話號碼)職員信息=(管理員號,姓名,性別,出生年月,聯系方式)用戶=(用戶名,密碼)管理=(倉庫號,管理員號)3.4 數據庫實現3.4.1建立數據庫模式及視圖 以下將對數據庫進行實現,實現的環境為sqlserver2008。create database 農產品信息管理on primary( name=農產品信息管理_data, filename= d:數據庫課程設計農產品信息.mdf , size=10, filegrowth=10%, maxsize=unlimited )log on( name=農產品信息管理_log, filename=d: 數據庫課程設計農產品信息.

9、ldf, size=1, filegrowth=10%, maxsize=5)1.建立農產品信息表create table 農產品信息表 ( 產品編號 char(10) primary key ,倉庫號 char(10) 產品名 char(10),入庫時間 char(10) not null,庫存量char(10)總 值char(10)2.倉庫信息表create table 倉庫信息表( 倉庫號 char(10) primary key ,面 積 char(10) not null,電話號碼 char(10),)3.職員信息表create table 職員信息表( 管理員號char(10) p

10、rimary key ,姓 名 char(10),性 別 char(10),出生年月 char(10),聯系方式char(10),)4.用戶create table 用戶( 用戶名 char(10) primary key ,密 碼 char(30)*新建視圖*建立農產品信息視圖create view 農產品信息(產品編號,倉庫號,入庫時間,庫存量,總值)asselect 產品編號,倉庫號,入庫時間,庫存量,總值from 農產品信息表建立倉庫信息視圖create view 倉庫信息(倉庫號,面積,電話號碼)asselect 倉庫號,面積,電話號碼from 倉庫信息表建立職員信息create v

11、iew 職員信息(管理員號,姓名,性別,出生年月,聯系方式)asselect 管理員號,姓名,性別,出生年月,聯系方式from 管理員信息表3.4.2源代碼用戶登錄private sub command1_click() adodc1.recordset.movefirst adodc1.recordset.find 用戶名= & text1.text & sql = select 用戶名 from 用戶 whree 用戶名 like text1.text adodc1.recordsource = sql static i as integer if adodc1.recordset.eof

12、 and i 3 then msgbox 用戶名錯誤,請重新輸入!, 32, 提示信息 i = i + 1 text1.text = text1.setfocus exit sub end if adodc1.recordset.movefirst adodc1.recordset.find 密碼= & text2.text & sql = select 密碼 from 用戶 whree 用戶名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof and i 3 then msgbox 密碼錯誤,請重新輸入!, 3

13、2, 提示信息 i = i + 1 text2.text = text2.setfocus exit sub end if if i = 3 then msgbox 請不起,您無權登錄本系統!, 16, 提示信息 form3.show form2.hide exit sub end if form5.show form2.hide text1.text = text2.text = end subprivate sub text2_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.recordset.

14、movefirst adodc1.recordset.find 用戶名= & text1.text & sql = select 用戶名 from 用戶 whree 用戶名 like text1.text adodc1.recordsource = sql static i as integer if adodc1.recordset.eof and i 3 then msgbox 用戶名錯誤,請重新輸入!, 32, 提示信息 i = i + 1 text1.text = text1.setfocus exit sub end if adodc1.recordset.movefirst ado

15、dc1.recordset.find 密碼= & text2.text & sql = select 密碼 from 用戶 whree 用戶名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof and i 3 then msgbox 密碼錯誤,請重新輸入!, 32, 提示信息 i = i + 1 text2.text = text2.setfocus exit sub end if if i = 3 then msgbox 請不起,您無權登錄本系統!, 16, 提示信息 form3.show form2.hide

16、 exit sub end if form5.show form2.hide text1.text = text2.text = end ifend sub密碼修改private sub command1_click() if text2.text text3.text then msgbox 兩次新密碼輸入不一致,請重新輸入!, 32, 提示信息 text2.text = text3.text = text2.setfocus exit sub end if if keycode = 13 and text2.text = text3.text then adodc1.recordset.m

17、ovefirst adodc1.recordset.find 用戶名= & text4.text & sql = select 用戶名 from 用戶 whree 用戶名 like text4.text adodc1.recordsource = sql adodc1.recordset(用戶名) = trim$(text4.text) adodc1.recordset(密碼) = trim$(text2.text) adodc1.recordset.update msgbox 密碼修改成功!, vbinformation text1.text = text2.text = text3.tex

18、t = text4.text = exit sub end ifend subprivate sub text1_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.recordset.movefirst adodc1.recordset.find 密碼= & text1.text & sql = select 密碼 from 用戶 whree 用戶名 like text4.text adodc1.recordsource = sql if adodc1.recordset.eof and i 3 th

19、en msgbox 舊密碼密碼輸入錯誤,請重新輸入!, 32, 提示信息 i = i + 1 text1.text = text1.setfocus exit sub end if if i = 3 then msgbox 請不起,您無權修改本用戶密碼!, 16, 提示信息 form2.show form4.hide exit sub end if text2.setfocus end ifend subprivate sub text3_keyup(keycode as integer, shift as integer) if keycode = 13 and text2.text tex

20、t3.text then msgbox 兩次新密碼輸入不一致,請重新輸入!, 32, 提示信息 text2.text = text3.text = text2.setfocus exit sub end if if keycode = 13 and text2.text = text3.text then adodc1.recordset.movefirst adodc1.recordset.find 用戶名= & text4.text & sql = select 用戶名 from 用戶 whree 用戶名 like text4.text adodc1.recordsource = sql

21、adodc1.recordset(用戶名) = trim$(text4.text) adodc1.recordset(密碼) = trim$(text2.text) adodc1.recordset.update msgbox 密碼修改成功!, vbinformation text1.text = text2.text = text3.text = text4.text = exit sub end ifend subprivate sub text4_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1

22、.recordset.movefirst adodc1.recordset.find 用戶名= & text4.text & sql = select 用戶名 from 用戶 whree 用戶名 like text4.text adodc1.recordsource = sql static i as integer if adodc1.recordset.eof then msgbox 用戶名輸入錯誤,請重新輸入!, 32, 提示信息 text4.text = text4.setfocus exit sub end if text1.setfocus end ifend sub農產品信息查詢

23、private sub command1_click() adodc1.recordset.movefirst adodc1.recordset.find 產品名= & text1.text & sql = select 產品名 from 農產品信息表 whree 產品名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 請不起,暫時還沒有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text =

24、adodc1.recordset(產品編號) text3.text = adodc1.recordset(倉庫號) text4.text = adodc1.recordset(產品名) text5.text = adodc1.recordset(入庫時間) text6.text = adodc1.recordset(庫存量) text7.text = adodc1.recordset(總值)end subprivate sub command6_click() dim i as integer i = msgbox(確定要刪除當前記錄嗎?, 4 + 48, 警告) if i = vbyes t

25、hen adodc1.recordset.delete adodc1.recordset.movenext text1.text = text2.text = text3.text = text4.text = text5.text = text6.text = text7.text = msgbox 刪除成功!, vbinformation, 提示信息 end ifend subprivate sub text1_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.recordset.movefirs

26、t adodc1.recordset.find 產品名= & text1.text & sql = select 產品名 from 農產品信息表 whree 產品名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 請不起,暫時還沒有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(產品編號) text3.text = adodc1.recordset(倉

27、庫號) text4.text = adodc1.recordset(產品名) text5.text = adodc1.recordset(入庫時間) text6.text = adodc1.recordset(庫存量) text7.text = adodc1.recordset(總值) end ifend sub倉庫信息查詢private sub command1_click() adodc1.recordset.movefirst adodc1.recordset.find 倉庫號= & text1.text & sql = select 倉庫號 from 倉庫信息表 whree 倉庫號 l

28、ike text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 請不起,暫時還沒有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(倉庫號) text3.text = adodc1.recordset(面積) text7.text = adodc1.recordset(電話號碼)end subprivate sub command4_click() dim i as in

29、teger i = msgbox(確定要刪除當前記錄嗎?, 4 + 48, 警告) if i = vbyes then adodc1.recordset.delete adodc1.recordset.movenext text1.text = text2.text = text3.text = text7.text = msgbox 刪除成功!, vbinformation, 提示信息 end ifend subprivate sub text1_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.r

30、ecordset.movefirst adodc1.recordset.find 倉庫號= & text1.text & sql = select 倉庫號 from 倉庫信息表 whree 倉庫號 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 請不起,暫時還沒有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(倉庫號) text3.text = ado

31、dc1.recordset(面積) text7.text = adodc1.recordset(電話號碼) end ifend sub職員信息查詢private sub command1_click() adodc1.recordset.movefirst adodc1.recordset.find 姓名= & text1.text & sql = select 姓名 from 職員信息表 whree 姓名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 請不起,暫時還沒有您要查找的信息

32、!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(管理員號) text3.text = adodc1.recordset(姓名) text4.text = adodc1.recordset(性別) text5.text = adodc1.recordset(出生年月) text6.text = adodc1.recordset(聯系方式)end subprivate sub command6_click() dim i as integer i = msgbox(確定要刪除

33、當前記錄嗎?, 4 + 48, 警告) if i = vbyes then adodc1.recordset.delete text1.text = text2.text = text3.text = text4.text = text5.text = text6.text = msgbox 刪除成功!, vbinformation, 提示信息 end ifend subprivate sub text1_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.recordset.movefirst ado

34、dc1.recordset.find 姓名= & text1.text & sql = select 姓名 from 職員信息表 whree 姓名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 請不起,暫時還沒有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(管理員號) text3.text = adodc1.recordset(姓名) text4.

35、text = adodc1.recordset(性別) text5.text = adodc1.recordset(出生年月) text6.text = adodc1.recordset(聯系方式) end ifend sub新增農產品信息private sub command2_click() if text1.text = then msgbox 請輸入農產品編名!, vbexclamation text1.setfocus exit sub end if if text2.text = then msgbox 請輸入農產品名!, vbexclamation text2.setfocus

36、exit sub end if if text3.text = then msgbox 請輸入農產品入庫號!, vbexclamation text3.setfocus exit sub end if adodc1.refresh adodc1.recordset.find (產品編號= & text1.text & ) if not adodc1.recordset.eof then msgbox 產品號重復,請重新輸入!, vbexclamation text1.setfocus exit sub end if adodc1.recordset.find (產品名= & text3.tex

37、t & ) if not adodc1.recordset.eof then msgbox 產品名重復,請重新輸入!, vbexclamation text2.setfocus exit sub else adodc1.recordset.addnew adodc1.recordset.fields(0) = trim$(text1.text) adodc1.recordset.fields(1) = trim$(text2.text) adodc1.recordset.fields(2) = trim$(text3.text) adodc1.recordset.fields(3) = tri

38、m$(text4.text) adodc1.recordset.fields(4) = trim$(text5.text) adodc1.recordset.fields(5) = trim$(text6.text) adodc1.recordset.update msgbox 農產品信息已經添加成功!, vbinformation adodc1.refresh text1.text = text2.text = text3.text = text4.text = text5.text = text6.text = end ifend subprivate sub text6_change()

39、 if keycode = 13 then if text1.text = then msgbox 請輸入農產品編名!, vbexclamation text1.setfocus exit sub end if if text2.text = then msgbox 請輸入農產品名!, vbexclamation text2.setfocus exit sub end if if text3.text = then msgbox 請輸入農產品入庫號!, vbexclamation text3.setfocus exit sub end if adodc1.refresh adodc1.reco

40、rdset.find (產品編號= & text1.text & ) if not adodc1.recordset.eof then msgbox 產品號重復,請重新輸入!, vbexclamation text1.setfocus exit sub end if adodc1.recordset.find (產品名= & text3.text & ) if not adodc1.recordset.eof then msgbox 產品名重復,請重新輸入!, vbexclamation ext2.setfocus exit sub else adodc1.recordset.addnew a

41、dodc1.recordset.fields(0) = trim$(text1.text) adodc1.recordset.fields(1) = trim$(text2.text) adodc1.recordset.fields(2) = trim$(text3.text) adodc1.recordset.fields(3) = trim$(text4.text) adodc1.recordset.fields(4) = trim$(text5.text) adodc1.recordset.fields(5) = trim$(text6.text) adodc1.recordset.up

42、date msgbox 農產品信息已經添加成功!, vbinformation adodc1.refresh text1.text = text2.text = text3.text = text4.text = text5.text = text6.text = end if end ifend sub新增倉庫信息private sub command1_click() if text1.text = then msgbox 請輸入倉庫號!, vbexclamation text1.setfocus exit sub end if if text2.text = then msgbox 請輸入面積!, vbexclamation text2.setfocus exit sub end if adodc1.refresh adodc1.recordset.find (倉庫號= & text1.text & ) if not adodc1.recordset.eof then msgbox 倉庫號重復,請重新輸入!, vbexclamation text1.setfocus exit sub else

溫馨提示

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

評論

0/150

提交評論