1、 381) 添加账号:2) 修改密码: 403) 退出: 41四、 总结(体会、经验与教训) 42一、 系统分析1. 开发背景随着人们知识层次的提高,图书馆成为日常生活中不可缺少的一部分。而图书馆的存数量和业务量庞大,仅仅靠传统的记账式管理是不可行的。图书馆管理系统应运而生,逐渐成为信息化建设的重要组成部分。图书馆管理系统为学校或社会型图书馆的管理员提供所有借阅者的详细信息,以及馆内库存的详细情况,对借书和还书两大功能进行合理操纵并登记。2. 需求分析经过仔细分析系统需求之后,本图书管理系统主要完成的主要功能如下: 进入系统前需要身份验证、用户名、密码,输入正确后方可进入。 用户可以根据需要进
2、行书库管理。 用户可以进行借书证的办理、查询、挂失等操作。 用户可以添加账户和修改密码。 身份验证:提供系统的访问控制功能。 书库管理:包括新书登记、借书、还书、书籍挂失、图书信息查询、借书信息查询等功能。 借阅证管理:提供办理借阅证、借阅证信息查询、借阅证挂失功能。 系统管理功能:包括添加账号、修改密码和退出系统等功能。二、 系统设计1. 系统总体结构通过对图书管理系统的功能分析,可以定义出系统的功能模块图如下:2. 数据库设计 管理员基本信息表字段名称数据类型可否为空约束条件说明WorkIDintNOT NULL主键成员IDUser_NameVARCHAR(24)无姓名Password密码
3、 图书信息表Book_IDVARCHAR(50)书籍IDBook_Name书名Writer作者Press出版社Pricefloat单价InLibrary_Datedatetime入库时间Total_Amount总量Now_Amount现存量 借阅卡信息表Proof_ID借阅卡IDNameSex性别Birth_Time出生日期Address地址ID_Number身份证号Tel_Number电话号码Now_Borrow_Amount现借书量 借书信息表BorrowID借书ID外键(Proof_Info)借书卡ID外键(Book_Info)Borrow_Date借出时间 罚单信息表Puni_ID罚单
4、IDReturn_Date还书时间Puni_Money罚金3. 编码设计 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. 登录 功能说明:验证管理员的用户名和密码是否
5、正确,正确则进入主界面。 源代码:头文件:using System.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(用户名和
6、密码都不能为空! if (con.State = ConnectionState.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
7、 = new Form2();/系统主界面 form2.Show(); this.Visible = false; else用户名或密码输入有误,请重新输入! this.UserName.Text = this.PassWord.Text = 界面演示:登录名和密码正确的话进入系统主界面(图一);登录名或者密码不正确的话会弹出提示对话框,并将用户名、密码栏置空(图二);如果用户名或者密码有空,弹出对话框并将用户名、密码栏置空(图三)。 图1 图2 图3 图42. 系统主界面选择各个功能模块private void Form2_FormClosing(object sender, FormClo
8、singEventArgs e) private void button_exit_Click(object sender, EventArgs e)private void button_new_book_Click(object sender, EventArgs e) Form3 form3 = new Form3();/新书登记 form3.Show();/初始化对应界面,和上面类似,不再赘述如图43. 书库管理入库的实现过程是首先要输入书籍的各种信息,包括书的书号、书名、作者、出版社、价钱、总量、现存量等,这里书的数量由两个变量来记录,总量代表图书馆中这种这种书的总量,现存量是目前正
9、在管中的量,两者之差就是被读者借出去的数量。其中每个信息不能有遗漏或者格式不正确,因为这是每一本书的基本信息,在函数的实现过程中有检验的功能。然后判断图书馆中是否存在这种图书,如果存在,那么时间简单的把库存的数量加上新加入的数量,如果不存在,那么就要新建记录。SqlDataAdapter da = new SqlDataAdapter();DataSet ds = new DataSet();/主界面调用的每个模块的返回按钮都是隐藏本体,以后不再写出返回按钮的操作带代码private void button_back_Click(object sender, EventArgs e)/返回 p
10、rivate 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_price .Text .Trim ()= |this.textBox_total .Text .Trim ()=|this.textBox_writer .Text .Trim ()= MessageBox
11、.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 = /判断书库中是否有该书,有,仅把数量加进去,没有,加进一条新的记录 String str1 = select Total_Amount from Book_Info where Book_ID= + this.textBox_book_no.
12、Text.Trim() + SqlCommand com1 = new SqlCommand(str1, con); int total_num = Convert.ToInt32(com1.ExecuteScalar(); String str2 = select Now_Amount from Book_Info where Book_ID= SqlCommand com2 = new SqlCommand(str2, con); int now_num = Convert.ToInt32(com2.ExecuteScalar(); int num1 = Convert.ToInt32(t
13、his.textBox_total.Text); total_num += num1; now_num += num1;select count(*) from Book_Info where Book_ID= String str3 = update dbo.Book_Info set Total_Amount= + total_num.ToString ().Trim () + ,Now_Amount= + now_num.ToString() .Trim () + where Book_ID= da.UpdateCommand = new SqlCommand(str3, con); r
14、es=da.UpdateCommand.ExecuteNonQuery(); if(res0)新书入库成功!,新书登记新书入库失败! String bookid = this.textBox_book_no.Text .ToString().Trim(); String name = this.textBox_name.Text .ToString().Trim(); String writer = this.textBox_writer.Text .ToString().Trim(); String press = boBox_press .Text .ToString().Trim();
15、float price =(float) Convert.ToDouble (this.textBox_price.Text .ToString().Trim(); String dt = DateTime.Now.ToString(); int totalaccount = Convert.ToInt32(total_num.ToString().Trim(); int nowacount =Convert .ToInt32 (now_num.ToString().Trim();insert into dbo.Book_Info (Book_ID,Book_Name,Writer,Press
16、,Price,+InLibrary_Date,Total_Amount,Now_Amount) +values (+bookid+,+name+ +writer+press+price+ + dt + +totalaccount+nowacount+) da.InsertCommand = new SqlCommand(str3, con); res=da.InsertCommand.ExecuteNonQuery(); if (res con.Close(); /主界面调用的每个模块的关闭按钮都是隐藏本体,以后不再写出关闭按钮的操作带代码 private void Form3_FormClo
17、sing(object sender, FormClosingEventArgs e) private void button_check_Click(object sender, EventArgs e)/查询 int i; String str1; ds.Tables.Clear(); & this.textBox_name.Text.Trim() = boBox_press .Text.Trim() = this.textBox_price.Text.Trim() = this.textBox_total.Text.Trim() = this.textBox_writer.Text.Tr
18、im() = 请填写任一项进行查询! if (this.textBox_book_no.Text != )/按书号查找select count(*) from dbo.Book_Info where Book_ID= this.textBox_book_no.Text.ToString().Trim() + da.SelectCommand = new SqlCommand(str, con); i = Convert.ToInt32(da.SelectCommand.ExecuteScalar(); str1 = select * from dbo.Book_Info where Book_
19、ID= + da.SelectCommand = new SqlCommand(str1, con); da.Fill(ds, selectifo2 dataGridView_result.DataSource = ds.Tables; dataGridView_result.Refresh();不存在此记录! else if (this.textBox_name.Text !)/按书名查找 /和上面类似 else if (this.textBox_writer.Text !)/按作者查找 else if (this.textBox_price.Text !)/按单价查找 else if (b
20、oBox_press.Text !)/按出版社查找 else if (this.textBox_total.Text !)/按总量查找/更新的代码操作就是将控件内容置空,每个模块都是,所以以后的更新操作不再给出具体代码 private void button_update_Click(object sender, EventArgs e)/更新 private void dataGridView_result_CellClick(object sender, DataGridViewCellEventArgs e) int i = dataGridView_result.CurrentRow.
21、Index;/dataGridView当前选中行 this.textBox_book_no.Text = ds.Tables.Rowsi0.ToString(); this.textBox_name.Text = ds.Tables.Rowsi1.ToString(); this.textBox_writer.Text = ds.Tables.Rowsi2.ToString(); this.textBox_price.Text = ds.Tables.Rowsi4.ToString(); boBox_press.Text = ds.Tables.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