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

下載本文檔

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

文檔簡介

1、高級程序設(shè)計語言圖書管理系統(tǒng)設(shè)計報告學(xué)院: 國土資源工程學(xué)院 專業(yè): 測 繪 工 程 成員:*指導(dǎo)教師:黃云鎧日期: 2014年11月5日1 系統(tǒng)設(shè)計1.1 設(shè)計目標(biāo)本系統(tǒng)是針對圖書管理工作過程進行設(shè)計的,主要實現(xiàn)如下目標(biāo):注冊用戶可以登錄此系統(tǒng);非注冊用戶注冊后可以使用本系統(tǒng);讀者可以查詢、借閱、歸還圖書等; 管理員可以對讀者、圖書進行管理。1.2數(shù)據(jù)庫設(shè)計概述1.2.1概念結(jié)構(gòu)設(shè)計將從需求分析中得到的數(shù)據(jù)信息抽象為概念模型,經(jīng)分析可得到數(shù)據(jù)庫的E-R模型。如圖所示。 圖書名稱作者編號出版日期價格種類圖1-1 圖書實體ER圖密碼 讀者XX編號專業(yè)借閱時間借書量年齡性別圖1-2 實體讀者ER圖

2、用戶密碼類型編號圖1- 3 用戶實體ER圖1.2 項目規(guī)劃圖書管理系統(tǒng)是一個典型的數(shù)據(jù)庫應(yīng)用程序,由應(yīng)用程序和后臺數(shù)據(jù)庫兩部分構(gòu)成。(1)應(yīng)用程序應(yīng)用程序主要包括登錄,注冊,用戶信息,讀者信息,圖書信息管理,借閱圖書,綜合查詢,信息等幾個部分組成。(2)數(shù)據(jù)庫 數(shù)據(jù)庫負責(zé)對圖書信息,用戶信息等數(shù)據(jù)的管理。2 數(shù)據(jù)庫設(shè)計說明書21 數(shù)據(jù)庫表結(jié)構(gòu)2.1.1 圖書表book2.1.2 借閱信息表borrow2.1.2用戶信息表Reader2.1.4 用戶信息權(quán)限表right2.1.5用戶賬號表user2.1.6 管理員賬號表usererheper2.2數(shù)據(jù)關(guān)系圖2.3圖書管理系統(tǒng)暫有數(shù)據(jù)(模擬運行)

3、2.3.1管理員學(xué)工號:2014701020 :邢吉昌密碼:1112.3.2普通用戶學(xué)工號:2014701021 :豬八戒密碼:333學(xué)工號:2014701022 :悟空密碼:4442.3.3圖書信息編號 作者 書名 出版日期 價格 書類H319584781 MARK C#入門經(jīng)典 清華大學(xué) 2011/4/5 21.56 計算機H319584782 哪吒 和猴子的那些事 天庭文印 2010/1/2 216.5 情感H319584783二郎神 我也可以鬧天宮 天庭文印 2009/8/1 29.32 技術(shù)3 程序功能的實現(xiàn)3.1登陸界面已注冊用戶登錄時,用戶類別選擇普通用戶或管理員,不選擇會出現(xiàn)提

4、示主要代碼如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1publicpartialclassLoginForm : Form publicstring password;

5、privateint ErrorTimes;string User, Pwd;bool flagshow = false;privatebool yanzhengshuru() password = textBox3.Text;if(Typename.Text.Trim()="") MessageBox.Show("請選擇登錄類型","登錄提示",MessageBoxButtons.OK,MessageBoxIcon.Information); Typename.Focus();returnfalse; elseif(loginid.

6、Text.Trim()="") MessageBox.Show("請輸入用戶名", "登錄提示",MessageBoxButtons.OK, MessageBoxIcon.Information); loginid.Focus();returnfalse; elseif (password = "") MessageBox.Show("請輸入密碼", "登錄提示",MessageBoxButtons.OK, MessageBoxIcon.Information); textB

7、ox3.Focus();returnfalse; else returntrue; public LoginForm() InitializeComponent(); privatevoid cancelbtn_Click(object sender, EventArgs e) Application.Exit(); privatevoid LoginForm_Load(object sender, EventArgs e) privatevoid LoginForm_Closing(object sender, FormClosingEventArgs e) Application.Exit

8、(); privatevoid loginbtn_Click(object sender, EventArgs e) if (yanzhengshuru() if (Typename.Text.Trim() = "管理員") SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Security=True"); conConnection.Open();string cmd = "sel

9、ect AdminID,AdminPass from userhelper "SqlCommand = newSqlCommand(cmd, conConnection);SqlDataReader reader = .ExecuteReader();while (reader.Read() User = reader"AdminID".ToString(); Pwd = reader"AdminPass".ToString();if (User.Trim() = loginid.Text & Pwd.Trim() = textBox3

10、.Text) flagshow = true; reader.Close(); conConnection.Close();if (flagshow = true) this.Hide();admin f1 = newadmin (); f1.ShowDialog(); else if (Typename.Text.Trim() = "普通用戶") SqlConnection conConnection1 = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated S

11、ecurity=True"); conConnection1.Open();stringd = "select ReaderID,ReaderPassword from reader "SqlCommandm = newSqlCommand(cnd, conConnection1);SqlDataReader reader1 =m.ExecuteReader();while (reader1.Read() User = reader1"ReaderID".ToString(); Pwd = reader1"ReaderPassword

12、".ToString();if (User.Trim() = loginid.Text & Pwd.Trim() = textBox3.Text) flagshow = true; reader1.Close(); conConnection1.Close();if (flagshow = true) this.Hide();讀者查閱 f1 = new讀者查閱(); f1.ShowDialog(); else MessageBox.Show("用戶名不存在或密碼錯誤!", "提示"); ErrorTimes+;if (ErrorTime

13、s >= 3) MessageBox.Show("登錄次數(shù)過多,程序?qū)㈥P(guān)閉");/Application.Exit();return; privatevoid label1_Click(object sender, EventArgs e) privatevoid label2_Click(object sender, EventArgs e) privatevoid label3_Click(object sender, EventArgs e) privatevoid button1_Click(object sender, EventArgs e) this.H

14、ide();注冊 f1 = new注冊(); f1.ShowDialog(); privatevoid usercomboBox_SelectedIndexChanged(object sender, EventArgs e) privatevoid useracctxt_TextChanged(object sender, EventArgs e) privatevoid textBox3_TextChanged(object sender, EventArgs e) 3.2登陸界面如果學(xué)號已經(jīng)存在,則會出現(xiàn)“*用戶名已經(jīng)存在,請重新輸入”的提示,當(dāng)重新輸入密碼時,如果兩次密碼不一樣,則會出

15、現(xiàn)“*請注意,兩次密碼不一樣”的提示主要代碼如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1publicpartialclass注冊 : Form public 注冊()

16、InitializeComponent(); publicbool UserFlag;privatevoid textBox3_TextChanged(object sender, EventArgs e) if (textBox2.Text.Trim() != textBox3.Text.Trim() label6.Visible = true; else label8.Visible = true; label6.Visible = false; privatevoid 注冊_Load(object sender, EventArgs e) privatevoid textBox1_Tex

17、tChanged(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Security=True"); conConnection.Open();string cmd = "select ReaderID from reader "SqlCommand = newSqlCommand(cmd ,conConnection );SqlData

18、Reader readerUser = .ExecuteReader();while (readerUser.Read () if(textBox1.Text =readerUser"ReaderID".ToString().Trim() label7.Visible = true; UserFlag = true;return; elseif (textBox1.Text != readerUser"ReaderID".ToString().Trim() label7.Visible = false; label9.Visible = true; Us

19、erFlag = false; privatevoid button1_Click(object sender, EventArgs e) int index = textBox4.Text.IndexOf("");if (index < 1) label10.Visible = true; label10.Text = "格式不正確,請重新輸入" else label10.Visible = true; label10.Text = "格式正確" if(UserFlag=true ) MessageBox.Show("

20、;用戶已經(jīng)存在,請重新輸入!");return; if (UserFlag=false) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Security=True"); conConnection.Open();string cmd = "insert into reader(ReaderID,ReaderPassword,ReaderEmall) values ('"+

21、textBox1.Text+"',"+"'"+textBox2.Text+"',"+"'"+textBox4.Text+"')"SqlCommand = newSqlCommand(cmd,conConnection ); .ExecuteNonQuery(); conConnection.Close();MessageBox.Show("注冊成功!點擊確定,返回登錄界面。","提示");this.Close();L

22、oginForm f2 = newLoginForm(); 3.3管理員操作界面using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1publicpartialclassadmin : Form public admin() Initial

23、izeComponent(); privatevoid 查看用戶信息ToolStripMenuItem_Click(object sender, EventArgs e) 權(quán)限設(shè)置 f8 = new權(quán)限設(shè)置(); f8.ShowDialog(); privatevoid 查看用戶信息ToolStripMenuItem1_Click(object sender, EventArgs e) 用戶信息 fi = new用戶信息(); fi.ShowDialog(); privatevoid 新增用戶ToolStripMenuItem1_Click(object sender, EventArgs e

24、) 新增用戶 f2 = new新增用戶(); f2.ShowDialog(); privatevoid 刪除用戶ToolStripMenuItem1_Click(object sender, EventArgs e) 用戶信息 f3 = new用戶信息(); f3.button2.Visible = true; f3.ShowDialog(); privatevoid 錄入書籍ToolStripMenuItem_Click(object sender, EventArgs e) 書籍信息 f5 = new書籍信息(); f5.ShowDialog(); privatevoid 刪除書籍Tool

25、StripMenuItem_Click(object sender, EventArgs e) 刪除書籍 f6 = new刪除書籍(); f6.ShowDialog(); privatevoid 還書處理ToolStripMenuItem_Click(object sender, EventArgs e) 還書處理 f9 = new還書處理(); f9.ShowDialog(); privatevoid admin_Load(object sender, EventArgs e) privatevoid 借閱處理ToolStripMenuItem_Click(object sender, Ev

26、entArgs e) 借閱處理 f10 = new借閱處理(); f10.ShowDialog(); 3.3.1管理用戶管理用戶下共有三個子菜單新增用戶界面主要代碼如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespa

27、ce WindowsFormsApplication1publicpartialclass新增用戶 : Form public 新增用戶() InitializeComponent(); privatevoid button1_Click(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Security=True"); conConnection.Open

28、();string cmd = "insert into reader(ReaderID,ReaderName,ReaderPassword,ReaderSex,ReaderAge,ReaderDept,ReaderZhuanYe,MaxNumber,ReaderEmall) values ('" + textBox1.Text + "'," + "'" + textBox2.Text + "'," + "'" + textBox3.Text + &quo

29、t;'," + "'" + textBox4.Text + "'," + "'" + textBox5.Text + "'," + "'" + textBox6.Text + "'," + "'" + textBox7.Text + "'," + "'" + textBox8.Text + "',"

30、+ "'" + textBox9.Text + "')"SqlCommand = newSqlCommand(cmd, conConnection); .ExecuteNonQuery(); conConnection.Close();MessageBox.Show("添加成功!點擊確定,返回登錄界面。", "提示");this.Close(); 刪除用戶界面輸入學(xué)號即可查詢用戶信息,如圖,點擊刪除即刪除該用戶主要代碼如下:using System;using System.Colle

31、ctions.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1publicpartialclass用戶信息 : Form bool UserFlag;public 用戶信息() InitializeComponent(); privatevoid but

32、ton1_Click(object sender, EventArgs e) if(UserFlag=false ) MessageBox.Show("不存在該用戶,請核對后再輸入","警告");return; if (UserFlag = true) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Security=True"); conConnection.Open(

33、);string cmd = "select * from reader"SqlCommand =newSqlCommand (cmd,conConnection); mandText = "select * from reader"SqlDataReader dr = .ExecuteReader();while (dr.Read() label11.Visible = true; textBox2.Text = dr"ReaderName".ToString().Trim(); textBox3.Text = dr"Re

34、aderPassword".ToString().Trim(); textBox4.Text = dr"ReaderSex".ToString().Trim(); textBox5.Text = dr"ReaderAge".ToString().Trim(); textBox6.Text = dr"ReaderDept".ToString().Trim(); textBox7.Text = dr"ReaderZhuanYe".ToString().Trim(); textBox8.Text = dr&qu

35、ot;MaxNumber".ToString().Trim(); textBox9.Text = dr"ReaderEmall".ToString().Trim(); conConnection.Close(); privatevoid textBox1_TextChanged(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Secur

36、ity=True"); conConnection.Open();string cmd = "select ReaderID from reader "SqlCommand = newSqlCommand(cmd, conConnection);SqlDataReader readerUser = .ExecuteReader();while (readerUser.Read() if (textBox1.Text = readerUser"ReaderID".ToString().Trim() UserFlag = true;return;

37、elseif (textBox1.Text != readerUser"ReaderID".ToString().Trim() UserFlag = false; privatevoid button2_Click(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Security=True"); conConnection.Open()

38、;string cmd = "delete from reader where ReaderID='" + textBox1.Text.Replace("'", "''") + "'"SqlCommand = newSqlCommand(cmd, conConnection); .ExecuteNonQuery(); conConnection.Close();MessageBox.Show("是否確認刪除", "提示"); 3.3.1

39、.3 查看用戶信息界面該界面與刪除用戶界面代碼基本相似,主要是將查詢按鈕隱藏,故代碼不再列出3.3.2圖書管理圖書查詢下共有2個子菜單錄入書籍頁面主要代碼如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace Wi

40、ndowsFormsApplication1publicpartialclass書籍信息 : Form public 書籍信息() InitializeComponent(); privatevoid button1_Click(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Security=True"); conConnection.Open();st

41、ring cmd = "insert into book (BookID,BookWrite,BookName,BookPublish,BookPublishDate,BookPrice,BookSort) values ('" + textBox1.Text + "'," + "'" + textBox2.Text + "'," + "'" + textBox3.Text + "'," + "'"

42、+ textBox4.Text + "'," + "'" + textBox5.Text + "'," + "'" + textBox6.Text + "'," + "'" + textBox7.Text + "')"SqlCommand = newSqlCommand(cmd, conConnection); .ExecuteNonQuery(); conConnection.Close();Mes

43、sageBox.Show("錄入成功", "提示"); textBox1.Text = "" textBox2.Text = "" textBox3.Text = "" textBox4.Text = "" textBox5.Text = "" textBox6.Text = "" textBox7.Text = "" 刪除書籍刪除書籍之前如需確認是否是所需刪除的書籍,以防刪除錯誤,可以先將所需刪除的書

44、籍的書名輸入,點擊檢索后會出現(xiàn)該書的詳細信息,若確認無誤后點擊刪除即可刪除該書主要代碼如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1publicpartialclass刪

45、除書籍 : Form bool UserFlag;public 刪除書籍() InitializeComponent(); privatevoid button1_Click(object sender, EventArgs e) if (UserFlag = false) MessageBox.Show("不存在此書,請核對后再輸入", "警告");return; if (UserFlag = true) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpre

46、ss;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Security=True"); conConnection.Open();string cmd = "select * from book"SqlCommand = newSqlCommand(cmd, conConnection); mandText = "select * from book"SqlDataReader dr = .ExecuteReader();while (dr.Read() textBox1.Text = dr"BookID&quo

47、t;.ToString().Trim(); textBox2.Text = dr"BookWrite".ToString().Trim(); textBox4.Text = dr"BookPublish".ToString().Trim(); textBox5.Text = dr"BookPublishDate".ToString().Trim(); textBox6.Text = dr"BookPrice".ToString().Trim(); textBox7.Text = dr"BookSort&q

48、uot;.ToString().Trim(); conConnection.Close(); privatevoid textBox3_TextChanged(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=學(xué)生管理數(shù)據(jù)庫;Integrated Security=True"); conConnection.Open();string cmd = "select BookName from book "SqlCommand = newSqlCommand(cmd, conConnection);SqlDataReader readerUser = .ExecuteReader();while (readerUser.Read() if (textBox1.Text = readerUser"BookName".ToString().Trim() UserFlag = true;return; elseif (textBox1.Text != readerUser"BookName".ToString

溫馨提示

  • 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論