图书管理系统课程设计报告.doc_第1页
图书管理系统课程设计报告.doc_第2页
图书管理系统课程设计报告.doc_第3页
图书管理系统课程设计报告.doc_第4页
图书管理系统课程设计报告.doc_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

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

文档简介

管理信息系统实习报告专 业 班 级 学 生 姓 名 指 导 教 师 王 桃 群 时 间 2012.3.132012.3.23 成 绩 评 语 一、课程设计题目 图书管理系统二、系统需求1.系统的准备操作系统:Windows xp数据库系统:SQL Server 2000 或 SQL Server 2005客户端开发工具:Visual Studio 2005或其他开发工具2.知识准备熟悉SQL Server 2000 或 SQL Server 2005的使用;熟悉C#、ASP.NET或其他语言进行数据库编程。3.系统分析图书信息包括:每种图书都有书名、ISBN、一名或多名作者(译者)、出版社、定价和内容简介等;读者信息包括:借书证记录有借阅者的姓名、密码、所在单位和类别等;读者凭借书证借书,教师最多借书15本书,借书期限最长为90天,学生最多借书8本书,借书期限最长为30天。对于超期未还的读者不能继续借书,每本书每超期一天罚款0.05元。三、系统设计1.体系结构本系统使用c/s模式的两层结构,表示层(USL)和数据访问层(DAL)。表示层(USL):为客户提供对应用程序的访问,以Windows应用程序或Web应用程序的形式提供实现的功能。业务逻辑层(BLL):实现应用程序的业务功能,以类库的形式为表示层提供服务。数据访问层(DAL):实现整个系统所有的数据库连接、数据存取操作,以组件类库的形式为业务逻辑层提供服务。此外,实体类,简单地说是描述一个业务实体的类。业务实体直观一点的理解就是整个应用系统业务所涉及的对象,从数据存储来讲,业务实体就是存储应用系统信息的数据表,将数据表中的每一个字段定义成属性,并将这些属性用一个类封装,这个类就称为实体类。2.功能模块框图图 书 管 理借 书图 书 管 理借书图书更新图书删除图书查找图书添加3.数据库设计1. 读者类别表(ReaderType)字段名数据类型说明rdTypeSmallInt读者类别【主键】rdTypeNameVarchar(8)读者类别名称CanLendQtyInt可借书数量CanLendDayInt可借书天数CanContinueTimesInt可续借的次数PunishRateFloat罚款率(分/天/本)DateValidSmallInt证书有效日期2. 读者信息表(Reader)字段名数据类型说明rdIDInt读者序号【主键】rdNamevarchar(10)读者姓名rdPwdvarchar (10)读者密码,初值为“123”rdSexBit性别,0-男,1-女rdTypeSmallInt读者类别【外键】rdDeptChar(8)单位代码rdPhonevarchar(25)电话号码rdEmailvarchar(25)电子邮件rdDateRegsmalldatetime读者登记日期rdBorrowQtyInt已借书数量3. 图书信息表(Book)字段名数据类型说明bkIDInt图书序号【主键】bkCodeChar(20)图书编号bkNameVarchar(50)书名bkAuthorVarchar(30)作者bkPressVarchar(50)出版社bkDatePressSmalldatetime出版日期bkISBNChar(15)书号bkCatalogVarchar(30)分类名bkLanguageSmallInt语言,0-中文,1-英文,2-日文,3-俄文,4-德文,5-法文bkPagesInt页数bkPriceMoney价格bkDateInSmallDateTime入馆日期bkBriefText内容简介bkCoverVarchar(100) 或image图书封面照片bkIsInLabChar(4)是否在馆4. 借阅信息表(Borrow)字段名数据类型说明rdIDInt读者序号【主键】bkIDInt图书序号【主键】ldContinueTimesInt续借次数(第一次借时,记为1)ldDateOutSmallDateTime借书日期ldDateRetPlanSmallDateTime应还日期ldDateRetActSmallDateTime实际还书日期ldOverDayInt超期天数ldOverMoneyMoney超期金额ldPunishMoneyMoney罚款金额lsHasReturnBit是否已经还书,缺省为0-未还OperatorLendVarChar(10)借书操作员OperatorRetVarChar(10)还书操作员四、系统实现 登录的代码实现:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace BooksMng public partial class BookLogin : Form public BookLogin() InitializeComponent(); private void textBox2_TextChanged(object sender, EventArgs e) private void btnlogin_Click(object sender, EventArgs e) /连接数据库 SqlConnection conn = new SqlConnection(server=.;database=Booksmng; integrated security=True); conn.Open(); SqlCommand cmd = conn.CreateCommand(); /cmd.CommandText=select count(*) from Users where userName=+txtName.Text+and userPwd=+txtPwd.Text+; cmd.CommandText = select count(*) from Users where userName=userName and userPwd=userPwd; cmd.Parameters.Add(userName, SqlDbType.VarChar, 20).Value = txtName.Text; cmd.Parameters.Add(userPwd, SqlDbType.VarChar, 20).Value = txtPwd.Text; try int count = Convert.ToInt32(cmd.ExecuteScalar(); if (count != 0) MessageBox.Show(登陆成功!); BookMain frm = new BookMain(); frm.Show(); catch (SqlException ex) /MessageBox.Show(登录失败!); MessageBox.Show(ex.Message); private void FrmLogin_Load(object sender, EventArgs e) 图书管理部分,主要的代码实现如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace BooksMng public partial class BookManage : Form public BookManage() InitializeComponent(); private void Form2_Load(object sender, EventArgs e) DataBind(); private void DataBind() /连接数据库 SqlConnection conn = new SqlConnection(server=.; database=BooksMng;integrated security=True); /SqlConnection conn = new SqlConnection(server=.; database=BooksMng;integrated security=True); conn.Open(); SqlCommand cmd = conn.CreateCommand(); /mandText = select * from Book; cmd.CommandText = select bkID 编号, bkName 书名,bkAuthor 作者,bkPages 页数,bkPress 出版社 from Book; SqlDataAdapter sda = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); sda.Fill(ds); dgvBooks.DataSource = ds.Tables0; txtName.DataBindings.Clear(); txtAuthor.DataBindings.Clear(); txtPage.DataBindings.Clear(); txtPress.DataBindings.Clear(); txtName.DataBindings.Add(Text,ds.Tables0,书名); txtAuthor.DataBindings.Add(Text,ds.Tables0,作者); txtPage.DataBindings.Add(Text,ds.Tables0,页数); txtPress.DataBindings.Add(Text, ds.Tables0, 出版社); /上面的代码是在窗体Load时,将Books表中的所有记录,即所有的图书信息显示在网格DataGrid空间中。 / /下面是实现添加功能 private void btnAdd_click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(server=.; database=BooksMng;integrated security=True); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = insert into Book(bkName, bkAuthor,bkPages,bkPress) values(bkName,bkAuthor,bkPages,bkPress); cmd.Parameters.Add(bkName, SqlDbType.VarChar, 30).Value = txtName.Text; cmd.Parameters.Add(bkAuthor, SqlDbType.VarChar, 30).Value = txtAuthor.Text; cmd.Parameters.Add(bkPages, SqlDbType.Int).Value =Convert.ToInt32(txtPage.Text);/类型转换 cmd.Parameters.Add(bkPress, SqlDbType.VarChar, 50).Value = txtPress.Text; try cmd.ExecuteNonQuery(); /执行上述SQL命令 MessageBox.Show(图书添加成功!); DataBind(); /重新将数据库绑定到DataGrid catch (SqlException ex) MessageBox.Show(图书添加失败); MessageBox.Show(ex.Message); private void btnSearch_Click(object sender, EventArgs e) /连接数据库 SqlConnection conn = new SqlConnection(server=.; database=BooksMng;integrated security=True); conn.Open(); SqlCommand cmd = conn.CreateCommand(); String sql = ; /按作者查找 if (txtAuthor.Text != ) sql += select bkID 编号, bkName 书名,bkPages 页数,bkPress 出版社 from Book where bkAuthor=bkAuthor; try cmd.CommandText=sql; cmd.Parameters.Add(bkAuthor, SqlDbType.VarChar, 30).Value = txtAuthor.Text; SqlDataAdapter sda=new SqlDataAdapter(cmd); DataSet ds=new DataSet(); sda.Fill(ds); dgvBooks.DataSource = ds.Tables0; catch(SqlException ex) MessageBox.Show(查找失败); MessageBox.Show(ex.Message); private void btnDelete_Click(object sender, EventArgs e) /连接数据库 SqlConnection conn = new SqlConnection(server=.; database=BooksMng;integrated security=True); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = delete from Book where bkID=bkID; cmd.Parameters.Add(bkID, SqlDbType.Int).Value = Convert.ToInt32(dgvBooks0, dgvBooks.CurrentRow.Index.Value); try if (MessageBox.Show(确定要删除该图书吗?, 确定删除, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.OK) cmd.ExecuteNonQuery(); MessageBox.Show(删除成功!); DataBind(); catch (SqlException ex) MessageBox.Show(删除失败); MessageBox.Show(ex.Message); /下面做更新图书信息 private void btnUpdate_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(server=.; database=BooksMng;integrated security=True); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = update Book set bkName=bkName, bkAuthor=bkAuthor, bkPages=bkPages,bkPress=bkPress where bkID=bkID; cmd.Parameters.Add(bkID, SqlDbType.Int).Value = Convert.ToInt32(dgvBooks0, dgvBooks.CurrentRow.Index.Value); cmd.Parameters.Add(bkName, SqlDbType.VarChar, 30).Value = txtName.Text; cmd.Parameters.Add(bkAuthor, SqlDbType.VarChar, 30).Value =txtAuthor.Text; cmd.Parameters.Add(bkPages, SqlDbType.Int).Value = Convert.ToInt32(txtPage.Text);/类型转换 cmd.Parameters.Add(bkPress, SqlDbType.VarChar, 50).Value = txtPress.Text; try if (MessageBox.Show(确定要更新图书信息吗?, 确认更新, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.OK) cmd.ExecuteNonQuery(); MessageBox.Show(更新成功!); DataBind(); catch (SqlException ex) MessageBox.Show(更新失败); MessageBox.Show(ex.Message); /图书可以添加成功借书实现主要代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace BooksMng public partial class BookBorrow : Form public BookBorrow() InitializeComponent(); /获取读者可借天数 private int GetLendDay(int rdID) SqlConnection conn = new SqlConnection(server=.;database=BooksMng;integrated security=true); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = select CanLendDay from ReaderType where rdType=(select rdType from Reader where rdID= + rdID + ); return Convert.ToInt32(cmd.ExecuteScalar(); private void btnBorrow_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(server=.;database=BooksMng;integrated security=true); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = insert into Borrow(rdID,bkID,ldContinueTimes,IdDateOut,ldDateRetPlan,lsHasReturn) values(rdID,bkID,0,IdDateOut,ldDateRetPlan,0); cmd.Parameters.Add(rdID, SqlDbType.Int).Value = Convert.ToInt32(txtrdID.Text); cmd.Parameters.Add(bkID, SqlDbType.Int).Value = Convert.ToInt32(txtbkID.Text);/类型转换 cmd.Parameters.Add(IdDateOut, SqlDbType.DateTime).Value = DateTime.Now;/借书时间为当前的系统时间 /应还日期为=借书日期+可借天数cmd.Parameters.Add(ldDateRetPlan, SqlDbType.DateTime).Value = DateTime.Now.AddDays(GetLendDay(Convert.ToInt32(txtrdID.Text); try cmd.ExecuteNonQuery(); MessageBox.Show(借书成功!); catch (SqlException ex) MessageBox.Show(借书失败); MessageBox.Show(ex.Message); 五、系统运行效果 图书管理模块的运行结果如下:首先,设计一个用户登录界面,以管理员的身份登录来实现图书的添加、查找、删除、更新的功能。 登录界面的设计:登录成功的效果登录成功以后,跳到图书管理主界面:图书管理主界面如下:登录成功以后,跳到图书管理的页面:图书管理的页面如下: 此界面可以对图书实现添加、查找、删除和信息更新这四个功能。从图书管理主界面跳到借书界面:六、遇到的问题及解决方法 在实现借书这个功能时,老是借书失败,并且提示: 凭借这个提示是不可能找到错误的,为了找到这个错误,我设置了一个断点如图: 然后逐句运行,发现错误在 “catch (SqlException ex)”这句,并且提示:点击获取错误的帮助,软件给出的帮助是:我不知道这是什么错

温馨提示

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

最新文档

评论

0/150

提交评论