圖書館管理系統(tǒng)設計_第1頁
圖書館管理系統(tǒng)設計_第2頁
圖書館管理系統(tǒng)設計_第3頁
圖書館管理系統(tǒng)設計_第4頁
圖書館管理系統(tǒng)設計_第5頁
已閱讀5頁,還剩30頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、jiangsu university 項 目 實 踐 ii圖書館管理系統(tǒng)library management system學 院 名 稱 : 計算機科學與通信工程 專 業(yè) 班 級 : 嵌入式軟件2012 學 號 : 3120609004 學 生 姓 名 : 孫靜 指 導 教 師 : 宋和平 2014 年 6 月 正文一、課程設計概述1,目的: 本系統(tǒng)為學校的圖書館信息而設計,實現(xiàn)信息處理的自動化、規(guī)范化,主要用于處理圖書日常借閱和還書、圖書入庫、各種查詢操作,系統(tǒng)具有以下功能:1)圖書借閱與歸還處理,罰款與賠償2)圖書與讀者信息查詢與修改、刪除3)圖書入庫與圖書的信息修改、刪除4)員工信息的修

2、改、刪除2,任務:1) 新建數(shù)據(jù)庫,進行表的設計,實現(xiàn)數(shù)據(jù)錄入與更新2) 創(chuàng)建界面,實現(xiàn)客戶端的友好界面3) 對系統(tǒng)進行功能的實現(xiàn)4) 解決實現(xiàn)過程中的問題3,開發(fā)環(huán)境:本系統(tǒng)采用sqlserver創(chuàng)建后臺數(shù)據(jù)庫,前臺開發(fā)工具采用的visualstudio2010,編程語言為c#二、項目的需求分析1.分析系統(tǒng)的功能(1) 所有人員需要登陸才能操作系統(tǒng),可以修改密碼。(2) 圖書管理員可以添加圖書(包括書號、書名、出版社、作者、圖書簡介、價格、封面圖片等信息)、刪除圖書,假設每種圖書只有一本。(3) 圖書管理員可以添加借閱者(包括借書證號、姓名、類別(教師或?qū)W生)、學院、性別、照片等信息)、刪除

3、借閱者。(4) 借閱者可以根據(jù)書名或者作者模糊查詢圖書,可以查看自己所借圖書信息。(5) 借閱者可以借閱圖書,此時需要記錄借書日期和應還日期信息(設置借閱日期為30天)。(6) 借閱者包括教師和學生,教師最多可以借閱10本圖書,學生最多可以借閱5本圖書。(7) 借閱者如果有超期圖書則不能再借。(8) 借閱者還書時,檢查是否超期,如果超期,按照0.1元/天計算罰款金額,繳納罰款后還書。如果圖書丟失,按照圖書價格的兩倍賠償。(9) 實現(xiàn)系統(tǒng)時請考慮數(shù)據(jù)的參照完整性,例如借閱圖書時應該是存在的圖書,刪除圖書時同時刪除該圖書的借閱信息。2. 劃分模塊a. 大的功能(見需求分析)b. 描述:填寫信息(見

4、概念模型,如何創(chuàng)建數(shù)據(jù)庫)管理員有權利對人員和圖書進行添加刪除操作,但不能刪除不存在的書或者人,添加也不能出現(xiàn)重復老師或者學生借閱時能夠看到未被借出的書的信息,并且不可以借不存在或者已借出的書怎樣處理借閱與歸還以及管理的事務可根據(jù)登錄人員的不同劃分為3個模塊(即管理員,老師,學生),分別實現(xiàn)各自的功能??筛鶕?jù)不同的操作方式劃分模塊,如圖:三、概念模型1.e-r圖分析。四、數(shù)據(jù)模型根據(jù)e-r圖轉(zhuǎn)換成關系模型(關系表)新建數(shù)據(jù)庫create database bookssystem創(chuàng)建表 create table books( bookid varchar(20), bname varchar(2

5、0) not null, bpublish varchar(20) not null, bauthor varchar(20) not null, bbrief varchar(20) , bprice money , bcover varchar(20) not null, primary key(bookid)create table bookout( readerid varchar(20) , bookid varchar(20) , outdate datetime, isreturn int, primary key(readerid,bookid), )create table

6、users( userid varchar(20) not null, username varchar(20)not null, usertype varchar(20), primary key(userid)create table readers( rid varchar(20) not null, rname varchar(20)not null, rtype varchar(20), rsex varchar(10) not null, rphone int, rmoney money, primary key(rid)1. books表:2,booksout表:3,reaser

7、s表:4,users表:五、功能設計1,登錄流程圖:根據(jù)登錄的信息判斷登錄者的類型,據(jù)此跳出不同的窗體界面來進行不同的操作。private void button1_click(object sender, eventargs e) sqlconnection con = new sqlconnection(); con.connectionstring = data source =(local);initial catalog =bookssystem;integrated security=true; con.open();/用于連接數(shù)據(jù)庫 sqlcommand da = new sql

8、command(select count(*) from dbo.users where userid =+textbox1 .text + and userpassword = +textbox2 .text + and usertype=+combobox1 .text +, con);/通過填入信息判斷是否是系統(tǒng)允許人員登錄 int flag = (int)da.executescalar(); da.connection.close(); con.close (); if (flag !=1) messagebox .show (用戶或密碼錯誤); else b = combobox1

9、.text; a = textbox1.text; d = textbox2.text; if ( combobox1 .text=管理員 )/跳出管理操作界面 new form1().hide(); form2 f2 = new form2(); f2.show(); else /跳出借閱界面 if(combobox1 .text =學生|combobox1 .text =老師) new form1().hide(); form3 f3 = new form3(); f3.show(); form1 f1 = new form1(); f1.visible = false; 2,管理界面操作

10、的流程圖:需要判斷是圖書操作還是人員操作。還需判斷是否存在,是否重復添加,是否刪除了原本不存在的圖書和人員。/用一個button實現(xiàn)人員的添加和刪除(添加圖書時與此操作同理)if (button3.text = add) /連接數(shù)據(jù)庫,添加符合要求的圖書并顯現(xiàn)出來 sql a = new sql(); datagridview1.datasource = a.dt(insert into dbo.readers(rid,rname,rtype,rsex,rphone,rmoney) values( + textbox8.text + , + textbox9.text + , + textbo

11、x10.text + , + textbox11.text + , + textbox12.text + , + textbox13.text + ), readers); datagridview1.datasource = a.dt( select * from dbo.readers, readers); textbox8.text = ; else if (button3 .text =delete) /連接數(shù)據(jù)庫,并判斷所要刪除的人員數(shù)據(jù)庫中是否存在,若不存在,則進行處理 sqlconnection con = new sqlconnection(); con.connections

12、tring = data source =(local);initial catalog =bookssystem;integrated security=true; con.open(); string str = select count (userid) from dbo.users where userid=+textbox8 .text + ; sqlcommand db = new sqlcommand(str, con); int c = int.parse(db.executescalar().tostring(); if (c = 0) messagebox.show(該人員

13、不存在); else /人員存在時實行刪除操作并把操作后的數(shù)據(jù)表顯現(xiàn)出來 sqlcommand da = new sqlcommand(delete from dbo.readers where rid= + textbox8.text + , con); da.executenonquery(); sql b = new sql(); / datagridview1.datasource = b.dt(delete from dbo.readers where rid= + textbox8.text + , readers); datagridview1.datasource = b.dt

14、( select * from dbo.readers, readers); da.connection.close(); con.close(); 3,借還界面的流程圖:借書時有些限制也需要實現(xiàn)。比如,學生只能最多借5本,老師最多只能借10本。如果有超期圖書則不能借。/用button1實現(xiàn)查詢,若書不滿足搜索條件顯示該書不存在;在歸還時,查詢此書是否借出等信息 private void button1_click(object sender, eventargs e) if (button1 .text = 搜索) sql b = new sql(); datagridview1.datas

15、ource = b.dt( select * from dbo.books join dbo.bookout on dbo.bookout.bookid = dbo.books.bookid where dbo.bookout.isreturn=1 and bname like % + textbox1.text + % and bauthor like % + textbox7.text + %, books); sqlconnection con = new sqlconnection(); con.connectionstring = data source =(local);initi

16、al catalog =bookssystem;integrated security=true; con.open(); string str= select count(dbo.bookout.bookid) from dbo.books join dbo.bookout on dbo.bookout.bookid = dbo.books.bookid where dbo.bookout.isreturn=1 and bname like % + textbox1.text + % and bauthor like % + textbox7.text + %; sqlcommand da

17、= new sqlcommand(str , con); int c=int.parse (da.executescalar().tostring(); if (c = 0) messagebox.show(該書不存在); else if(button1 .text =確認歸還) sql b = new sql(); datagridview1.datasource = b.dt( select * from dbo.books join dbo.bookout on dbo.bookout.bookid = dbo.books.bookid where dbo.books.isreturn

18、= 0 and dbo.books.bname like% + textbox1.text + % and bauthor like % + textbox7.text + %and readerid=+form1.a + , return); /此鍵用于確認借書或者還書private void button2_click(object sender, eventargs e) /用于獲取借書時日期,并顯示在textbox5里 textbox5.text = system.datetime.now.tostring(); /用于獲取還書日期 textbox6.text = system.dat

19、etime.now.adddays(30).tostring(); sqlconnection con = new sqlconnection(); con.connectionstring = data source =(local);initial catalog =bookssystem;integrated security=true; con.open(); string str = select count(dbo.books.bookid) from dbo.books join dbo.bookout on dbo.bookout.bookid = dbo.books.book

20、id where dbo.books.isreturn = 0 and readerid= + form1.a + ; sqlcommand da = new sqlcommand(str, con); int c = int.parse(da.executescalar().tostring();/判斷借書者身份,限制借書數(shù) if (form1.b = 學生) if (c = 5) messagebox.show(不得超過5本!); else sqlcommand da1 = new sqlcommand(update dbo.books set dbo.books.isreturn=0 w

21、here dbo.books.bookid = + textbox3.text + and exists(select * from dbo.books join dbo.bookout on dbo.bookout.bookid=dbo.books.bookid join dbo.readers on readerid=rid where dbo.bookout.bookid= + textbox3.text + ), con); da1.executenonquery(); sql b = new sql(); datagridview1.datasource = b.dt( select

22、 * from dbo.books, books); if (da.executenonquery() != 0) sqlcommand db = new sqlcommand(update dbo.bookout set isreturn=0 ,readerid= + form1.a + where bookid= + textbox3.text + and exists(select * from dbo.books join dbo.bookout on dbo.bookout.bookid=dbo.books.bookid join dbo.readers on readerid=ri

23、d where dbo.bookout.bookid= + textbox3.text + ), con); db.executenonquery(); db.connection.close(); con.close(); da.connection.close(); con.close(); else if (c = 10) messagebox.show(不得超過10本!); else sqlcommand da1 = new sqlcommand(update dbo.books set dbo.books.isreturn=0 where dbo.books.bookid = + t

24、extbox3.text + and exists(select * from dbo.books join dbo.bookout on dbo.bookout.bookid=dbo.books.bookid join dbo.readers on readerid=rid where dbo.bookout.bookid= + textbox3.text + ), con); da1.executenonquery(); sql b = new sql(); datagridview1.datasource = b.dt( select * from dbo.books, books);

25、if (da.executenonquery() != 0) /操作完成時更新數(shù)據(jù)庫 sqlcommand db = new sqlcommand(update dbo.bookout set isreturn=0 ,readerid= + form1.a + where bookid= + textbox3.text + and exists(select * from dbo.books join dbo.bookout on dbo.bookout.bookid=dbo.books.bookid join dbo.readers on readerid=rid where dbo.boo

26、kout.bookid= + textbox3.text + ), con); db.executenonquery(); db.connection.close(); con.close(); da.connection.close(); con.close(); 6、 運行過程1. 登陸界面:需要填寫用戶名,密碼與用戶類型管理員登錄:老師登錄:學生登錄:2. 管理員操作:欲添加圖書時需要填寫信息,此時bookid必填,且不能出現(xiàn)添加同本書的情況:添加人員,類似添加圖書,出現(xiàn)重復添加時:(主鍵的設置)不添加同一個人時:刪除人員時,若此人不存在,則提醒:3,老師或者學生登錄時出現(xiàn)借閱者操作界面

27、,可以實現(xiàn)借書與還書功能。借閱時可根據(jù)書名或者作者名進行模糊查詢,并且已借出書籍不可再借。借不存在書籍時出現(xiàn)提醒。4,還書時,系統(tǒng)根據(jù)登陸時的用戶名顯示出所借的書的詳細信息,以便輕松還書,根據(jù)書的id號來還書。5,當歸還時產(chǎn)生借閱記錄,欠款金額的查詢項等,點擊即可查詢,若有丟失,可直接返回借閱界面進行信息查詢,并及時賠款:6,登錄界面時可以進行密碼的修改7、 個人遇到的困難、解決方法與個人小結(jié)1,起初連接數(shù)據(jù)庫時有問題解決發(fā)法:通過查閱書籍與上網(wǎng)查資料等手段,掌握兩種連接數(shù)據(jù)庫的手段與方法。先創(chuàng)建sql連接類,然后創(chuàng)建實例如:sql b = new sql();再在datagridview導出

28、數(shù)據(jù)庫的表格 datagridview1.datasource = b.dt( select * from dbo.books join dbo.bookout on dbo.bookout.bookid = dbo.books.bookid where dbo.bookout.isreturn=1 and bname like % + textbox1.text + % and bauthor like % + textbox7.text + %, books);這種方法比較慢,還有一種是比較快速的方式,如: sqlconnection con = new sqlconnection();

29、con.connectionstring = data source =(local);initial catalog =bookssystem;integrated security=true; con.open(); string str = select count (userid) from dbo.users where userid=+textbox8 .text + ; sqlcommand db = new sqlcommand(str, con);2,問題:創(chuàng)建數(shù)據(jù)庫時發(fā)現(xiàn)book表與bookout表雖然可以連接,但是在借出書之后,更新表bookout時可以將isreturn

30、設為0,表示已借出,但book表里面沒有顯示出已借出,其他人員搜索時,會出現(xiàn)同一本書,被兩個人同時借走的狀況。解決方法:在book表里面也設置一個isreturn屬性,當借出書時,兩表連接,使得isreturn 都變?yōu)?,此時若有人想借書,在gridview顯示的未借出列表中就不會出現(xiàn)該書,不會導致沖突。3,問題:在計算日期時,使用的此方法: 借書日期: textbox5.text = system.datetime.now.tostring(); 還書日期: textbox6.text = system.datetime.now.adddays(30).tostring();因此導致在計算欠

31、款時,價錢出現(xiàn)了上千的情況,并沒有按照小時來算超期時間解決方法:先連接數(shù)據(jù)庫,從數(shù)據(jù)庫中讀取借出時的日期,由此讀取當前日期與借出日期的差值,并轉(zhuǎn)化為天數(shù) int i = d.days-30;減30是因為超過30 天之后才需要罰款 sqlconnection con = new sqlconnection(); con.connectionstring = data source =(local);initial catalog =bookssystem;integrated security=true; con.open(); string str = select outdate from

32、dbo.bookout where readerid=+form1 .a + and isreturn=0; sqlcommand da = new sqlcommand(str, con); string s = da.executescalar().tostring(); datetime t = convert.todatetime(s); datetime t1 = datetime.now; timespan d = t1 - t; int i = d.days-30; double ii = (double)(i / 10); textbox1.text = ii.tostring

33、() + 元;4,問題:起初還書時,發(fā)現(xiàn)自己不光能查閱到自己所未還的書,還能查閱到其他人未還的書。此漏洞屬于泄露隱私的情況。只要限定用戶名和isreturn=0即可,也造成了數(shù)據(jù)的多余。又因為登錄界面與借還界面不在一個form里,限定自己的用戶名時必須要回到原界面否則需要再次輸入用戶名,顯得累贅和繁瑣。解決方法:在form1中將登陸時所填的用戶名設為靜態(tài)變量,因此查詢所需還的書時,在sql語句中可以這樣寫:select * from dbo.books join dbo.bookout on dbo.bookout.bookid = dbo.books.bookid where dbo.boo

34、ks.isreturn = 1 and readerid= + form1.a + 同理,只要在登錄時將登錄時的密碼和用戶類型設為靜態(tài)變量,修改密碼和判斷用戶可借多少本書時就變得容易得多了。如: if (form1 .b=學生) sqlconnection con = new sqlconnection(); con.connectionstring = data source =(local);initial catalog =bookssystem;integrated security=true; con.open(); string str =select count(dbo.book

35、s.bookid) from dbo.books join dbo.bookout on dbo.bookout.bookid = dbo.books.bookid where dbo.books.isreturn = 0 and readerid= + form1.a + ; sqlcommand da = new sqlcommand(str, con); int c = int.parse(da.executescalar().tostring(); if (c=5) messagebox.show(不得超過5本!); 5,問題:在登陸時,無法判斷所填信息是否是數(shù)據(jù)庫中所有的信息,即,該用戶是否存在,或者,所填信息用戶名與密碼,用戶類型是否匹配的問題。解決方法:sqlcommand da = new sqlcommand(select count(*) from dbo.users where userid =+tex

溫馨提示

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

評論

0/150

提交評論