数据库课程设计图书管理系统_第1页
数据库课程设计图书管理系统_第2页
数据库课程设计图书管理系统_第3页
数据库课程设计图书管理系统_第4页
数据库课程设计图书管理系统_第5页
已阅读5页,还剩41页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、课 程 设 计课程设计名称: 数据库应用系统课程设计 专 业 班 级 : 计科0906 学 生 姓 名 : 学 号 : 指 导 教 师 : 课程设计时间: 2011-12-19至2011-12-30 计算机科学与技术 专业课程设计任务书学生姓名专业班级计科0906学号题 目图书管理系统课题性质其它课题来源自拟课题指导教师王社伟同组姓名无主要内容图书馆作为学校的核心机构,传统的登记式已经不能满足,信息量越来越大的图书馆需求。时间一长,将产生大量的文件和数据,这对于查找、更新和维护都带来了不少的困难。课题要求设计并实现一个图书管理系统,能够通过计算机和数据库满足对图书信息的管理工作。功能应包括:登

2、录对角色的判断、登陆密码修改、新书入库、旧书淘汰、借书还书管理、书本修改、增加读者、读书排行查询、读者对自己信息查询、读者多条件查询和统计等。界面设计相对友好,方便用户的操作。任务要求综合运用所学的数据库根本知识,并能通过查阅相关文献材料,独立完成该课题的设计开发工作。要求根据本课题设计出合理的数据结构,并实现图书管理系统中, 登录对角色的判断、登陆密码修改、新书入库、旧书淘汰、借书还书管理、书本修改、增加读者、读书排行查询、读者对自己信息查询、读者多条件查询和统计等。参考文献1.数据库原理与应用教程SQL Server尹志宇、郭晴审查意见指导教师签字:教研室主任签字: 年 月 日 填 表 说

3、 明1“课题性质一栏:A工程设计;B工程技术研究;C软件工程如CAI课题等;D文献型综述;E其它。2“课题来源一栏:A自然科学基金与部、省、市级以上科研课题;B企、事业单位委托课题;C校、院系、部级基金课题;D自拟课题。图书管理系统1 概述“图书是人类进步的阶梯,是人类的精神财富,是人类的终身伴侣。图书作为教学和学习必不可少的工具,它的作用举足轻重,它几乎存在与每一个学校之中,而相当一局部的设施条件不好资金缺乏的学校甚至对于图书的管理,采用传统的纸质的方式去完成,这样就导致了很多很多的问题,例如:不能很好的对读者借书还书管理,当读者需要还书的时候还要查找以前的纸质文档来找到相应的记录,非常的麻

4、烦;时间长的话图书馆的资料一旦丧失很难再恢复,给整个工作带来很大的困难;读者也只有通过去学校图书馆才能一本一本挨个的寻找才能找到自己想要找到书本等等一系列的问题。针对以上情况开发一个图书管理系统,来实现管理员和读者两个角色的管理使用,对于读者,可以不用去图书馆直接在自己电脑上按多种条件轻松的查找自己想要找的书本的信息,可以很轻松的看到自己借阅的信息来方便读者及时的归还相应的信息,可以很容易的看到读者对在馆书籍的借阅排行问题,来了解图书的热度以及为了个人平安来对密码的管理。而对于图书的管理员,他实现的功能就相当的复杂了,首先它可以增加读者信息,可以对新书进行入库,删除旧书,这里所说的旧书是没有人

5、借阅的书,当有读者节约的时候,管理员就不能删除图书的信息了,可以查询所有的读者信息,可以对图书进行修改校正,以及解决自己登陆平安性的问题。最重要的是可以进行对图书的借阅和归还,同时改变图书库存和被借阅次数的信息。本图书管理系统可以更加人性化的满足小型图书馆的日常借阅问题,到达一个很理想的智能管理目的。2 需求分析业务流程:本系统的流程图如下: 图2.1 系统功能模块数据流图如下:图2.2 业务流程图数据字典: 图 2.3 管理员表 图2.4 图书表功能分析:本系统的主要文件以及所实现功能的对照表如下:文件名 功能 登陆界面实现admain存放管理员实现功能的文件夹新书入库管理员主界面读者还书读

6、者借书查阅所有读者信息图书校正旧书淘汰修改管理员登录密码新读者注册image存放系统中所用的图片reader存放实现读者功能的文件夹查看图书借阅排行查看读者自己借阅信息读者按不同条件作者,图书代码,出版社,图书类型查询图书读者主界面读者密码修改 表 2.1 功能对照表3 概念结构设计通过需求分析阶段的分析结果,本系统所要设计的ER图如下;4逻辑结构设计设计环境:操作系统:Windows XP;DBMS:SQL Server 2005;开发工具:。管理员管理员账号,管理员密码图书图书代码,图书名称,图书类型,出版社,定价,作者,库存,被借次数读者读者编号,密码,姓名,性别,专业,联系方式借还书读

7、者编号,图书代码,借书日期,还书日期注:“_为表中的主键。改关系模型满足根本的三范式。因为每个非主属性既不局部依赖也不传递依赖于码。5源代码及系统截图在书数据库连接局部,加上<add name="图书馆ConnectionString" connectionString="Data Source=41928FCITVRT9GD;Initial Catalog=图书馆;Integrated Security=True" providerName=""/>在每个文件引用:using System.Data.SqlClient;

8、图书管理系统登录Login.aspx通过不同的角色验证,分别实现读者和管理员登录代码如下:protected void Button1_Click(object sender, EventArgs e) string ConnSql = ConfigurationManager.ConnectionStrings"图书馆ConnectionString".ConnectionString; string userName = txtUserName.Text.ToString().Trim(); string userPwd = txtPwd.Text.ToString()

9、.Trim(); string userRole = rblClass.SelectedValue.Trim(); string selectStr = "" switch (userRole) case "0": /身份为管理员时 selectStr = "Select * from 管理员 where 管理员账号 = '" + userName + "'" break; case "1": /身份为读者时 selectStr = "Select * from 读者

10、where 读者编号 = '" + userName + "'" break; SqlConnection conn = new SqlConnection(ConnSql); SqlCommand cmd = new SqlCommand(selectStr, conn); try conn.Open(); /翻开连接 SqlDataReader sdr = cmd.ExecuteReader(); /执行查询 if (sdr.Read() /如果该用户存在 if (sdr.GetString(1) = userPwd) /密码正确 Sessio

11、n"userName" = userName; Session"userRole" = userRole; conn.Close(); switch (userRole) case "0": /身份为管理员时 Response.Redirect("admain/admain.aspx"); break; case "1": /身份为读者时 Response.Redirect("reader/reader.aspx"); break; else /密码错误,给出提示信息! lb

12、lMessage.Text = "您输入的密码错误,请检查后重新输入!" else /用户不存在或用户名输入错误 lblMessage.Text = "该用户不存在或用户名输入错误,请检查后重新输入!" catch (Exception ee) Response.Write("<script language=javascript>alert('" + ee.Message.ToString() + "')</script>"); finally conn.Close();

13、protected void TextBox2_TextChanged(object sender, EventArgs e) protected void txtUserName_TextChanged(object sender, EventArgs e) protected void Button2_Click(object sender, EventArgs e) txtUserName.Focus(); txtUserName.Text = txtPwd.Text = string.Empty; 程序运行结果如图: 图5.1 系统登陆页面5.2 读者主页面reader.aspx显示读

14、者的每个功能的页面程序代码如下:protected void Page_Load(object sender, EventArgs e) if (!this.IsPostBack) Label1.Text = "欢送学生" + Session"userName".ToString() + "进入本系统!" Label2.Text = DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日&qu

15、ot; / Label3.Text = operatorclass.getWeek(); protected void Button2_Click(object sender, EventArgs e) Response.Redirect("xiugai.aspx"); protected void Button3_Click(object sender, EventArgs e) Response.Redirect("chaziji.aspx"); protected void Button4_Click(object sender, EventArg

16、s e) Response.Redirect("look.aspx"); protected void Button5_Click(object sender, EventArgs e) Response.Write("<a href='javascript:window.opener=null;window.close()'>关闭窗口</a>"); protected void Button1_Click(object sender, EventArgs e) Response.Redirect("bo

17、okpaihang.aspx"); 程序运行结果如图: 图5.2 读者主页面 5.3管理员主页面显示和索引管理员实现的功能程序代码如下: protected void Page_Load(object sender, EventArgs e) if (!this.IsPostBack) Label1.Text = "欢送管理员" + Session"userName".ToString() + "进入本系统!" Label2.Text = DateTime.Now.Year + "年" + DateTim

18、e.Now.Month + "月" + DateTime.Now.Day + "日" protected void Button5_Click(object sender, EventArgs e) Response.Redirect("xiugai.aspx"); protected void Button1_Click(object sender, EventArgs e) Response.Redirect("add.aspx"); protected void Button3_Click(object se

19、nder, EventArgs e) Response.Redirect("gaishu.aspx"); protected void Button8_Click(object sender, EventArgs e) Response.Redirect("zengdu.aspx"); protected void Button7_Click(object sender, EventArgs e) Response.Redirect("shanbook.aspx"); protected void Button4_Click(obje

20、ct sender, EventArgs e) Response.Redirect("back.aspx"); protected void Button2_Click(object sender, EventArgs e) Response.Redirect("borrow.aspx"); protected void Button9_Click(object sender, EventArgs e) Response.Write("<a href='javascript:window.opener=null;window.cl

21、ose()'>关闭窗口</a>"); protected void Button10_Click(object sender, EventArgs e) Response.Redirect("duzhe.aspx"); 程序运行结果如图: 图5.3 管理员主页面5.4 新书入库 程序代码如下:protected void Page_Load(object sender, EventArgs e) this.Title = "新书入库" TextBox1.Focus(); protected void Submit_Cl

22、ick1(object sender, EventArgs e) string ConnSql = ConfigurationManager.ConnectionStrings"图书馆ConnectionString".ConnectionString; /声明Conn为一个SQL Server连接对象 SqlConnection Conn = new SqlConnection(ConnSql); Conn.Open();/翻开连接 SqlDataAdapter da = new SqlDataAdapter(); string SelectSql = "sel

23、ect * from 图书" da.SelectCommand = new SqlCommand(SelectSql, Conn); SqlCommandBuilder scb = new SqlCommandBuilder(da); DataSet ds = new DataSet(); da.Fill(ds); Conn.Close(); DataRow NewRow = ds.Tables0.NewRow(); NewRow"图书代码" = TextBox1.Text;/为新行的各字段赋值 NewRow"图书名称" = TextBox2.

24、Text; NewRow"图书类型" = TextBox3.Text; NewRow"出版社" = TextBox4.Text; NewRow"定价" = TextBox5.Text; NewRow"作者" = TextBox6.Text; NewRow"库存" = TextBox7.Text;NewRow"被借次数" = TextBox8.Text; ds.Tables0.Rows.Add(NewRow);/将新建行添加到DataSet第一个表对象中 da.Update(d

25、s);/将DataSet中数据变化提交到数据库更新数据库 Response.Write("<script language=javascript>alert('新记录添加成功,请单击“返回回到主页面!');</script>"); protected void TextBox1_TextChanged(object sender, EventArgs e) protected void BackHome_Click1(object sender, EventArgs e) Response.Redirect("admain.

26、aspx"); 程序运行结果如图: 图5.4(1) 新书入库 图5.4(2) 新书入库成功图书校正admaingaishu.aspx程序代码如下:protected void Page_Load(object sender, EventArgs e) this.Title = "更新记录" DropDownList1.AutoPostBack = true; if (!IsPostBack) string ConnSql = "Data Source=.;Initial Catalog=图书馆;Integrated Security=True"

27、 /声明Conn为一个SQL Server连接对象 SqlConnection Conn = new SqlConnection(ConnSql); Conn.Open();/翻开连接 SqlDataAdapter da = new SqlDataAdapter(); string SelectSql = "select * from 图书" da.SelectCommand = new SqlCommand(SelectSql, Conn); SqlCommandBuilder scb = new SqlCommandBuilder(da); DataSet ds = n

28、ew DataSet(); da.Fill(ds); Conn.Close(); DataRow MyRow = ds.Tables0.Rows0; TextBox1.Text = MyRow"图书名称".ToString(); TextBox2.Text = MyRow"图书类型".ToString(); TextBox3.Text = MyRow"出版社".ToString(); TextBox4.Text = MyRow"定价".ToString(); TextBox5.Text = MyRow"作

29、者".ToString(); TextBox6.Text = MyRow"库存".ToString(); protected void Button1_Click(object sender, EventArgs e) string ConnSql = ConfigurationManager.ConnectionStrings"图书馆ConnectionString".ConnectionString; SqlConnection Conn = new SqlConnection(ConnSql); Conn.Open();/翻开连接 Sql

30、DataAdapter da = new SqlDataAdapter(); string SelectSql = "select * from 图书 where 图书代码 ='" + DropDownList1.Text + "'" da.SelectCommand = new SqlCommand(SelectSql, Conn); SqlCommandBuilder scb = new SqlCommandBuilder(da); DataSet ds = new DataSet(); da.Fill(ds); DataRow My

31、Row = ds.Tables0.Rows0;/从表对象中得到要修改 MyRow"图书名称" = TextBox1.Text; MyRow"图书类型" = TextBox2.Text; MyRow"出版社" = TextBox3.Text; MyRow"定价" = TextBox4.Text; MyRow"作者" = TextBox5.Text; MyRow"库存" = TextBox6.Text; da.Update(ds);/提交更新 Response.Write(&qu

32、ot;<script language=javascript>alert('记录更新成功,请单击“返回按钮回到主页面!');</script>"); protected void Button2_Click(object sender, EventArgs e) Response.Redirect("admain.aspx"); protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e) string ConnSql = &qu

33、ot;Data Source=.;Initial Catalog=图书馆;Integrated Security=True" SqlConnection Conn = new SqlConnection(ConnSql); Conn.Open();/翻开连接 SqlDataAdapter da = new SqlDataAdapter(); string SelectSql = "select * from 图书 where 图书代码 ='" + DropDownList1.Text + "'" da.SelectCommand

34、 = new SqlCommand(SelectSql, Conn); SqlCommandBuilder scb = new SqlCommandBuilder(da); DataSet ds = new DataSet(); da.Fill(ds); Conn.Close(); DataRow MyRow = ds.Tables0.Rows0;/从表对象中得到要修改的行 TextBox1.Text = MyRow"图书名称".ToString(); TextBox2.Text = MyRow"图书类型" .ToString(); TextBox3.T

35、ext = MyRow"出版社".ToString(); TextBox4.Text = MyRow"定价".ToString(); TextBox5.Text = MyRow"作者".ToString(); TextBox6.Text = MyRow"库存".ToString(); 程序运行结果如图:旧书淘汰(admainshanbook.aspx)该局部是通过sqldatasource 和GridView控件来实现的把没有读者借阅的图书显示出来,其中配置数据源的时候运用的是sql 语句定义的代码如下:SELEC

36、T * FROM 图书where 图书代码 not in (select 图书.图书代码 from 图书,借还书 where 图书.图书代码=借还书.图书代码 )ORDER BY 图书代码程序运行结果如图: 图5.6 旧书淘汰 修改管理员密码admainxiugai.aspx程序代码如下: /修改密码按钮事件 protected void Button1_Click(object sender, EventArgs e) /取参数 string ConnSql = ConfigurationManager.ConnectionStrings"图书馆ConnectionString&q

37、uot;.ConnectionString; string userName = Session"userName".ToString(); string oldPwd = txtOldPwd.Text.Trim(); stringrim(); string selectStr = "Select * from 管理员 where 管理员账号='" + userName + "' and 密码='" + oldPwd + "'" string updateStr = "up

38、date 管理员 set 密码='" + newPwd + "' where 管理员账号='" + userName + "'" SqlConnection conn = new SqlConnection(ConnSql); SqlCommand selectCmd = new SqlCommand(selectStr, conn); conn.Open(); SqlDataReader sdr = selectCmd.ExecuteReader(); if (sdr.Read() /如果用户存在且输入密码正确

39、,修改密码 sdr.Close(); SqlCommand updateCmd = new SqlCommand(updateStr, conn); int i = updateCmd.ExecuteNonQuery(); if (i > 0) /根据修改后返回的结果给出提示 Label1.Text = "成功修改密码" else Label1.Text = "修改密码失败!" else Response.Write("您输入的旧密码错误,检查后重新输入!"); conn.Close(); protected void Butt

40、on3_Click(object sender, EventArgs e) txtOldPwd.Text = "" txtNewPwd.Text = "" txtConfirmPwd.Text = "" 程序运行结果如图: 图5.7 管理员密码修改5.8新读者注册( admainzengdu.aspx)程序代码如下:protected void Button1_Click1(object sender, EventArgs e) SqlConnection conn = new SqlConnection(ConfigurationM

41、anager.ConnectionStrings"图书馆ConnectionString".ConnectionString);/创立连接对象 SqlCommand insertCmd = new SqlCommand("insert into 读者(读者编号,密码,姓名,性别,专业,联系方式) values(readerID,readerPwd,readerName,readerSex,readerDep,readerPhone)", conn); insertCmd.Parameters.Add("readerID", SqlDb

42、Type.Char, 12);/设置参数 insertCmd.Parameters.Add("readerPwd", SqlDbType.VarChar, 16); insertCmd.Parameters.Add("readerName", SqlDbType.Char, 10); insertCmd.Parameters.Add("readerSex", SqlDbType.Char,2); insertCmd.Parameters.Add("readerDep", SqlDbType.VarChar,20);

43、 insertCmd.Parameters.Add("readerPhone", SqlDbType.Char,11); insertCmd.Parameters"readerID".Value = TextBox1.Text; /为每个参数赋值 insertCmd.Parameters"readerPwd".Value = TextBox1.Text; insertCmd.Parameters"readerName".Value = TextBox2.Text; insertCmd.Parameters"

44、;readerSex".Value = RadioButtonList1.SelectedValue; insertCmd.Parameters"readerDep".Value = ddlDepart.SelectedValue; insertCmd.Parameters"readerPhone".Value = TextBox3.Text; conn.Open(); int flag = insertCmd.ExecuteNonQuery(); /执行添加 if (flag > 0) /如果添加成功 lblMessage.Text =

45、 "成功添加读者信息!" else /如果添加失败 lblMessage.Text = "添加读者信息失败,查看输入是否正确!" conn.Close(); protected void Button2_Click(object sender, EventArgs e) TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" protected void Button3_Click(object sender, EventArgs e)

46、Response.Redirect("admain.aspx"); 程序运行结果如图:5.9图书借阅admainborrow.aspx程序代码如下:protected void Page_Load(object sender, EventArgs e) Label1.Visible = false; Label2.Visible = false; Button2.Visible = false; Button3.Visible = false; Button4.Visible = false; /Button5.Visible = false; txtBookID.Visi

47、ble = false; protected void Button1_Click(object sender, EventArgs e) if (txtReaderID.Text = "") Response.Write("<script>alert('读者编号不能为空!')</script>"); else string ConnSql = ConfigurationManager.ConnectionStrings"图书馆ConnectionString".ConnectionString

48、; string ReaderID = txtReaderID.Text.ToString().Trim(); string selectStr = "Select 读者编号,姓名,性别,专业,联系方式 from 读者 where 读者编号= '" + ReaderID+ "'" SqlConnection conn = new SqlConnection(ConnSql); SqlCommand cmd = new SqlCommand(selectStr, conn); conn.Open(); /翻开连接 SqlDataReader sdr = cmd.ExecuteReader(); /执行查询 Session"ReaderID" = ReaderID; GridView2.DataSource = sdr; GridView2.DataBind(); if (GridView2.Rows.Count = 0) Response.Write("<script lauguage =javascript>alert('查无此人!'

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论