《管理信息系统实习》报告
专 业 班 级
学 生 姓 名
指 导 教 师
王 桃 群
2012.3.13~2012.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)
字段名
rdType
rdTypeName
CanLendQty
CanLendDay
CanContinueTimes
PunishRate
DateValid
数据类型
SmallInt
Varchar(8)
Int
Int
Int
Float
SmallInt
说明
读者类别【主键】
读者类别名称
可借书数量
可借书天数
可续借的次数
罚款率(分/天/本)
证书有效日期
说明
读者序号【主键】
读者姓名
读者密码,初值为“123”
性别,0-男,1-女
读者类别【外键】
单位代码
电话号码
电子邮件
读者登记日期
已借书数量
说明
图书序号【主键】
图书编号
书名
作者
出版社
出版日期
书号
2. 读者信息表(Reader)
字段名
rdID
rdName
rdPwd
rdSex
rdType
rdDept
rdPhone
rdEmail
rdDateReg
rdBorrowQty
数据类型
Int
varchar(10)
varchar (10)
Bit
SmallInt
Char(8)
varchar(25)
varchar(25)
smalldatetime
Int
3. 图书信息表(Book)
数据类型
Int
Char(20)
Varchar(50)
Varchar(30)
Varchar(50)
Smalldatetime
Char(15)
Varchar(30)
SmallInt
字段名
bkID
bkCode
bkName
bkAuthor
bkPress
bkDatePress
bkISBN
bkCatalog
bkLanguage
bkPages
bkPrice
bkDateIn
bkBrief
bkCover
bkIsInLab
分类名
语言,0-中文,1-英文,2-日文,3-俄文,
4-德文,5-法文
页数
内容简介
是否在馆
价格
Int
Money
SmallDateTime
Text
Varchar(100) 或 image 图书封面照片
Char(4)
入馆日期
4. 借阅信息表(Borrow)
字段名
rdID
bkID
ldContinueTimes
ldDateOut
ldDateRetPlan
ldDateRetAct
ldOverDay
ldOverMoney
数据类型
Int
Int
Int
SmallDateTime
SmallDateTime
SmallDateTime
Int
Money
说明
读者序号【主键】
图书序号【主键】
续借次数(第一次借时,记为 1)
借书日期
应还日期
实际还书日期
超期天数
超期金额
ldPunishMoney
lsHasReturn
OperatorLend
OperatorRet
Money
Bit
VarChar(10)
VarChar(10)
罚款金额
是否已经还书,缺省为 0-未还
借书操作员
还书操作员
四、系统实现
登录的代码实现:
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();
//cmd.commandText = "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.Tables[0];
txtName.DataBindings.Clear();
txtAuthor.DataBindings.Clear();
txtPage.DataBindings.Clear();
txtPress.DataBindings.Clear();
txtName.DataBindings.Add("Text",ds.Tables[0],"书名");
txtAuthor.DataBindings.Add("Text",ds.Tables[0],"作者");
txtPage.DataBindings.Add("Text",ds.Tables[0],"页数");
txtPress.DataBindings.Add("Text", ds.Tables[0], "出版社");
//上面的代码是在窗体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 = "";
//按作者查找