




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、 目錄1、緒論22、數(shù)據(jù)庫(kù)設(shè)計(jì)32.1 數(shù)據(jù)庫(kù)分析32.1創(chuàng)建數(shù)據(jù)庫(kù)43、界面設(shè)計(jì)43.1 登陸界面43.2 圖書(shū)管理系統(tǒng)界面83.3 圖書(shū)信息界面93.4 圖書(shū)歸還界面113.5 圖書(shū)借閱界面133.6 用戶(hù)信息界面153.7管理員界面163.8注冊(cè)界面183.9添加圖書(shū)界面194、系統(tǒng)測(cè)試214.1 登陸功能214.2 借閱圖書(shū)功能224.3 歸還圖書(shū)庫(kù)功能224.4 圖書(shū)信息功能234.5 管理員登陸功能234.6 添加圖書(shū)功能 244.7 用戶(hù)信息245 、連接數(shù)據(jù)庫(kù)245.1連接數(shù)據(jù)庫(kù)255.2操作數(shù)據(jù)庫(kù)中的數(shù)據(jù)256 、總結(jié)271、緒論2、數(shù)據(jù)庫(kù)設(shè)計(jì)2.1 數(shù)據(jù)庫(kù)分析本系統(tǒng)利用Vi
2、sual Studio 2010處理數(shù)據(jù)庫(kù)的功能,實(shí)現(xiàn)對(duì)圖書(shū)館信息的管理。主要功能為管理有關(guān)用戶(hù)、管理員、書(shū)籍和借閱的信息等。本系統(tǒng)的結(jié)構(gòu)分為用戶(hù)信息管理模塊、書(shū)籍信息管理模塊、借閱信息管理模塊、管理者管理信息模塊和查詢(xún)處理模塊。圖書(shū)館管理系統(tǒng)框圖如圖所示 進(jìn)入圖書(shū)館管理系統(tǒng)借閱圖書(shū)查詢(xún)圖書(shū)增加圖書(shū)查詢(xún)圖書(shū)圖書(shū)管理登錄 用戶(hù) 管理員失敗成功 2.2創(chuàng)建數(shù)據(jù)庫(kù)3、界面設(shè)計(jì)3.1登陸界面amespace 圖書(shū)管理系統(tǒng) public partial class Form1 : Form public Form1() InitializeComponent(); public static Form
3、fm = null; private static int ErrorTimes = 0; private void button3_Click(object sender, EventArgs e) this.Close(); private void textBox1_TextChanged(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) if (textBox1.Text = "" | textBox2.Text = "") Mes
4、sageBox.Show("提示:請(qǐng)輸入用戶(hù)名和密碼!", "警告"); SqlConnection conn = new SqlConnection("Server=PC_201402131602;Integrated Security=true;DataBase=圖書(shū)管理系統(tǒng)"); conn.Open(); SqlCommand cmd = new SqlCommand("select * from Table_1 where id='" + textBox1.Text.Trim() + "&
5、#39; and us='" + textBox2.Text.Trim() + "'", conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) MessageBox.Show("登錄成功!", "提示"); Form2 fm = new Form2(); fm.Show(); this.Hide(); else ErrorTimes+; MessageBox.Show("用戶(hù)名或密碼不正確!您還有&q
6、uot; + (3 - ErrorTimes) + "次輸入密碼的機(jī)會(huì),請(qǐng)重新輸入!如果超過(guò)3次,系統(tǒng)將自動(dòng)關(guān)閉"); if (ErrorTimes >= 3) ErrorTimes = 0; conn.Close(); private void Form1_Load(object sender, EventArgs e) private void button4_Click(object sender, EventArgs e) if (textBox1.Text = "" | textBox2.Text = "") Mess
7、ageBox.Show("提示:請(qǐng)輸入用戶(hù)名和密碼!", "警告"); SqlConnection conn = new SqlConnection("Server=PC_201402131602;Integrated Security=true;DataBase=圖書(shū)管理系統(tǒng)"); conn.Open(); SqlCommand cmd = new SqlCommand("select * from Table_2 where uid='" + textBox1.Text.Trim() + "&
8、#39; and usr='" + textBox2.Text.Trim() + "'", conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) MessageBox.Show("登錄成功!", "提示"); Form7 fm = new Form7(); fm.Show(); this.Hide(); else ErrorTimes+; MessageBox.Show("用戶(hù)名或密碼不正確!您還有&
9、quot; + (3 - ErrorTimes) + "次輸入密碼的機(jī)會(huì),請(qǐng)重新輸入!如果超過(guò)3次,系統(tǒng)將自動(dòng)關(guān)閉"); if (ErrorTimes >= 3) ErrorTimes = 0; conn.Close(); private void button2_Click(object sender, EventArgs e) Form8 f1=new Form8(); f1.Show(); private void button5_Click(object sender, EventArgs e) this.Hide(); Form10 f2 = new For
10、m10(); f2.Show(); 3.2圖書(shū)管理系統(tǒng)界面namespace 圖書(shū)管理系統(tǒng) public partial class Form2 : Form public Form2() InitializeComponent(); private void button5_Click(object sender, EventArgs e) this.Close(); private void button3_Click(object sender, EventArgs e) Form3 f2 = new Form3(); f2.Show(); this.Close(); MessageBo
11、x.Show("您已成功進(jìn)入-圖書(shū)信息!"); private void button2_Click(object sender, EventArgs e) Form4 f4 = new Form4(); f4.Show(); this.Close(); MessageBox.Show("您已成功進(jìn)入-還書(shū)系統(tǒng)!"); private void button1_Click(object sender, EventArgs e) Form5 f5 = new Form5(); f5.Show(); this.Close(); MessageBox.Show
12、("您已成功進(jìn)入-借書(shū)系統(tǒng)!"); 3.3圖書(shū)信息namespace 圖書(shū)管理系統(tǒng) public partial class Form3 : Form public Form3() InitializeComponent(); private void Form3_Load(object sender, EventArgs e) / TODO: 這行代碼將數(shù)據(jù)加載到表“圖書(shū)管理系統(tǒng)DataSet.Table_3”中。您可以根據(jù)需要移動(dòng)或刪除它。 this.table_3TableAdapter.Fill(this.圖書(shū)管理系統(tǒng)DataSet.Table_3); privat
13、e void textBox1_TextChanged(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) this.Close(); 3.4歸還圖書(shū)namespace 圖書(shū)管理系統(tǒng) public partial class Form4 : Form public Form4() InitializeComponent(); private void button1_Click(object sender, EventArgs e) if (textBox1.Text = &quo
14、t;") MessageBox.Show("提示:請(qǐng)輸入所借書(shū)籍編號(hào)!", "警告"); SqlConnection conn = new SqlConnection("Server=PC_201402131602;Integrated Security=true;DataBase=圖書(shū)管理系統(tǒng)"); conn.Open(); SqlCommand cmd = new SqlCommand("select * from Table_4 where sid='" + textBox1.Text.Tr
15、im() + "' ", conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) MessageBox.Show("該書(shū)已還", "提示"); else sdr.Close(); string myinsert = "insert into Table_4 (sid) values ('" + textBox1.Text + "') " SqlCommand mycom =
16、new SqlCommand(myinsert, conn); mycom.ExecuteNonQuery(); conn.Close(); conn.Dispose(); MessageBox.Show("您已還書(shū)成功!"); private void Form4_Load(object sender, EventArgs e) / TODO: 這行代碼將數(shù)據(jù)加載到表“圖書(shū)管理系統(tǒng)DataSet.Table_4”中。您可以根據(jù)需要移動(dòng)或刪除它。 this.table_4TableAdapter.Fill(this.圖書(shū)管理系統(tǒng)DataSet.Table_4); / TOD
17、O: 這行代碼將數(shù)據(jù)加載到表“圖書(shū)管理系統(tǒng)DataSet.Table_3”中。您可以根據(jù)需要移動(dòng)或刪除它。 this.table_3TableAdapter.Fill(this.圖書(shū)管理系統(tǒng)DataSet.Table_3); private void button2_Click(object sender, EventArgs e) this.Close(); Form2 f2 = new Form2(); f2.Show(); 3.5已借圖書(shū)namespace 圖書(shū)管理系統(tǒng) public partial class Form5 : Form public Form5() Initialize
18、Component(); private void button1_Click(object sender, EventArgs e) this.Close(); Form2 f2 = new Form2(); f2.Show(); private void Form5_Load(object sender, EventArgs e) / TODO: 這行代碼將數(shù)據(jù)加載到表“圖書(shū)管理系統(tǒng)DataSet.Table_4”中。您可以根據(jù)需要移動(dòng)或刪除它。 this.table_4TableAdapter.Fill(this.圖書(shū)管理系統(tǒng)DataSet.Table_4); / TODO: 這行代碼將
19、數(shù)據(jù)加載到表“圖書(shū)管理系統(tǒng)DataSet.Table_3”中。您可以根據(jù)需要移動(dòng)或刪除它。 this.table_3TableAdapter.Fill(this.圖書(shū)管理系統(tǒng)DataSet.Table_3); private void button2_Click(object sender, EventArgs e) if (textBox1.Text = "") MessageBox.Show("提示:請(qǐng)輸入所借書(shū)籍編號(hào)!", "警告"); SqlConnection conn = new SqlConnection("S
20、erver=PC_201402131602;Integrated Security=true;DataBase=圖書(shū)管理系統(tǒng)"); conn.Open(); SqlCommand cmd = new SqlCommand("select * from Table_4 where sid='" + textBox1.Text.Trim() + "' ", conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) MessageBox.S
21、how("該書(shū)已借", "提示"); else sdr.Close(); string myinsert = "insert into Table_4 (sid) values ('" + textBox1.Text + "') " SqlCommand mycom = new SqlCommand(myinsert, conn); mycom.ExecuteNonQuery(); conn.Close(); conn.Dispose(); MessageBox.Show("您已借書(shū)成功!
22、"); private void textBox2_TextChanged(object sender, EventArgs e) 3.6用戶(hù)信息namespace 圖書(shū)管理系統(tǒng) public partial class Form6 : Form public Form6() InitializeComponent(); private void Form6_Load(object sender, EventArgs e) / TODO: 這行代碼將數(shù)據(jù)加載到表“圖書(shū)管理系統(tǒng)DataSet.Table_1”中。您可以根據(jù)需要移動(dòng)或刪除它。 this.table_1TableAdapt
23、er.Fill(this.圖書(shū)管理系統(tǒng)DataSet.Table_1); private void button1_Click(object sender, EventArgs e) this.Close(); 3.7 管理員主界面namespace 圖書(shū)管理系統(tǒng) public partial class Form7 : Form public Form7() InitializeComponent(); private void button2_Click(object sender, EventArgs e) Form6 f1 = new Form6(); f1.Show(); Messa
24、geBox.Show("您已成功進(jìn)入-用戶(hù)信息!"); private void button3_Click(object sender, EventArgs e) Form3 f2 = new Form3(); f2.Show(); MessageBox.Show("您已成功進(jìn)入-圖書(shū)信息!"); private void button1_Click(object sender, EventArgs e) Form9 f2 = new Form9(); f2.Show(); MessageBox.Show("您已成功進(jìn)入-添加圖書(shū)系統(tǒng)!&qu
25、ot;); private void button4_Click(object sender, EventArgs e) this.Close(); 3.8注冊(cè)界面namespace 圖書(shū)管理系統(tǒng) public partial class Form8 : Form public Form8() InitializeComponent(); private void button1_Click(object sender, EventArgs e) if (textBox1.Text = "" | textBox2.Text = "") MessageBo
26、x.Show("提示:請(qǐng)輸入用戶(hù)名和密碼!", "警告"); SqlConnection conn = new SqlConnection("Server=PC_201402131602;Integrated Security=true;DataBase=圖書(shū)管理系統(tǒng)"); conn.Open(); SqlCommand cmd = new SqlCommand("select * from table_1 where id='" + textBox1.Text.Trim() + "' a
27、nd us='" + textBox2.Text.Trim() + "'", conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) MessageBox.Show("該用戶(hù)已注冊(cè),請(qǐng)使用其他用戶(hù)名", "提示"); else sdr.Close(); string myinsert = "insert into table_1(id,us) values ('" + textBox1
28、.Text + "','" + textBox2.Text + "')" SqlCommand mycom = new SqlCommand(myinsert, conn); mycom.ExecuteNonQuery(); conn.Close(); conn.Dispose(); MessageBox.Show("您已注冊(cè)成功!"); private void button2_Click(object sender, EventArgs e) this.Close(); private void Form8
29、_Load(object sender, EventArgs e) 3.9 添加圖書(shū)namespace 圖書(shū)管理系統(tǒng) public partial class Form9 : Form public Form9() InitializeComponent(); private void button2_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection("server=PC_2014
30、02131602;database=圖書(shū)管理系統(tǒng);integrated Security=true"); string sql = "insert into Table_3 (sid,sdata,sname) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')" conn.Open(); SqlCommand comm = new SqlCommand
31、(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è)試登陸借閱圖書(shū)歸還圖書(shū)圖書(shū)信息管理員登陸添加圖書(shū)用戶(hù)信息5、連接數(shù)據(jù)庫(kù)為數(shù)據(jù)庫(kù)BookManage和本系統(tǒng)之間建立一個(gè)數(shù)據(jù)連接。(1)在服務(wù)器
32、資源管理器中右擊“數(shù)據(jù)連接”節(jié)點(diǎn)(VS 2008中操作)。在彈出的快捷菜單中執(zhí)行“添加連接”命令,打開(kāi)Data Link Properties對(duì)話框。切換到Provider選項(xiàng)卡,選中列表框中的Microsoft OLE DB Provider for SQL Server項(xiàng)。單擊“下一步”切換到Connection選項(xiàng)卡。(2)在其中的第一個(gè)下拉列表框中選擇數(shù)據(jù)庫(kù)所在服務(wù)器名稱(chēng)。輸入登錄服務(wù)器信息后選擇數(shù)據(jù)庫(kù)BookManage,然后單擊測(cè)試按鈕。如果測(cè)試成功,單擊“確定”按鈕。5.1 連接數(shù)據(jù)庫(kù)(1)定義數(shù)據(jù)庫(kù)連接字符串,代碼如下:Private static string Connect
33、String = "Data Source= (local)sqlexpress;DataBase=BookManage.mdf"(2)創(chuàng)建Connection對(duì)象,代碼如下:SqlConnection con = new SqlConnection(ConnectString);(3)打開(kāi)連接,代碼如下:con.Open();(4)關(guān)閉連接,代碼如下:con.Close();5.2操作數(shù)據(jù)庫(kù)中的數(shù)據(jù)using System;using System.Collections.Generic;using System.Linq;using System.Text;using
34、System.Data;using System.Data.SqlClient;namespace BookManage class DataAccess private static string ConnectString = "Data Source =SQLEXPRESS;AttachDbFilename=F:BookManagedataBookManage.mdf;Integrated Security=False"/數(shù)據(jù)庫(kù)連接字符串 / <summary> / 根據(jù)表名獲取數(shù)據(jù)集的表 / </summary> / <param na
35、me="table"></param> / <returns></returns>public static DataTable GetDataSetByTableName(string table) using (SqlConnection con = new SqlConnection(ConnectString)/創(chuàng)建數(shù)據(jù)庫(kù)連接對(duì)象 string sql = "select * from " + table + ""/查詢(xún)sql語(yǔ)句try SqlDataAdapter adapter =
36、 new SqlDataAdapter(sql, con);/創(chuàng)建適配器對(duì)象 DataSet ds = new DataSet();/創(chuàng)建數(shù)據(jù)集對(duì)象 adapter.Fill(ds, "table");/填充數(shù)據(jù)集 return ds.Tables0;/返回?cái)?shù)據(jù)表 catch (SqlException ex) throw new Exception(ex.Message); ; public static DataSet GetDataSetBySql(string sql) using (SqlConnection con = new SqlConnection(ConnectString)/創(chuàng)建數(shù)據(jù)庫(kù)連接對(duì)象 SqlDataAdapter adapter = new SqlDataAdapter(sql,con);/創(chuàng)建適配器對(duì)象 DataSet ds = new DataSet
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 嵌入式系統(tǒng)架構(gòu)中的重要性試題及答案
- 黨辦預(yù)算業(yè)務(wù)管理制度
- 公司集團(tuán)結(jié)算管理制度
- 售電公司財(cái)務(wù)管理制度
- 醫(yī)用氧氣灌裝管理制度
- 工廠輔料預(yù)算管理制度
- 數(shù)據(jù)庫(kù)設(shè)計(jì)案例試題及答案分享
- 數(shù)學(xué) 第八章 實(shí)數(shù)復(fù)習(xí)練習(xí)題2024-2025學(xué)年人教版數(shù)學(xué)七年級(jí)下冊(cè)
- 行政組織理論的考點(diǎn)試題及答案
- 大學(xué)班級(jí)績(jī)效管理制度
- 吊車(chē)組塔施工方案
- 7 第七章 共產(chǎn)主義崇高理想及其最終實(shí)現(xiàn)
- 美愛(ài)德華·W·薩義德-東方學(xué)
- 云南咖啡行業(yè)行業(yè)發(fā)展趨勢(shì)及投資戰(zhàn)略研究分析報(bào)告
- 華為的管理框架
- 新《科學(xué)技術(shù)普及法》專(zhuān)題講座課件
- 電動(dòng)機(jī)常見(jiàn)故障分析與維護(hù)(課件)
- 藥品管理與使用規(guī)范管理制度
- 《wto案例分析》課件
- 2025屆陜西西安高新一中高考數(shù)學(xué)全真模擬密押卷含解析
- 海洋機(jī)器人與人工智能知到智慧樹(shù)章節(jié)測(cè)試課后答案2024年秋哈爾濱工程大學(xué)
評(píng)論
0/150
提交評(píng)論