1、图书管理系统设计与实现(此文档为word格式,下载后您可任意编辑修改!)图书管理系统的设计一、 系统分析 21. 开发背景 22. 需求分析 2二、 系统设计 21. 系统总体结构 22. 数据库设计 33. 编码设计 4三、 系统实施 41. 登录 42. 系统主界面 53. 书库管理 71) 新书登记: 72) 借书/还书: 131) 缴费 202) 书籍挂失: 233) 图书信息查询: 284) 借书信息查询: 304. 借阅证管理: 311) 办理借阅证: 312) 借阅证信息查询: 343) 借阅证挂失: 355. 系统/其它: 381) 添加账号: 382) 修改密码: 403)
2、退出: 41四、 总结(体会、经验与教训) 42一、 系统分析1. 开发背景随着人们知识层次的提高,图书馆成为日常生活中不可缺少的一部分。而图书馆的存数量和业务量庞大,仅仅靠传统的记账式管理是不可行的。图书馆管理系统应运而生,逐渐成为信息化建设的重要组成部分。图书馆管理系统为学校或社会型图书馆的管理员提供所有借阅者的详细信息,以及馆内库存的详细情况,对借书和还书两大功能进行合理操纵并登记。2. 需求分析经过仔细分析系统需求之后,本图书管理系统主要完成的主要功能如下: 进入系统前需要身份验证、用户名、密码,输入正确后方可进入。 用户可以根据需要进行书库管理。 用户可以进行借书证的办理、查询、挂失
3、等操作。 用户可以添加账户和修改密码。 身份验证:提供系统的访问控制功能。 书库管理:包括新书登记、借书、还书、书籍挂失、图书信息查询、借书信息查询等功能。 借阅证管理:提供办理借阅证、借阅证信息查询、借阅证挂失功能。 系统管理功能:包括添加账号、修改密码和退出系统等功能。二、 系统设计1. 系统总体结构通过对图书管理系统的功能分析,可以定义出系统的功能模块图如下:2. 数据库设计 管理员基本信息表字段名称数据类型可否为空约束条件说明WorkIDintNOT NULL主键成员IDUser_NameVARCHAR(24)NOT NULL无姓名PasswordVARCHAR(24)NOT NULL
4、无密码 图书信息表字段名称数据类型可否为空约束条件说明Book_IDVARCHAR(50)NOT NULL主键书籍IDBook_NameVARCHAR(50)NOT NULL无书名WriterVARCHAR(50)NOT NULL无作者PressVARCHAR(50)NOT NULL无出版社PricefloatNOT NULL无单价InLibrary_DatedatetimeNOT NULL无入库时间Total_AmountintNOT NULL无总量Now_AmountintNOT NULL无现存量 借阅卡信息表字段名称数据类型可否为空约束条件说明Proof_IDVARCHAR(50)NOT
5、 NULL主键借阅卡IDNameVARCHAR(50)NOT NULL无姓名SexVARCHAR(50)NOT NULL无性别Birth_TimedatetimeNOT NULL无出生日期AddressVARCHAR(50)NOT NULL无地址ID_NumberVARCHAR(50)NOT NULL无身份证号Tel_NumberVARCHAR(50)NOT NULL无电话号码Now_Borrow_AmountintNOT NULL无现借书量 借书信息表字段名称数据类型可否为空约束条件说明BorrowIDintNOT NULL主键借书IDProof_IDVARCHAR(50)NOT NULL外
6、键(Proof_Info)借书卡IDBook_IDVARCHAR(50)NOT NULL外键(Book_Info)书籍IDBorrow_DatedatetimeNOT NULL无借出时间 罚单信息表字段名称数据类型可否为空约束条件说明Puni_IDintNOT NULL主键罚单IDProof_IDVARCHAR(50)NOT NULL无借书卡IDBook_IDVARCHAR(50)NOT NULL无书籍IDBorrow_DatedatetimeNOT NULL无借出时间Return_DatedatetimeNOT NULL无还书时间Puni_MoneyfloatNOT NULL无罚金3. 编码
7、设计 WorkID,BorrowID,Puni_ID都设置了标识规范,增加记录时自动加1,保持其唯一性。 Borrow_Date,Return_Date,InLibrary_Date都设置成datetime类型,插入记录时自动获取当前日期,不需要管理员输入日期。 Proof_ID,Book_ID,ID_Number,Tel_Number,Proof_ID由于它们只是代表一个标识,不是一个表示大小的数字,所以用VARCHAR类型,用int或long可能会有溢出现象。三、 系统实施1. 登录 功能说明:验证管理员的用户名和密码是否正确,正确则进入主界面。 源代码:头文件:using System.
8、Data.SqlClient;连接数据库:Security=True);程序主体:private void button_exit_Click(object sender, EventArgs e)/退出 Application.Exit(); private void button_log_Click(object sender, EventArgs e)/登录 if (this.UserName.Text.Trim() = | this.PassWord.Text.Trim() = ) MessageBox.Show(用户名和密码都不能为空!); if (con.State = Conne
9、ctionState.Closed) con.Open(); String str = select count(*) from Admin_Info where User_Name= + this.UserName.Text.Trim() + and Password= + this.PassWord.Text + ; SqlCommand com = new SqlCommand(str, con); int i = Convert.ToInt32(com.ExecuteScalar(); if (i 0) Form2 form2 = new Form2();/系统主界面 form2.Sh
10、ow(); this.Visible = false; else MessageBox.Show(用户名或密码输入有误,请重新输入!); this.UserName.Text = ; this.PassWord.Text = ; 界面演示:登录名和密码正确的话进入系统主界面(图一);登录名或者密码不正确的话会弹出提示对话框,并将用户名、密码栏置空(图二);如果用户名或者密码有空,弹出对话框并将用户名、密码栏置空(图三)。 图1 图2 图3 图42. 系统主界面 功能说明:选择各个功能模块 源代码:private void Form2_FormClosing(object sender, For
11、mClosingEventArgs e) Application.Exit(); private void button_exit_Click(object sender, EventArgs e) Application.Exit(); private void button_new_book_Click(object sender, EventArgs e) Form3 form3 = new Form3();/新书登记 form3.Show(); /初始化对应界面,和上面类似,不再赘述 界面演示:如图43. 书库管理1) 新书登记: 功能说明:入库的实现过程是首先要输入书籍的各种信息,包
12、括书的书号、书名、作者、出版社、价钱、总量、现存量等,这里书的数量由两个变量来记录,总量代表图书馆中这种这种书的总量,现存量是目前正在管中的量,两者之差就是被读者借出去的数量。其中每个信息不能有遗漏或者格式不正确,因为这是每一本书的基本信息,在函数的实现过程中有检验的功能。然后判断图书馆中是否存在这种图书,如果存在,那么时间简单的把库存的数量加上新加入的数量,如果不存在,那么就要新建记录。 源代码:连接数据库:SqlDataAdapter da = new SqlDataAdapter();DataSet ds = new DataSet();程序主体:/主界面调用的每个模块的返回按钮都是隐藏
13、本体,以后不再写出返回按钮的操作带代码private void button_back_Click(object sender, EventArgs e)/返回 this.Visible = false; private void button_in_Click(object sender, EventArgs e)/入库 int res; /检验输入数据是否合法 if (this.textBox_book_no.Text.Trim() = |this.textBox_name .Text .Trim ()= |boBox_press .Text .Trim ()=|this.textBox_
14、price .Text .Trim ()= |this.textBox_total .Text .Trim ()=|this.textBox_writer .Text .Trim ()=) MessageBox.Show (请正确填写要求的数据!, 新书入库登记); this.textBox_book_no.Text = ; this.textBox_name.Text = ; boBox_press .Text = ; this.textBox_price.Text = ; this.textBox_total.Text = ; this.textBox_writer.Text = ; /判
15、断书库中是否有该书,有,仅把数量加进去,没有,加进一条新的记录 else if (con.State = ConnectionState.Closed) con.Open(); String str1 = select Total_Amount from Book_Info where Book_ID= + this.textBox_book_no.Text.Trim() + ; SqlCommand com1 = new SqlCommand(str1, con); int total_num = Convert.ToInt32(com1.ExecuteScalar(); String st
16、r2 = select Now_Amount from Book_Info where Book_ID= + this.textBox_book_no.Text.Trim() + ; SqlCommand com2 = new SqlCommand(str2, con); int now_num = Convert.ToInt32(com2.ExecuteScalar(); int num1 = Convert.ToInt32(this.textBox_total.Text); total_num += num1; now_num += num1; String str = select co
17、unt(*) from Book_Info where Book_ID= + this.textBox_book_no.Text.Trim() + ; SqlCommand com = new SqlCommand(str, con); int i = Convert.ToInt32(com.ExecuteScalar(); if (i 0) String str3 = update dbo.Book_Info set Total_Amount= + total_num.ToString ().Trim () + ,Now_Amount= + now_num.ToString() .Trim
18、() + where Book_ID= + this.textBox_book_no.Text.Trim() + ; da.UpdateCommand = new SqlCommand(str3, con); res=da.UpdateCommand.ExecuteNonQuery(); if(res0) MessageBox.Show(新书入库成功!,新书登记); else MessageBox.Show(新书入库失败!, 新书登记); else String bookid = this.textBox_book_no.Text .ToString().Trim(); String name
19、 = this.textBox_name.Text .ToString().Trim(); String writer = this.textBox_writer.Text .ToString().Trim(); String press = boBox_press .Text .ToString().Trim(); float price =(float) Convert.ToDouble (this.textBox_price.Text .ToString().Trim(); String dt = DateTime.Now.ToString(); int totalaccount = C
20、onvert.ToInt32(total_num.ToString().Trim(); int nowacount =Convert .ToInt32 (now_num.ToString().Trim(); String str3 = insert into dbo.Book_Info (Book_ID,Book_Name,Writer,Press,Price,+ InLibrary_Date,Total_Amount,Now_Amount) +values (+bookid+,+name+, +writer+,+press+,+price+, + dt + ,+totalaccount+,+
21、nowacount+); da.InsertCommand = new SqlCommand(str3, con); res=da.InsertCommand.ExecuteNonQuery(); if (res 0) MessageBox.Show(新书入库成功!, 新书登记); else MessageBox.Show(新书入库失败!, 新书登记); con.Close(); /主界面调用的每个模块的关闭按钮都是隐藏本体,以后不再写出关闭按钮的操作带代码 private void Form3_FormClosing(object sender, FormClosingEventArgs e
22、) this.Visible = false; private void button_check_Click(object sender, EventArgs e)/查询 if (con.State = ConnectionState.Closed) con.Open(); int i; String str1; ds.Tables.Clear(); if (this.textBox_book_no.Text.Trim() = & this.textBox_name.Text.Trim() = & boBox_press .Text.Trim() = & this.textBox_price
23、.Text.Trim() = & this.textBox_total.Text.Trim() = & this.textBox_writer.Text.Trim() = ) MessageBox.Show(请填写任一项进行查询!, 新书入库登记); else if (this.textBox_book_no.Text != )/按书号查找 String str = select count(*) from dbo.Book_Info where Book_ID= + this.textBox_book_no.Text.ToString().Trim() + ; da.SelectComman
24、d = new SqlCommand(str, con); i = Convert.ToInt32(da.SelectCommand.ExecuteScalar(); if (i 0) str1 = select * from dbo.Book_Info where Book_ID= + this.textBox_book_no.Text.ToString().Trim() + ; da.SelectCommand = new SqlCommand(str1, con); da.Fill(ds, selectifo2); dataGridView_result.DataSource = ds.
25、Tablesselectifo2; dataGridView_result.Refresh(); else MessageBox.Show(不存在此记录!); else if (this.textBox_name.Text != )/按书名查找 /和上面类似 else if (this.textBox_writer.Text != )/按作者查找 /和上面类似 else if (this.textBox_price.Text != )/按单价查找 /和上面类似 else if (boBox_press.Text != )/按出版社查找 /和上面类似 else if (this.textBox_
26、total.Text != )/按总量查找 /和上面类似 con.Close(); /更新的代码操作就是将控件内容置空,每个模块都是,所以以后的更新操作不再给出具体代码 private void button_update_Click(object sender, EventArgs e)/更新 this.textBox_book_no.Text = ; this.textBox_name.Text = ; boBox_press .Text = ; this.textBox_price.Text = ; this.textBox_total.Text = ; this.textBox_wri
27、ter.Text = ; private void dataGridView_result_CellClick(object sender, DataGridViewCellEventArgs e) int i = dataGridView_result.CurrentRow.Index;/dataGridView当前选中行 this.textBox_book_no.Text = ds.Tablesselectifo2.Rowsi0.ToString(); this.textBox_name.Text = ds.Tablesselectifo2.Rowsi1.ToString(); this.
28、textBox_writer.Text = ds.Tablesselectifo2.Rowsi2.ToString(); this.textBox_price.Text = ds.Tablesselectifo2.Rowsi4.ToString(); boBox_press.Text = ds.Tablesselectifo2.Rowsi3.ToString(); 运行结果: 运行前数据库中Book_Info表中的数据: 图5 如果信息有没填的,点击“入库”会弹出如下对话框,图6: 图6 图7 图8 图9 填入书号后点击“查询”在DataGridView控件里会显示按书号查询的结果,图7: 在DataGridView控件里点击一条记录会在上面的textBox和ComboBox控件里显示该书的信息,图8: 20变到28本,现存量由20(图5)变到28本(图10)。并弹出图9对话
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1