C#圖書館管理系統(tǒng)設(shè)計(jì)_第1頁
C#圖書館管理系統(tǒng)設(shè)計(jì)_第2頁
C#圖書館管理系統(tǒng)設(shè)計(jì)_第3頁
C#圖書館管理系統(tǒng)設(shè)計(jì)_第4頁
C#圖書館管理系統(tǒng)設(shè)計(jì)_第5頁
已閱讀5頁,還剩11頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

..目錄TOC\o"1-4"\h\z\u1、緒論22、數(shù)據(jù)庫設(shè)計(jì)32.1數(shù)據(jù)庫分析32.1創(chuàng)建數(shù)據(jù)庫 43、界面設(shè)計(jì) 43.1登陸界面 43.2圖書管理系統(tǒng)界面 83.3圖書信息界面 93.4圖書歸還界面 113.5圖書借閱界面 133.6用戶信息界面 153.7管理員界面 163.8注冊(cè)界面 183.9添加圖書界面 194、系統(tǒng)測(cè)試 214.1登陸功能 214.2借閱圖書功能 224.3歸還圖書庫功能 224.4圖書信息功能 234.5管理員登陸功能 234.6添加圖書功能 244.7用戶信息 245、連接數(shù)據(jù)庫 245.1連接數(shù)據(jù)庫 255.2操作數(shù)據(jù)庫中的數(shù)據(jù) 256、總結(jié) 271、緒論2、數(shù)據(jù)庫設(shè)計(jì)2.1數(shù)據(jù)庫分析本系統(tǒng)利用VisualStudio2010處理數(shù)據(jù)庫的功能,實(shí)現(xiàn)對(duì)圖書館信息的管理。主要功能為管理有關(guān)用戶、管理員、書籍和借閱的信息等。本系統(tǒng)的結(jié)構(gòu)分為用戶信息管理模塊、書籍信息管理模塊、借閱信息管理模塊、管理者管理信息模塊和查詢處理模塊。圖書館管理系統(tǒng)框圖如圖所示進(jìn)入圖書館管理系統(tǒng)進(jìn)入圖書館管理系統(tǒng)借閱圖書查詢圖書增加圖書查詢圖書圖書管理登錄用戶管理員借閱圖書查詢圖書增加圖書查詢圖書圖書管理登錄用戶管理員失敗成功2.2創(chuàng)建數(shù)據(jù)庫3、界面設(shè)計(jì)3.1登陸界面amespace圖書管理系統(tǒng){publicpartialclassForm1:Form{publicForm1<>{InitializeComponent<>;}publicstaticFormfm=null;privatestaticintErrorTimes=0;privatevoidbutton3_Click<objectsender,EventArgse>{this.Close<>;}privatevoidtextBox1_TextChanged<objectsender,EventArgse>{}privatevoidbutton1_Click<objectsender,EventArgse>{if<textBox1.Text==""||textBox2.Text=="">{MessageBox.Show<"提示:請(qǐng)輸入用戶名和密碼!","警告">;}SqlConnectionconn=newSqlConnection<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=圖書管理系統(tǒng)">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromTable_1whereid='"+textBox1.Text.Trim<>+"'andus='"+textBox2.Text.Trim<>+"'",conn>;SqlDataReadersdr=cmd.ExecuteReader<>;sdr.Read<>;if<sdr.HasRows>{MessageBox.Show<"登錄成功!","提示">;Form2fm=newForm2<>;fm.Show<>;this.Hide<>;}else{ErrorTimes++;MessageBox.Show<"用戶名或密碼不正確!您還有"+<3-ErrorTimes>+"次輸入密碼的機(jī)會(huì),請(qǐng)重新輸入!如果超過3次,系統(tǒng)將自動(dòng)關(guān)閉">;if<ErrorTimes>=3>{ErrorTimes=0;conn.Close<>;}}}privatevoidForm1_Load<objectsender,EventArgse>{}privatevoidbutton4_Click<objectsender,EventArgse>{if<textBox1.Text==""||textBox2.Text=="">{MessageBox.Show<"提示:請(qǐng)輸入用戶名和密碼!","警告">;}SqlConnectionconn=newSqlConnection<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=圖書管理系統(tǒng)">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromTable_2whereuid='"+textBox1.Text.Trim<>+"'andusr='"+textBox2.Text.Trim<>+"'",conn>;SqlDataReadersdr=cmd.ExecuteReader<>;sdr.Read<>;if<sdr.HasRows>{MessageBox.Show<"登錄成功!","提示">;Form7fm=newForm7<>;fm.Show<>;this.Hide<>;}else{ErrorTimes++;MessageBox.Show<"用戶名或密碼不正確!您還有"+<3-ErrorTimes>+"次輸入密碼的機(jī)會(huì),請(qǐng)重新輸入!如果超過3次,系統(tǒng)將自動(dòng)關(guān)閉">;if<ErrorTimes>=3>{ErrorTimes=0;conn.Close<>;}}}privatevoidbutton2_Click<objectsender,EventArgse>{Form8f1=newForm8<>;f1.Show<>;}privatevoidbutton5_Click<objectsender,EventArgse>{this.Hide<>;Form10f2=newForm10<>;f2.Show<>;}}}3.2圖書管理系統(tǒng)界面namespace圖書管理系統(tǒng){publicpartialclassForm2:Form{publicForm2<>{InitializeComponent<>;}privatevoidbutton5_Click<objectsender,EventArgse>{this.Close<>;}privatevoidbutton3_Click<objectsender,EventArgse>{Form3f2=newForm3<>;f2.Show<>;this.Close<>;MessageBox.Show<"您已成功進(jìn)入圖書信息!">;}privatevoidbutton2_Click<objectsender,EventArgse>{Form4f4=newForm4<>;f4.Show<>;this.Close<>;MessageBox.Show<"您已成功進(jìn)入還書系統(tǒng)!">;}privatevoidbutton1_Click<objectsender,EventArgse>{Form5f5=newForm5<>;f5.Show<>;this.Close<>;MessageBox.Show<"您已成功進(jìn)入借書系統(tǒng)!">;}}}3.3圖書信息namespace圖書管理系統(tǒng){publicpartialclassForm3:Form{publicForm3<>{InitializeComponent<>;}privatevoidForm3_Load<objectsender,EventArgse>{//TODO:這行代碼將數(shù)據(jù)加載到表"圖書管理系統(tǒng)DataSet.Table_3"中。您可以根據(jù)需要移動(dòng)或刪除它。this.table_3TableAdapter.Fill<this.圖書管理系統(tǒng)DataSet.Table_3>;}privatevoidtextBox1_TextChanged<objectsender,EventArgse>{}privatevoidbutton1_Click<objectsender,EventArgse>{this.Close<>;}}}3.4歸還圖書namespace圖書管理系統(tǒng){publicpartialclassForm4:Form{publicForm4<>{InitializeComponent<>;}privatevoidbutton1_Click<objectsender,EventArgse>{if<textBox1.Text=="">{MessageBox.Show<"提示:請(qǐng)輸入所借書籍編號(hào)!","警告">;}SqlConnectionconn=newSqlConnection<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=圖書管理系統(tǒng)">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromTable_4wheresid='"+textBox1.Text.Trim<>+"'",conn>;SqlDataReadersdr=cmd.ExecuteReader<>;sdr.Read<>;if<sdr.HasRows>{MessageBox.Show<"該書已還","提示">;}else{sdr.Close<>;stringmyinsert="insertintoTable_4<sid>values<'"+textBox1.Text+"'>";SqlCommandmycom=newSqlCommand<myinsert,conn>;mycom.ExecuteNonQuery<>;conn.Close<>;conn.Dispose<>;MessageBox.Show<"您已還書成功!">;}}privatevoidForm4_Load<objectsender,EventArgse>{//TODO:這行代碼將數(shù)據(jù)加載到表"圖書管理系統(tǒng)DataSet.Table_4"中。您可以根據(jù)需要移動(dòng)或刪除它。this.table_4TableAdapter.Fill<this.圖書管理系統(tǒng)DataSet.Table_4>;//TODO:這行代碼將數(shù)據(jù)加載到表"圖書管理系統(tǒng)DataSet.Table_3"中。您可以根據(jù)需要移動(dòng)或刪除它。this.table_3TableAdapter.Fill<this.圖書管理系統(tǒng)DataSet.Table_3>;}privatevoidbutton2_Click<objectsender,EventArgse>{this.Close<>;Form2f2=newForm2<>;f2.Show<>;}}}3.5已借圖書namespace圖書管理系統(tǒng){publicpartialclassForm5:Form{publicForm5<>{InitializeComponent<>;}privatevoidbutton1_Click<objectsender,EventArgse>{this.Close<>;Form2f2=newForm2<>;f2.Show<>;}privatevoidForm5_Load<objectsender,EventArgse>{//TODO:這行代碼將數(shù)據(jù)加載到表"圖書管理系統(tǒng)DataSet.Table_4"中。您可以根據(jù)需要移動(dòng)或刪除它。this.table_4TableAdapter.Fill<this.圖書管理系統(tǒng)DataSet.Table_4>;//TODO:這行代碼將數(shù)據(jù)加載到表"圖書管理系統(tǒng)DataSet.Table_3"中。您可以根據(jù)需要移動(dòng)或刪除它。this.table_3TableAdapter.Fill<this.圖書管理系統(tǒng)DataSet.Table_3>;}privatevoidbutton2_Click<objectsender,EventArgse>{if<textBox1.Text=="">{MessageBox.Show<"提示:請(qǐng)輸入所借書籍編號(hào)!","警告">;}SqlConnectionconn=newSqlConnection<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=圖書管理系統(tǒng)">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromTable_4wheresid='"+textBox1.Text.Trim<>+"'",conn>;SqlDataReadersdr=cmd.ExecuteReader<>;sdr.Read<>;if<sdr.HasRows>{MessageBox.Show<"該書已借","提示">;}else{sdr.Close<>;stringmyinsert="insertintoTable_4<sid>values<'"+textBox1.Text+"'>";SqlCommandmycom=newSqlCommand<myinsert,conn>;mycom.ExecuteNonQuery<>;conn.Close<>;conn.Dispose<>;MessageBox.Show<"您已借書成功!">;}}privatevoidtextBox2_TextChanged<objectsender,EventArgse>{}}3.6用戶信息namespace圖書管理系統(tǒng){publicpartialclassForm6:Form{publicForm6<>{InitializeComponent<>;}privatevoidForm6_Load<objectsender,EventArgse>{//TODO:這行代碼將數(shù)據(jù)加載到表"圖書管理系統(tǒng)DataSet.Table_1"中。您可以根據(jù)需要移動(dòng)或刪除它。this.table_1TableAdapter.Fill<this.圖書管理系統(tǒng)DataSet.Table_1>;}privatevoidbutton1_Click<objectsender,EventArgse>{this.Close<>;}}}3.7管理員主界面namespace圖書管理系統(tǒng){publicpartialclassForm7:Form{publicForm7<>{InitializeComponent<>;}privatevoidbutton2_Click<objectsender,EventArgse>{Form6f1=newForm6<>;f1.Show<>;MessageBox.Show<"您已成功進(jìn)入用戶信息!">;}privatevoidbutton3_Click<objectsender,EventArgse>{Form3f2=newForm3<>;f2.Show<>;MessageBox.Show<"您已成功進(jìn)入圖書信息!">;}privatevoidbutton1_Click<objectsender,EventArgse>{Form9f2=newForm9<>;f2.Show<>;MessageBox.Show<"您已成功進(jìn)入添加圖書系統(tǒng)!">;}privatevoidbutton4_Click<objectsender,EventArgse>{this.Close<>;}}}3.8注冊(cè)界面namespace圖書管理系統(tǒng){publicpartialclassForm8:Form{publicForm8<>{InitializeComponent<>;}privatevoidbutton1_Click<objectsender,EventArgse>{if<textBox1.Text==""||textBox2.Text=="">{MessageBox.Show<"提示:請(qǐng)輸入用戶名和密碼!","警告">;}SqlConnectionconn=newSqlConnection<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=圖書管理系統(tǒng)">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromtable_1whereid='"+textBox1.Text.Trim<>+"'andus='"+textBox2.Text.Trim<>+"'",conn>;SqlDataReadersdr=cmd.ExecuteReader<>;sdr.Read<>;if<sdr.HasRows>{MessageBox.Show<"該用戶已注冊(cè),請(qǐng)使用其他用戶名","提示">;}else{sdr.Close<>;stringmyinsert="insertintotable_1<id,us>values<'"+textBox1.Text+"','"+textBox2.Text+"'>";SqlCommandmycom=newSqlCommand<myinsert,conn>;mycom.ExecuteNonQuery<>;conn.Close<>;conn.Dispose<>;MessageBox.Show<"您已注冊(cè)成功!">;}}privatevoidbutton2_Click<objectsender,EventArgse>{this.Close<>;}privatevoidForm8_Load<objectsender,EventArgse>{}}}3.9添加圖書namespace圖書管理系統(tǒng){publicpartialclassForm9:Form{publicForm9<>{InitializeComponent<>;}privatevoidbutton2_Click<objectsender,EventArgse>{}privatevoidbutton1_Click<objectsender,EventArgse>{SqlConnectionconn=newSqlConnection<"server=PC_201402131602;database=圖書管理系統(tǒng);integratedSecurity=true">;stringsql="insertintoTable_3<sid,sdata,sname>values<'"+textBox1.Text+"','"+textBox2.Text+"','"+textBox3.Text+"'>";conn.Open<>;SqlCommandcomm=newSqlCommand<sql,conn>;if<conn.State==ConnectionState.Closed>{conn.Open<>;}if<Convert.ToInt32<comm.ExecuteNonQuery<>>>0>{label4.Text="成功!";MessageBox.Show<"您已成功添加數(shù)據(jù)!">;}else{label4.Text="失??!";}}}}4、系統(tǒng)測(cè)試登陸借閱圖書歸還圖書圖書信息管理員登陸添加圖書用戶信息5、連接數(shù)據(jù)庫為數(shù)據(jù)庫BookManage和本系統(tǒng)之間建立一個(gè)數(shù)據(jù)連接。<1>在服務(wù)器資源管理器中右擊"數(shù)據(jù)連接"節(jié)點(diǎn)<VS2008中操作>。在彈出的快捷菜單中執(zhí)行"添加連接"命令,打開DataLinkProperties對(duì)話框。切換到Provider選項(xiàng)卡,選中列表框中的MicrosoftOLEDBProviderforSQLServer項(xiàng)。單擊"下一步"切換到Connection選項(xiàng)卡。<2>在其中的第一個(gè)下拉列表框中選擇數(shù)據(jù)庫所在服務(wù)器名稱。輸入登錄服務(wù)器信息后選擇數(shù)據(jù)庫BookManage,然后單擊測(cè)試按鈕。如果測(cè)試成功,單擊"確定"按鈕。5.1連接數(shù)據(jù)庫<1>定義數(shù)據(jù)庫連接字符串,代碼如下:PrivatestaticstringConnectString="DataSource=<local>\\sqlexpress;DataBase=BookManage.mdf";<2>創(chuàng)建Connection對(duì)象,代碼如下:SqlConnectioncon=newSqlConnection<ConnectString>;<3>打開連接,代碼如下:con.Open<>;<4>關(guān)閉連接,代碼如下:con.Close<>;5.2操作數(shù)據(jù)庫中的數(shù)據(jù)usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;namespaceBookManage{classDataAccess{privatestaticstringConnectString=@"DataSource=SQLEXPRESS;AttachDbFilename=F:\BookManage\data\BookManage.mdf;IntegratedSecurity=False";//數(shù)據(jù)庫連接字符串///<summary>///根據(jù)表名獲取數(shù)據(jù)集的表///</summary>///<paramname="table"></param>///<returns></returns>publicstaticDataTableGetDataSetByTableName<stringtable>{using<SqlConnectioncon=newSqlConnection<ConnectString>>//創(chuàng)建數(shù)據(jù)庫連接對(duì)象{stringsql="select*from"+table+"";//查詢sql語句try{SqlDataAdapteradapter=newSqlDataAdapter<sql,con>;//創(chuàng)建適配器對(duì)象DataSetds=newDataSet<>;//創(chuàng)建數(shù)據(jù)集對(duì)象adapter.Fill<ds,"table">;//填充數(shù)據(jù)集returnds.Tables[0];//返回?cái)?shù)據(jù)表}catch<SqlExceptionex>{thrownewException<ex.Message>;;}}}publicstaticDataSetGetDataSetBySql<stringsql>{using<SqlConnectioncon=newSqlConnection<ConnectString>>//創(chuàng)建數(shù)據(jù)庫連接對(duì)象{SqlDataAdapteradapter=new

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論