

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、目錄1、緒論12、數(shù)據(jù)庫設計12.1數(shù)據(jù)庫分析12.1創(chuàng)建數(shù)據(jù)庫43、界面設計43.1登陸界面43.2圖書管理系統(tǒng)界面83.3圖書信息界面93.4圖書歸還界面113.5圖書借閱界面133.6用戶信息界面153.7管理員界面163.8注冊界面183.9添加圖書界面194、系統(tǒng)測試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、總結271、緒論2、數(shù)據(jù)庫設計2.1數(shù)據(jù)庫分析本系統(tǒng)利用VisualStudio2010處理數(shù)據(jù)庫
2、的功能,實現(xiàn)對圖書館信息的管理。主要功能為管理有關用戶、管理員、書籍和借閱的信息等。本系統(tǒng)的結構分為用戶信息管理模塊、書籍信息管理模塊、借閱信息管理模塊、管理者管理信息模塊和查詢處理模塊。圖書館管理系統(tǒng)框圖如圖所示22創(chuàng)建數(shù)據(jù)庫列容允許Mullifidncharl-OU5-nchr10允許Mullifuidnchar10)團usirnchar10畫nB列名允許Nullf卜sidnchar(lO)Ssdatanchar(lO)圍snamenchar(lO)n列容允許MullIidTKhar(lO)Sn3、界面設計3.1登陸界面amespace圖書管理系統(tǒng)publicpartialclassFor
3、ml:FormpublicForml()InitializeComponent();publicstaticFormfm=null;privatestaticintErrorTimes=0;privatevoidbutton3_Click(objectsender,EventArgse)this.Close();privatevoidtextBox1_TextChanged(objectsender,EventArgse)privatevoidbutton1_Click(objectsender,EventArgse)if(textBox1.Text=""|textBox2
4、.Text="")MessageBox.Show("提示:請輸入用戶名和密碼!","警告");SqlConnectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|圖書管理系統(tǒng)");conn.Open();SqlCommandcmd=newSqlCommand("select*fromTable_1whereid='"+textBox1.Text.Trim()+"
5、'andus='"+textBox2.Text.Trim()+"'",conn);SqlDataReadersdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("登錄成功!","提示");Form2fm=newForm2();fm.Show();this.Hide();elseErrorTimes+;MessageBox.Show("用戶名或密碼不正確!您還有"+(3-ErrorTimes)+"
6、;次輸入密碼的機會,請重新輸入!如果超過3次,系統(tǒng)將自動關閉");if(ErrorTimes>=3)ErrorTimes=0;conn.Close();privatevoidForm1_Load(objectsender,EventArgse)privatevoidbutton4_Click(objectsender,EventArgse)if(textBox1.Text=""|textBox2.Text="")MessageBox.Show("提示:請輸入用戶名和密碼!","警告");SqlCon
7、nectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|圖書管理系統(tǒng)");conn.Open();SqlCommandcmd=newSqlCommand("select*fromTable_2whereuid='"+textBox1.Text.Trim()+"'andusr='"+textBox2.Text.Trim()+"'",conn);SqlDataReader
8、sdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("登錄成功!","提示");Form7fm=newForm7();fm.Show();this.Hide();elseErrorTimes+;MessageBox.Show("用戶名或密碼不正確!您還有"+(3-ErrorTimes)+次輸入密碼的機會,請重新輸入!如果超過3次,系統(tǒng)將自動關閉);if(ErrorTimes>=3)ErrorTimes=0;conn.Close();privatevo
9、idbutton2_Click(objectsender,EventArgse)Form8fl二newForm8();fl.Show();privatevoidbutton5_Click(objectsender,EventArgse)this.Hide();Form10f2=newForm10();f2.Show();叫登?®面|=|回|圧|welcome3.2圖書管理系統(tǒng)界面namespace圖書管理系統(tǒng)publicpartialclassForm2:FormpublicForm2()InitializeComponent();privatevoidbutton5_Click(o
10、bjectsender,EventArgse)this.Close();privatevoidbutton3_Click(objectsender,EventArgse)Form3f2=newForm3();f2.Show();this.Close();MessageBox.Show("您已成功進入圖書信息!");privatevoidbutton2_Click(objectsender,EventArgse)Form4f4=newForm4();f4.Show();this.Close();MessageBox.Show("您已成功進入還書系統(tǒng)!");
11、privatevoidbutton1_Click(objectsender,EventArgse)Form5f5=newForm5();f5.Show();this.Close();MessageBox.Show("您已成功進入借書系統(tǒng)!");3.3圖書信息namespace圖書管理系統(tǒng)publicpartialclassForm3:FormpublicForm3()InitializeComponent();privatevoidForm3_Load(objectsender,EventArgse)/TODO:這行代碼將數(shù)據(jù)加載到表“圖書管理系統(tǒng)DataSet.Table
12、_3”中。您可以根據(jù)需要移動或刪除它。this.table_3TableAdapter.Fill(this.圖書管理系統(tǒng)DataSet.Table_3);privatevoidtextBoxl_TextChanged(objectsender,EventArgse)privatevoidbuttonl_Click(objectsender,EventArgse)this.Close();3.4歸還圖書namespace圖書管理系統(tǒng)publicpartialclassForm4:FormpublicForm4()InitializeComponent();privatevoidbutton1_C
13、lick(objectsender,EventArgse)if(textBox1.Text="")MessageBox.Show(提示:請輸入所借書籍編號!","警告);SqlConnectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|圖書管理系統(tǒng)");conn.Open();SqlCommandcmd=newSqlCommand("select*fromTable_4wheresid='"
14、;+textBox1.Text.Trim()+"'",conn);SqlDataReadersdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("該書已還","提示");elsesdr.Close();stringmyinsert="insertintoTable_4(sid)values('"+textBox1.Text+"')"SqlCommandmycom=newSqlCommand(m
15、yinsert,conn);mycom.ExecuteNonQuery();conn.Close();conn.Dispose();MessageBox.Show("您已還書成功!");privatevoidForm4_Load(objectsender,EventArgse)/TODO:這行代碼將數(shù)據(jù)加載到表“圖書管理系統(tǒng)DataSet.Table_4”中。您可以根據(jù)需要移動或刪除它。this.table_4TableAdapter.Fill(this.圖書管理系統(tǒng)DataSet.Table_4);/TODO:這行代碼將數(shù)據(jù)加載到表“圖書管理系統(tǒng)DataSet.Table
16、_3”中。您可以根據(jù)需要移動或刪除它。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:FormpublicForm5()InitializeComponent();privatevoidbutton1_Click(objectsender,EventArgs
17、e)this.Close();Form2f2=newForm2();f2.Show();privatevoidForm5_Load(objectsender,EventArgse)/TODO:這行代碼將數(shù)據(jù)加載到表“圖書管理系統(tǒng)DataSet.Table_4”中。您可以根據(jù)需要移動或刪除它。this.table_4TableAdapter.Fill(this.圖書管理系統(tǒng)DataSet.Table_4);/TODO:這行代碼將數(shù)據(jù)加載到表“圖書管理系統(tǒng)DataSet.Table_3”中。您可以根據(jù)需要移動或刪除它。this.table_3TableAdapter.Fill(this.圖書管理系
18、統(tǒng)DataSet.Table_3);if(textBox1.Text="")MessageBox.Show(提示:請輸入所借書籍編號!","警告);privatevoidbutton2_Click(objectsender,EventArgse)SqlConnectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|圖書管理系統(tǒng)");conn.Open();SqlCommandcmd=newSqlCommand("
19、;select*fromTable_4wheresid='"+textBox1.Text.Trim()+"'",conn);SqlDataReadersdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("該書已借",”提示");elsesdr.Close();stringmyinsert="insertintoTable_4(sid)values('"+textBox1.Text+"')&quo
20、t;SqlCommandmycom=newSqlCommand(myinsert,conn);mycom.ExecuteNonQuery();conn.Close();conn.Dispose();MessageBox.Show(您已借書成功!);privatevoidtextBox2_TextChanged(objectsender,EventArgse)3.6用戶信息namespace圖書管理系統(tǒng)publicpartialclassForm6:FormpublicForm6()InitializeComponent();privatevoidForm6_Load(objectsender,
21、EventArgse)/TODO:這行代碼將數(shù)據(jù)加載到表“圖書管理系統(tǒng)DataSet.Table_1”中。您可以根據(jù)需要移動或刪除它。this.table_1TableAdapter.Fill(this.圖書管理系統(tǒng)DataSet.Table_1);this.Close();privatevoidbutton2_Click(objectsender,EventArgse)用戶信息1=1回3.7管理員主界面namespace圖書管理系統(tǒng)publicpartialclassForm7:FormpublicForm7()InitializeComponent();privatevoidbutton2
22、_Click(objectsender,EventArgse)Form6fl=newForm6();fl.Show();MessageBox.Show("您已成功進入用戶信息!");Form3f2=newForm3();f2.Show();privatevoidbutton3_Click(objectsender,EventArgse)MessageBox.Show("您已成功進入圖書信息!");privatevoidbuttonl_Click(objectsender,EventArgse)Form9f2=newForm9();f2.Show();Me
23、ssageBox.Show("您已成功進入添加圖書系統(tǒng)!");privatevoidbutton4_Click(objectsender,EventArgse)this.Close();3.8注冊界面namespace圖書管理系統(tǒng)publicpartialclassForm8:FormpublicForm8()InitializeComponent();privatevoidbutton1_Click(objectsender,EventArgse)if(textBox1.Text=""|textBox2.Text="")Messag
24、eBox.Show("提示:請輸入用戶名和密碼!","警告");SqlConnectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|圖書管理系統(tǒng)");conn.Open();SqlCommandcmd=newSqlCommand("select*fromtable_1whereid='"+textBox1.Text.Trim()+"'andus='"+te
25、xtBox2.Text.Trim()+"'",conn);SqlDataReadersdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("該用戶已注冊,請使用其他用戶名","提示");elsesdr.Close();stringmyinsert="insertintotable_1(id,us)values('"+textBox1.Text+"','"+textBox2.Text+&q
26、uot;')"SqlCommandmycom=newSqlCommand(myinsert,conn);mycom.ExecuteNonQuery();conn.Close();conn.Dispose();MessageBox.Show("您已注冊成功!");privatevoidbutton2_Click(objectsender,EventArgse)this.Close();privatevoidForm8_Load(objectsender,EventArgse)3.9添加圖書namespace圖書管理系統(tǒng)publicpartialclassFo
27、rm9:FormpublicForm9()InitializeComponent();privatevoidbutton2_Click(objectsender,EventArgse)privatevoidbutton1_Click(objectsender,EventArgse)SqlConnectionconn=newSqlConnection("server二PC_201402131602;database二圖書管理系統(tǒng);integratedSecurity=true");stringsql="insertintoTable_3(sid,sdata,snam
28、e)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="成功!&qu
29、ot;MessageBox.Show("您已成功添加數(shù)據(jù)!");elselabel4.Text="失??!"4、系統(tǒng)測試登陸借閱圖書歸還圖書圖書信息管理員登陸添加圖書用戶信息5、連接數(shù)據(jù)庫為數(shù)據(jù)庫BookManage和本系統(tǒng)之間建立一個數(shù)據(jù)連接。(1) 在服務器資源管理器中右擊“數(shù)據(jù)連接”節(jié)點(VS2008中操作)。在彈出的快捷菜單中執(zhí)行“添加連接”命令,打開DataLinkProperties對話框。切換到Provider選項卡,選中列表框中的MicrosoftOLEDBProviderforSQLServer項。單擊“下一步”切換到Connection
30、選項卡。(2) 在其中的第一個下拉列表框中選擇數(shù)據(jù)庫所在服務器名稱。輸入登錄服務器信息后選擇數(shù)據(jù)庫BookManage,然后單擊測試按鈕。如果測試成功,單擊“確定”按鈕。5.1連接數(shù)據(jù)庫(1) 定義數(shù)據(jù)庫連接字符串,代碼如下:PrivatestaticstringConnectString="DataSource=(local)sqlexpress;DataBase=BookManage.mdf"(2) 創(chuàng)建Connection對象,代碼如下:SqlConnectioncon=newSqlConnection(ConnectString);(3) 打開連接,代碼如下:con
31、.Open();(4) 關閉連接,代碼如下:con.Close();5.2操作數(shù)據(jù)庫中的數(shù)據(jù)usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;namespaceBookManageclassDataAccessprivatestaticstringConnectString="DataSource=SQLEXPRESS;AttachDbFilename=F:BookManagedataBook
32、Manage.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ù)庫連接對象stri
33、ngsql="select*from"+table+""/查詢sql語句trySqlDataAdapteradapter=newSqlDataAdapter(sql,con);/創(chuàng)建適配器對象DataSetds=newDataSet();/創(chuàng)建數(shù)據(jù)集對象adapter.Fill(ds,"table");/填充數(shù)據(jù)集returnds.TablesO;/返回數(shù)據(jù)表catch(SqlExceptionex)thrownewException(ex.Message);publicstaticDataSetGetDataSetBySql(stringsql)using(SqlConnectioncon=newSqlConnection(ConnectString)/創(chuàng)建數(shù)據(jù)庫連接對象SqlDataAdapteradapter=newSqlDataAdapter(sql,con);/創(chuàng)建適配器對象DataSetds=newDa
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 財務財務合規(guī)計劃
- 跨境電話欺詐案例分析與防范
- 足球校隊隊員壓力管理與團隊默契提升
- 金融領域中的安全保障措施與實踐探討
- 貴州國企招聘2025貴州黔源電力股份有限公司應屆畢業(yè)生招聘筆試參考題庫附帶答案詳解
- 質量控制與檢驗標準的法規(guī)要求解析
- 跨領域合作促進藥物分析方法的進步
- 新課標2024-2025學年高中英語Unit4SharingSectionⅤWriting-記敘文教案含解析新人教版選修7
- 銷售談判技巧與策略培訓
- 新高考2025版高考數(shù)學二輪復習第三部分講重點解答題專練第1講解三角形教學案理
- 戶外廣告制作安裝合同模板
- 廠房改公寓出租合同范例
- 污水處理廠SBR工藝的設計說明
- 2025年國家自然科學基金委員會招聘流動編制人員59人歷年高頻重點模擬試卷提升(共500題附帶答案詳解)
- 歷史地理學研究-深度研究
- 2025江蘇太倉市城市建設投資集團限公司招聘易考易錯模擬試題(共500題)試卷后附參考答案
- 2.2 學會管理情緒(同步課件)2024-2025學年七年級道德與法治下冊(統(tǒng)編版2024)
- 14磁極與方向(教學設計)-二年級科學下冊(教科版)
- 2025年山西經(jīng)貿職業(yè)學院高職單招職業(yè)技能測試近5年??及鎱⒖碱}庫含答案解析
- 2024年09月江蘇2024年蘇州金融租賃校園招考筆試歷年參考題庫附帶答案詳解
- 2025年八省聯(lián)考數(shù)學試題(原卷版)
評論
0/150
提交評論