C#圖書信息管理系統(tǒng)_第1頁
C#圖書信息管理系統(tǒng)_第2頁
C#圖書信息管理系統(tǒng)_第3頁
C#圖書信息管理系統(tǒng)_第4頁
C#圖書信息管理系統(tǒng)_第5頁
已閱讀5頁,還剩31頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上精選優(yōu)質(zhì)文檔-傾情為你奉上專心-專注-專業(yè)專心-專注-專業(yè)精選優(yōu)質(zhì)文檔-傾情為你奉上專心-專注-專業(yè)北 華 航 天 工 業(yè) 學(xué) 院C程序設(shè)計課程設(shè)計報告課程設(shè)計題目: 圖書信息管理系統(tǒng) 作者所在系部: 計算機(jī)科學(xué)與工程系 作者所在專業(yè): 計算機(jī)科學(xué)與技術(shù) 作者所在班級: B08514 班 作 者 姓 名 : 韓 旭 作 者 學(xué) 號 : 3號 指導(dǎo)教師姓名: 楊麗娟 完 成 時 間 : 2011年6月6日 北華航天工業(yè)學(xué)院教務(wù)處制課程設(shè)計任務(wù)書課題名稱圖書信息管理系統(tǒng)完成時間 2011/6/6指導(dǎo)教師楊麗娟職稱講師學(xué)生姓名韓 旭班 級B08514班總體設(shè)計要求和技術(shù)要點(diǎn)

2、圖書信息管理系統(tǒng)基本功能描述圖書信息錄入功能(圖書信息包括ISBN號、書名、作者、出版單位、出版時間、價格等)圖書信息瀏覽功能查詢和排序功能:按書名查詢、按作者名查詢等圖書信息的刪除與修改要求要求操作簡便功能齊全,風(fēng)格統(tǒng)一沒有明顯錯誤和異常數(shù)據(jù)格式驗證工作內(nèi)容及時間進(jìn)度安排時間:此次課程設(shè)計時間為兩周,第15、16周,共40學(xué)時。分四個階段完成:1.分析設(shè)計階段:明確設(shè)計要求,找出實(shí)現(xiàn)方法,這一階段在第1天完成。2.編碼調(diào)試階段:根據(jù)設(shè)計分析方案編寫C#代碼,然后調(diào)試該代碼,實(shí)現(xiàn)課題要求的功能。這一階段在第2-8天完成。3.總結(jié)報告階段:總結(jié)設(shè)計工作,撰寫課程設(shè)計報告,這一階段在第8-9天完成

3、。4.考核階段:這一階段在第10天完成。地點(diǎn):計算機(jī)系實(shí)驗室課程設(shè)計成果1與設(shè)計內(nèi)容對應(yīng)的軟件程序2課程設(shè)計報告書3成果使用說明書摘要圖書館作為一種信息資源的集散地,圖書借閱頻繁,用戶管理多變,包含大量的信息數(shù)據(jù)。對于這些數(shù)據(jù)的管理,需要一個完善的圖書管理系統(tǒng)來實(shí)現(xiàn)對圖書,用戶的實(shí)時管理。系統(tǒng)的主要任務(wù)就是對圖書書目、圖書借閱、圖書用戶查詢進(jìn)行統(tǒng)一管理,達(dá)到各類用戶的需求。管理員對數(shù)據(jù)庫進(jìn)行操作,完成借閱、添加、刪除、統(tǒng)計等各功能。圖書管理系統(tǒng)是典型的信息管理系統(tǒng)(MIS),其開發(fā)主要包括后臺數(shù)據(jù)庫的建立和維護(hù)以及前端應(yīng)用程序的開發(fā)兩個方面。對于前者要求建立起數(shù)據(jù)一致性和完整性強(qiáng)、數(shù)據(jù)安全性好

4、的庫。而對于后者則要求應(yīng)用程序功能完備,易使用等特點(diǎn)?;贑#開發(fā)的學(xué)校圖書管理系統(tǒng),在借書模塊和還書模塊中應(yīng)解決兩個難點(diǎn).其一,在借書模塊中不僅要考慮數(shù)據(jù)綁定問題,即輸入讀者編號即能顯示該讀者的詳細(xì)信息,而且要實(shí)現(xiàn)借書過程中能根據(jù)讀者類型,進(jìn)行可借數(shù)量檢查,同時系統(tǒng)可以控制不同類型讀者的可借數(shù)量.其二,還書模塊在還書操作時,能自動根據(jù)當(dāng)前日期進(jìn)行所借天數(shù)檢查,并根據(jù)不同讀者類型可借天數(shù)不同,計算出相應(yīng)的超期天數(shù)和應(yīng)交納的滯納金.系統(tǒng)的應(yīng)用需求,按照數(shù)據(jù)庫設(shè)計理論一步一步地給出了系統(tǒng)需求說明書、局部ER圖、全局ER圖、系統(tǒng)關(guān)系模式,子模式,利用MS SQL Server2005建立了數(shù)據(jù)庫。設(shè)

5、計充分利用C#、MS SQL Server2005數(shù)據(jù)庫技術(shù)的強(qiáng)大力量,提高了編程效率和可靠性。關(guān)鍵詞:圖書管理 MS SQL Server DataGridView控件 skinEngine控件目 錄 TOC o 1-3 h z u 第1章 緒論當(dāng)今時代是飛速發(fā)展的信息時代。在各行各業(yè)中離不開信息處理,這正是計算機(jī)被廣泛應(yīng)用于信息管理系統(tǒng)的環(huán)境。計算機(jī)的最大好處在于利用它能夠進(jìn)行信息管理。使用計算機(jī)進(jìn)行信息控制,不僅提高了工作效率,而且大大的提高了其安全性。尤其對于復(fù)雜的信息管理,計算機(jī)能夠充分發(fā)揮它的優(yōu)越性。計算機(jī)進(jìn)行信息管理與信息管理系統(tǒng)的開發(fā)密切相關(guān),系統(tǒng)的開發(fā)是系統(tǒng)管理的前提。本系統(tǒng)

6、就是為了管理好圖書館信息而設(shè)計的。1.1課題研究現(xiàn)狀分析圖書館作為一種信息資源的集散地,圖書和用戶借閱資料繁多,包含很多的信息數(shù)據(jù)的管理,現(xiàn)今,有很多的圖書館都是初步開始使用,甚至尚未使用計算機(jī)進(jìn)行信息管理。根據(jù)調(diào)查得知,他們以前對信息管理的主要方式是基于文本、表格等紙介質(zhì)的手工處理,對于圖書借閱情況(如借書天數(shù)、超過限定借書時間的天數(shù))的統(tǒng)計和核實(shí)等往往采用對借書卡的人工檢查進(jìn)行,對借閱者的借閱權(quán)限、以及借閱天數(shù)等用人工計算、手抄進(jìn)行。數(shù)據(jù)信息處理工作量大,容易出錯;由于數(shù)據(jù)繁多,容易丟失,且不易查找??偟膩碚f,缺乏系統(tǒng),規(guī)范的信息管理手段。盡管有的圖書館有計算機(jī),但是尚未用于信息管理,沒有

7、發(fā)揮它的效力,資源閑置比較突出,這就是管理信息系統(tǒng)的開發(fā)的基本環(huán)境。 本次課題為:圖書基本信息管理系統(tǒng),它的主要功能是先通過用戶身份驗證,然后即可登錄圖書基本信息管理系統(tǒng),然后通過增、刪、查、改操作對圖書基本信息進(jìn)行管理和維護(hù)。1.1.1 本領(lǐng)域內(nèi)已開展的研究工作1. 理論研究基礎(chǔ)(1) 后臺以SQL server 2005數(shù)據(jù)庫支持。(2) 前臺以 Microsoft Visual Studio 2010為開發(fā)環(huán)境,實(shí)現(xiàn)圖書基本信息管理的增、刪、查、改操作。2. 技術(shù)層面的支持(1)系統(tǒng)的設(shè)計與實(shí)現(xiàn)應(yīng)采用MVC分層模式。(2)系統(tǒng)界面采用MDI方式,即用戶登錄后進(jìn)入主窗體,主窗體通過菜單進(jìn)入

8、子窗體。1.1.2 已經(jīng)取得的研究成果在此模塊對社會上已經(jīng)存在的相關(guān)系統(tǒng)進(jìn)行總結(jié)、分析。1.2選題的目的及意義目的:使圖書信息管理電子化、信息化,減少管理員工作量,使其工作更輕松。意義:極大提高了圖書信息管理的工作效率。第2章 系統(tǒng)需求分析設(shè)計一個簡單的圖書管理系統(tǒng)包括管理員信息、圖書館內(nèi)書籍的信息、學(xué)校在校學(xué)生的信息以及學(xué)生的借閱信息。此系統(tǒng)功能分為面向?qū)W生和面向管理員兩部分,其中學(xué)生可以進(jìn)行借閱、.歸還和查詢書籍等操作,管理員可以完成書籍和學(xué)生的增加,刪除和修改以及對學(xué)生,借閱、歸還的確認(rèn)。1)需求概要:A可以有多個管理員管理該系統(tǒng),管理員通過帳號和密碼登陸系統(tǒng);B一個學(xué)生可以最多借閱5本

9、書籍;2)系統(tǒng)功能包括:a學(xué)生管理:讀者的添加、修改;b圖書管理:圖書添加、修改、刪除;c圖書查詢:按圖書的書名、作者;d圖書借閱:管理員根據(jù)學(xué)生的借閱情況對其進(jìn)行,新借入、歸還等操作。系統(tǒng)采用先進(jìn)的兩層體系結(jié)構(gòu),Client(客戶端)負(fù)責(zé)提供表達(dá)邏輯、顯示用戶界面信息、基本操作;Server(服務(wù)器端)負(fù)責(zé)實(shí)現(xiàn)數(shù)據(jù)服務(wù)。2.1 問題的提出數(shù)據(jù)處理手工操作,工作量大,出錯率高,出錯后不易更改。圖書館采取手工方式對圖書借閱情況進(jìn)行人工管理,由于信息比較多,圖書借閱信息的管理工作混亂而又復(fù)雜;一般借閱情況是記錄在借書證上,圖書的數(shù)目和內(nèi)容記錄在文件中,圖書館的工作人員和管理員也只是當(dāng)時對它比較清楚

10、,時間一長,如再要進(jìn)行查詢,就得在眾多的資料中翻閱、查找了,造成查詢費(fèi)時、費(fèi)力。如要對很長時間以前的圖書進(jìn)行更改就更加困難了。 基于這此問題,我認(rèn)為有必要建立一個圖書管理系統(tǒng),使圖書管理工作規(guī)范化,系統(tǒng)化,程序化,避免圖書管理的隨意性,提高信息處理的速度和準(zhǔn)確性,能夠及時、準(zhǔn)確、有效的查詢和修改圖書情況。2.2 系統(tǒng)的設(shè)計目標(biāo)本系統(tǒng)是對圖書館進(jìn)行一體化管理的軟件系統(tǒng),其核心管理思想是實(shí)現(xiàn)對圖書信息增、刪、改的管理,以及對用戶的增、刪、改的管理。此系統(tǒng)功能分為面向?qū)W生和面向管理員兩部分,其中學(xué)生可以進(jìn)行借閱、.歸還和查詢書籍等操作,管理員可以完成書籍和學(xué)生的增加,刪除和修改以及對學(xué)生,借閱、歸還

11、的確認(rèn)。第3章 系統(tǒng)總體設(shè)計3.1系統(tǒng)功能設(shè)計 本系統(tǒng)實(shí)現(xiàn)了圖書基本信息的查閱、借閱圖書的管理等??傮w分為登錄注冊、圖書信息管理、用戶信息管理、圖書借閱管理、退出系統(tǒng)等5個模塊,如圖3-1所示:圖3-1 系統(tǒng)功能模塊圖各功能模塊設(shè)計: 登錄注冊模塊:用于登錄系統(tǒng)或注冊新用戶。圖書信息管理模塊:是對圖書進(jìn)行添加、刪除、修改、查閱、排序等操作。用戶信息管理模塊:是管理員對用戶信息的維護(hù)。圖書借閱管理模塊:用戶借閱圖書的管理。退出系統(tǒng)模塊:退出系統(tǒng)。一、系統(tǒng)登錄或注冊登錄為用戶使用系統(tǒng)的起始點(diǎn),用戶必須先通過身份驗證,方可對圖書基本信息進(jìn)行相關(guān)操作,登錄流程如3-2圖所示: 圖3-2 登錄模塊流程圖

12、圖3-2登錄注冊簡要說明及功能描述:功能主要是用于確保用戶在提供正確的驗證信息之后,可以進(jìn)一步使用本系統(tǒng)。二、圖書基本信息資料維護(hù)查閱圖書信息,對圖書的增、刪、查、改、排序等操作。結(jié)構(gòu)模塊如圖3-3所示:圖3-2圖書管理模塊三、用戶基本信息資料維護(hù) 該模塊是為管理員設(shè)置,管理員通過登錄系統(tǒng)對用的管理包括:增、刪、查看等功能;四、圖書借閱管理該模塊是實(shí)現(xiàn)對用戶借閱圖書的記錄,流程如圖3-3所示: 圖3-3 圖書借閱流程3.2數(shù)據(jù)庫的設(shè)計本系統(tǒng)采用sql server 2005數(shù)據(jù)庫管理系統(tǒng),創(chuàng)建的數(shù)據(jù)庫名稱為:Library數(shù)據(jù)庫中包含3張表,各表功能及描述如表31所示:表3-1 數(shù)據(jù)庫中的表表

13、名作用library_login用于存儲用戶信息librar_information用于存儲圖書基本信息borrow用于存儲用戶借閱圖書信息3.3庫中各個表的設(shè)計一、用戶基本信息表用戶基本信息表library_login 用于維護(hù)系統(tǒng)用戶的基本情況,主鍵為ID。表中各字段定義及描述如表3-2所示。表3-2 library_login表字段名數(shù)據(jù)類型長度是否為空是否主鍵字段意義IDIntNO是用戶編號Namevarchar20N0賬號PasswordVarchar20NO密碼TypeIntNO類型二、圖書基本信息表圖書基本信息表librar_information 用于維護(hù)系統(tǒng)圖書的基本情況,主

14、鍵為ID。表中各字段定義及描述如表3-3所示。表3-2 library_login表字段名數(shù)據(jù)類型長度是否為空是否主鍵字段意義IDIntNO是圖書編號ISBNvarchar30N0ISBN書名Varchar10NO書名作者Varchar10NO作者出版社varchar20NO出版社出版時間DatetimeNO出版時間價格IntNO單價庫存數(shù)量IntYES庫存量三、借閱圖書信息表借閱圖書信息表borrow 用于維護(hù)系統(tǒng)圖書的基本情況,主鍵為ID。表中各字段定義及描述如表3-4所示。表3-2 library_login表字段名數(shù)據(jù)類型長度是否為空是否主鍵字段意義IDIntNO是編號Statetim

15、eDatetimeN0借書時間EndtimeDatetimeYES還書時間User_IDIntNO外鍵用戶編號Book_IDIntNO外鍵圖書編號PriceIntYES罰款第4章 系統(tǒng)實(shí)現(xiàn)4.1數(shù)據(jù)庫操作類String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True;4.2登錄注冊模塊實(shí)現(xiàn)本系統(tǒng)的登錄界面如圖4-1所示,輸入姓名和密碼,點(diǎn)擊登錄,判斷用戶名和密碼是否正確,正確可進(jìn)入系統(tǒng)主界面,否則提示錯誤。點(diǎn)擊注冊,轉(zhuǎn)到注冊窗口。如圖4-2所示 圖4-1 登錄界面登錄界面的代碼為:nam

16、espace WindowsFormsApplication1public partial class login : Formint type = -1; public login() this.CenterToScreen(); InitializeComponent(); private void btn_agreen_Click(object sender, EventArgs e) if (type != -1) try String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=Tr

17、ue; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string str = select password from dbo.library_login where name= + tbx_user.Text + and type=+type; SqlCommand comd = new SqlCommand(str, conn); SqlDataReader da = comd.ExecuteReader(); if (da.Read() if (dapassword.ToString().Trim() = tb

18、x_password.Text.ToString().Trim() conn.Close(); this.Hide(); first f3 = new first(tbx_user.Text.ToString(),type); f3.MdiParent = this.MdiParent; f3.Show(); else MessageBox.Show(您輸入的密碼有誤,請核實(shí)后再輸!); else MessageBox.Show(您輸入的用戶名或用戶身份有誤!); conn.Close(); catch (Exception) else MessageBox.Show(請選擇輸入類型!); p

19、rivate void tbn_zhuce_Click(object sender, EventArgs e) this.Hide(); reg f2 = new reg(); f2.MdiParent = this.MdiParent; f2.Show(); private void rbtn_type1_CheckedChanged(object sender, EventArgs e) type = 1; 圖4-2注冊主界面注冊界面代碼為:namespace WindowsFormsApplication1 public partial class reg : Form public r

20、eg() this.CenterToScreen(); InitializeComponent(); private void btn_agreen_Click(object sender, EventArgs e) try String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); int type = 0; if (cbx_type.Text.ToString

21、() = 管理員) type = 1; SqlCommand comd,comd1; string sql = select * from library_login where name=+tbx_users.Text+and type=+type; comd = new SqlCommand(sql,conn); SqlDataReader dr = comd.ExecuteReader(); if (!dr.Read() if (tbx_pass.Text.ToString() = tbx_passwor.Text.ToString() dr.Close(); string str =

22、insert into library_login(name,password,type) values( + tbx_users.Text.ToString() + , + tbx_pass.Text.ToString() + , + type + ); comd1 = new SqlCommand(str, conn); comd1.ExecuteNonQuery(); MessageBox.Show(登錄成功!您的身份是 + cbx_type.Text, 提示, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); conn.Close(); t

23、his.Hide(); login f3 = new login(); f3.MdiParent = this.MdiParent; f3.Show(); else MessageBox.Show(您兩次輸入的密碼不匹配); else MessageBox.Show(該用戶名已存在); conn.Close(); catch (Exception) private void reg_Load(object sender, EventArgs e) this.skinEngine1.SkinFile = SteelBlack.ssk; 4.3 圖書信息管理模塊實(shí)現(xiàn) 圖4-3歡迎界面1、顯示圖書信

24、息窗體如圖4-4所示 圖4-4圖書信息主要代碼:private void Form3_Load(object sender, EventArgs e) this.skinEngine1.SkinFile = SteelBlack.ssk; seach();private void seach()String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True;SqlConnection conn = new SqlConnection(strCon);SqlCommand comd = ne

25、w SqlCommand();string str = select ISBN,書名,作者,出版社,CONVERT(char(10), 出版時間, 120)AS 出版時間,價格,庫存數(shù)量 from librar_information;da = new SqlDataAdapter(str, conn);SqlCommandBuilder cb = new SqlCommandBuilder(da);ds = new DataSet();da.Fill(ds, librar_information);dgv_infrom.DataSource = ds;dgv_infrom.DataMembe

26、r = librar_information;dgv_infrom.Rows0.Selected = true;conn.Close(); private void btn_gx_Click(object sender, EventArgs e) String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string str = update librar_in

27、formation set ISBN= + tbx_ISBN.Text.ToString().Trim(); str += ,書名= + tbx_bookname.Text.ToString().Trim() + ,作者= + tbx_usersname.Text.ToString().Trim(); str += ,出版社= + tbx_cbdw.Text.ToString().Trim() + ,出版時間=+ Convert.ToDateTime(tbx_date.Text)+; str += ,價格= + Convert.ToInt32(tbx_jg.Text); str+=,庫存數(shù)量=

28、 + Convert.ToInt32(tbx_number.Text)+where ISBN=+tbx_ISBN.Text.ToString().Trim()+; SqlCommand comd = new SqlCommand(str,conn); comd.ExecuteNonQuery(); conn.Close(); MessageBox.Show(修改成功!); seach(); private void btn_sc_Click(object sender, EventArgs e) String strCon = Data Source=(local);Initial Catal

29、og=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string sql = delete from librar_information where ISBN=+tbx_ISBN.Text.ToString().Trim()+; SqlCommand comd = new SqlCommand(sql, conn); comd.ExecuteNonQuery(); MessageBox.Show(刪除成功!); conn.Close(); seach

30、(); 添加圖書窗口如圖4-5所示 圖4-5 添加圖書信息主要代碼如下:private void btn_tj_Click(object sender, EventArgs e) try if (tbx_ISBN.Text != string.Empty) if (tbx_usersname.Text != string.Empty) if (dtp_date.Text!= string.Empty) if (tbx_cbdw.Text != string.Empty) if (tbx_bookname.Text != string.Empty) if (tbx_jg.Text != stri

31、ng.Empty) String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open();string sql = insert into librar_information(ISBN,書名,作者,出版社,出版時間,價格,庫存數(shù)量);sql += values( + tbx_ISBN.Text + , + tbx_bookname.Text + , + tbx_usersn

32、ame.Text + , + tbx_cbdw.Text + , +Convert.ToDateTime( dtp_date.Text) + , + Convert.ToInt32(tbx_jg.Text) + ,+Convert.ToInt32(tbx_number.Text)+); SqlCommand comd = new SqlCommand(sql, conn); comd.ExecuteNonQuery(); conn.Close(); this.Hide(); index f3 = new index(username,1); f3.MdiParent = this.MdiPar

33、ent; f3.Show(); else MessageBox.Show(請輸入該書的價格!); else MessageBox.Show(書名不能為空!); else MessageBox.Show(請輸入該書的出版社!); else MessageBox.Show(請輸入該書的出版時間!); else MessageBox.Show(請輸入該書的作者!); else MessageBox.Show(請輸入該書的ISBN!); catch (Exception) 4、查詢排序窗體如圖4-6所示 圖4-6查詢排序窗體主要代碼:private void btn_searcha_Click(obj

34、ect sender, EventArgs e)String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True;SqlConnection conn = new SqlConnection(strCon);conn.Open();SqlCommand comd = new SqlCommand();string sql = ;if (tbx_name.Text != string.Empty | tbx_username.Text != string.Empty) if (tbx_name

35、.Text.Trim() = string.Empty)sql = select ISBN,書名,作者,出版社,CONVERT(char(10), 出版時間, 120)AS 出版時間,價格 from librar_information where 作者= + tbx_username.Text.Trim() + ;else if (tbx_username.Text = string.Empty)sql = select ISBN,書名,作者,出版社,CONVERT(char(10), 出版時間, 120)AS 出版時間,價格 from librar_information where 書名

36、= + tbx_name.Text.Trim() + ;elsesql = select ISBN,書名,作者,出版社,CONVERT(char(10), 出版時間, 120)AS 出版時間,價格 from librar_information where 作者= + tbx_username.Text.Trim() + and 書名= + tbx_name.Text.Trim() + ;tryda = new SqlDataAdapter(sql, conn);SqlCommandBuilder cb = new SqlCommandBuilder(da);ds = new DataSet(

37、);da.Fill(ds, librar_information);dgv_sort.DataSource = ds;dgv_sort.DataMember = librar_information;catch (Exception ex)MessageBox.Show(沒有你要查詢的結(jié)果!);else MessageBox.Show(請輸入要查詢的條件!);conn.Close();private void btn_sort_Click(object sender, EventArgs e)String strCon = Data Source=(local);Initial Catalog

38、=Library;Integrated Security=True;SqlConnection conn = new SqlConnection(strCon);conn.Open();SqlCommand comd = new SqlCommand();string sql = ;if (cbx_sort.Text.ToString().Trim() = 作者)sql = select ISBN,書名,作者,出版社,CONVERT(char(10), 出版時間, 120)AS 出版時間,價格 from librar_information order by 作者 asc;else if (c

39、bx_sort.Text.ToString().Trim() = 書名)sql = select ISBN,書名,作者,出版社,CONVERT(char(10), 出版時間, 120)AS 出版時間,價格 from librar_information order by 書名 asc;tryda = new SqlDataAdapter(sql, conn);SqlCommandBuilder cb = new SqlCommandBuilder(da);ds = new DataSet();da.Fill(ds, librar_information);dgv_sort.DataSource

40、 = ds;dgv_sort.DataMember = librar_information;catch (Exception ex) MessageBox.Show(沒有你要查詢的結(jié)果!); conn.Close(); 4.4 用戶信息管理模塊實(shí)現(xiàn)管理員對用戶的增、刪等操作,如圖4-7所示 圖4-7 用戶信息主要代碼:private void user_Load(object sender, EventArgs e) this.skinEngine1.SkinFile = SteelBlack.ssk;String strCon = Data Source=(local);Initial C

41、atalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string sql = select name,password from library_login where type=1; SqlCommand comd = new SqlCommand(sql,conn); SqlDataReader dr = comd.ExecuteReader(); for (; dr.Read(); ) string dat = drname.ToStri

42、ng(); tvw_user.Nodes0.Nodes.Add(dat); dr.Close(); string sql1 = select name,password from library_login where type=0; SqlCommand comd1 = new SqlCommand(sql1,conn); SqlDataReader dr1 = comd1.ExecuteReader(); for (; dr1.Read(); ) string data = dr1name.ToString(); tvw_user.Nodes1.Nodes.Add(data); priva

43、te void btn_add_Click(object sender, EventArgs e) string type = tvw_user.SelectedNode.Text; if (type = ) MessageBox.Show(請選擇用戶類型!); return; int types; if (type = 管理員) types = 1; else types = 0;String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn =

44、new SqlConnection(strCon); conn.Open(); string sql = select * from library_login where name= + tbx_user.Text + and type= + types; SqlCommand comd1 = new SqlCommand(sql, conn); SqlDataReader dr = comd1.ExecuteReader(); if (!dr.Read() dr.Close(); if (tbx_user.Text.Trim() != & tbx_password.Text.Trim()

45、!= ) string str = insert into library_login(name,password,type) values( + tbx_user.Text.ToString() + , + tbx_password.Text.ToString() + , + types + ); SqlCommand comd = new SqlCommand(str, conn); comd.ExecuteNonQuery(); if (type = 管理員) tvw_user.Nodes0.Nodes.Add(tbx_user.Text.ToString(); else tvw_use

46、r.Nodes1.Nodes.Add(tbx_user.Text.ToString(); MessageBox.Show(添加成功!); else MessageBox.Show(請輸入密碼或用戶名!); else MessageBox.Show(該用戶已存在!); conn.Close(); private void btn_delete_Click(object sender, EventArgs e) string type = tvw_user.SelectedNode.Parent.Text; string user = tvw_user.SelectedNode.Text; if

47、(user = ) MessageBox.Show(請選擇要刪除的用戶!); return; int types; if (type = 管理員) types = 1; else types = 0;String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string sql = delete from library_login where name=+us

48、er+ and type=+types; SqlCommand comd = new SqlCommand(sql,conn); comd.ExecuteNonQuery(); tvw_user.SelectedNode.Remove(); MessageBox.Show(刪除成功!); conn.Close(); 4.5 圖書借閱管理模塊實(shí)現(xiàn)實(shí)現(xiàn)圖書的借閱信息管理如圖4-8所示 圖4-8 圖書借閱主要代碼: private void mark() String strCon = Data Source=(local);Initial Catalog=Library;Integrated Se

49、curity=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string str = select ID from library_login where name=+username+; SqlCommand comd = new SqlCommand(str, conn); SqlDataReader dr = comd.ExecuteReader(); if (dr.Read() userid = Convert.ToInt32(drID); conn.Close(); private void bt

50、n_agreen_Click(object sender, EventArgs e) String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string str = select ID,書名,作者,庫存數(shù)量 from librar_information where ISBN=+cbx_ISBN.Text.ToString().Trim()+; SqlCom

51、mand comd = new SqlCommand(str, conn); SqlDataReader dr = comd.ExecuteReader(); if (dr.Read() int bookid=Convert.ToInt32(drID); int k=Convert.ToInt32(dr庫存數(shù)量)-1; /string isbn = drISBN.ToString().Trim(); dr.Close(); string sql1 = insert into borrow(statetime,user_ID,book_ID) values( + Convert.ToDateTi

52、me(dtp_state.Text) + ,+userid+,+bookid+); SqlCommand comd2 = new SqlCommand(sql1,conn); comd2.ExecuteNonQuery(); string sql = update librar_information set 庫存數(shù)量= + k + where ISBN= + cbx_ISBN.Text.ToString().Trim() + ; SqlCommand comd1 = new SqlCommand(sql, conn); comd1.ExecuteNonQuery(); MessageBox.

53、Show(借閱圖書成功,請愛護(hù)書籍!); conn.Close(); private void borrow_Load(object sender, EventArgs e) this.skinEngine1.SkinFile = SteelBlack.ssk; cbx_ISBN.Items.Clear(); String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(

54、); string str = select ISBN,書名,作者,庫存數(shù)量 from librar_information ; SqlCommand comd = new SqlCommand(str,conn); SqlDataReader dr = comd.ExecuteReader(); for (; dr.Read(); ) if (Convert.ToInt32(dr庫存數(shù)量) 0) cbx_ISBN.Items.Add(drISBN.ToString(); conn.Close(); private void 還書_Click(object sender, EventArgs

55、e) cbx_ISBNW.Items.Clear(); String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string str = select ISBN,書名,作者,庫存數(shù)量 from librar_information; SqlCommand comd = new SqlCommand(str, conn); SqlDataReader dr =

56、comd.ExecuteReader(); for (; dr.Read(); ) cbx_ISBNW.Items.Add(drISBN.ToString(); dr.Close(); string sql = select name from library_login; SqlCommand comd1 = new SqlCommand(sql,conn); SqlDataReader dr1 = comd1.ExecuteReader(); for (; dr1.Read(); ) cbx_userid.Items.Add(dr1name.ToString(); conn.Close()

57、; private void cbx_ISBN_SelectedIndexChanged(object sender, EventArgs e) String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string str = select 書名,作者,出版社,CONVERT(char(10), 出版時間, 120)AS 出版時間,價格,庫存數(shù)量 from l

58、ibrar_information where ISBN=+cbx_ISBN.Text.ToString()+; SqlCommand comd = new SqlCommand(str, conn); SqlDataReader dr = comd.ExecuteReader(); if (dr.Read() tbx_bookname.Text = dr書名.ToString(); tbx_cbdw.Text = dr出版社.ToString(); tbx_date.Text = dr出版時間.ToString(); tbx_jg.Text = dr價格.ToString(); tbx_nu

59、mber.Text = dr庫存數(shù)量.ToString(); tbx_username.Text = dr作者.ToString(); conn.Close(); private void btn_agree_Click(object sender, EventArgs e) String strCon = Data Source=(local);Initial Catalog=Library;Integrated Security=True; SqlConnection conn = new SqlConnection(strCon); conn.Open(); string str = s

60、elect ID,書名,作者,庫存數(shù)量 from librar_information where ISBN= + cbx_ISBNW.Text.ToString().Trim() + ; SqlCommand comd = new SqlCommand(str, conn); SqlDataReader dr = comd.ExecuteReader(); if (dr.Read() int book_id = Convert.ToInt32(drID); int book_number = Convert.ToInt32(dr庫存數(shù)量)+1; dr.Close(); string sql

溫馨提示

  • 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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論