图书管理系统论文设计课程设计报告Word文档格式.docx
《图书管理系统论文设计课程设计报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《图书管理系统论文设计课程设计报告Word文档格式.docx(25页珍藏版)》请在冰豆网上搜索。
C#是面向对象的编程语言。
它使得程序员可以快速地编写各种基于MICROSOFT.NET平台的应用程序,MICROSOFT.NET提供了一系列的工具和服务来最大程度地开发利用计算与通讯领域。
C#使得C++程序员可以高效的开发程序,且因可调用由C/C++编写的本机原生函数,因此绝不损失C/C++原有的强大的功能。
因为这种继承关系,C#与C/C++具有极大的相似性,熟悉类似语言的开发者可以很快的转向C#。
2.2Sql数据库概述
SQLServer是一个关系数据库管理系统。
它最初是由Microsoft、Sybase和Ashton-Tate三家公司共同开发的,于1988年推出了第一个OS/2版本。
在WindowsNT推出后,Microsoft与Sybase在SQLServer的开发上就分道扬镳了,Microsoft将SQLServer移植到WindowsNT系统上,专注于开发推广SQLServer的WindowsNT版本。
Sybase则较专注于SQLServer在UNⅨ操作系统上的应用。
SQLServer2000是Microsoft公司推出的SQLServer数据库管理系统,该版本继承了SQLServer7.0版本的优点,同时又比它增加了许多更先进的功能。
具有使用方便可伸缩性好与相关软件集成
程度高等优点,可跨越从运行MicrosoftWindows98的膝上型电脑到运行MicrosoftWindows2000的大型多处理器的服务器等多种平台使用。
第三章系统分析
3.1图书管理系统设计
任何一个软件的开始都是进行系统的需求分析。
需求分析要根据用户的功能要求、界面以及其他要求进行分析,当然在此需求分析是根据我自己对图书管理系统的基本了解以及系统所需要的基本功能来进行的。
其次制作的各个流程图才是真正的系统设计,是在完成需求分析的基础上进行的。
3.2用户的功能需求分析
图书管理系统需要的功能分析如下:
管理系统具有多个用户,用户可以使用不同的用户名和密码进入管理系统,并可以修改自己的密码;
(一)进入系统后可以登录该系统;
(二)在系统中可以对数据库进行简单的操作;
(三)最基本的功能还应具有可以编辑图书——录入、删除图书资料。
图书分类信息的添加、修改、删除和查询。
此功能为图书的分类管理提供依据。
(四)图书基本信息的添加、修改、删除和查询。
3.3系统运作流程
该系统涉及到用户以及管理员,在两者之间进行一系列的操作。
管理员对图书进行录入、删除等操作,和用户之间的交流则是进行借阅图书操作。
运作流程图如图:
第四章系统的实现
4.1数据库设计
库名:
libraryDB
表名:
Administrator,book
Administrator表
Book表
4.2C#的设计
4.2.1系统登录界面
函数名称
功能
privatevoidbutton2_Click(objectsender,EventArgse)
取消按钮操作
publicboolCheckInput()
非空验证
publicboolCheckUser(refstringmessage
检查用户是否存在
dbhelper.CloseConnection();
关闭数据库连接
privatevoidbutton1_Click(objectsender,EventArgse)
登陆按钮操作
privatevoidForm1_FormClosing(objectsender,FormClosingEventArgse)
关闭窗口
publicvoidOpenConnection()
打开数据库
publicvoidCloseConnection()
关闭数据库
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Threading.Tasks;
usingSystem.Windows.Forms;
namespaceLibrary
{
publicpartialclassloginMenu:
Form
{
publicloginMenu()
InitializeComponent();
this.FormClosing+=newFormClosingEventHandler(this.Form1_FormClosing);
}
//取消按钮操作
privatevoidbutton2_Click(objectsender,EventArgse)
DialogResultresult=MessageBox.Show("
确定取消登陆吗?
"
"
操作提示"
MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if(result==DialogResult.Yes)
Application.Exit();
//非空验证
publicboolCheckInput()
if(this.txtUserName.Text.Trim().Equals(string.Empty))
MessageBox.Show("
请输入用户名"
输入提示"
MessageBoxButtons.OK,MessageBoxIcon.Information);
this.txtUserName.Focus();
returnfalse;
elseif(this.txtPwd.Text.Trim().Equals(string.Empty))
请输入密码"
this.txtPwd.Focus();
else
returntrue;
//检查用户是否存在
publicboolCheckUser(refstringmessage)
boolisValidUser=false;
stringuserName=txtUserName.Text.Trim();
stringuserPwd=txtPwd.Text.Trim();
StringBuildersb=newStringBuilder();
//查询用的SQL语句
sb.AppendFormat("
SELECTCOUNT(*)FROMAministratorWHEREAdmin='
{0}'
andPsw='
{1}'
userName,userPwd);
intcount=0;
DBHelperdbhelper=newDBHelper();
try
SqlCommandcommand=newSqlCommand(sb.ToString(),dbhelper.Connection);
dbhelper.OpenConnection();
count=(int)command.ExecuteScalar();
if(count>
0)
isValidUser=true;
用户名或密码错误,请重新输入"
message="
用户名不存在"
;
isValidUser=false;
catch(Exceptionex)
系统发生错误,请稍后再试!
finally
//关闭数据库连接
dbhelper.CloseConnection();
returnisValidUser;
//登陆按钮操作
privatevoidbutton1_Click(objectsender,EventArgse)
if(CheckInput())
stringmessage=string.Empty;
//显示选择菜单
if(CheckUser(refmessage))
searchBookfrmsearch=newsearchBook();
frmsearch.Show();
this.Hide();
//关闭窗口
privatevoidForm1_FormClosing(objectsender,FormClosingEventArgse)
//数据库打开关闭操作
publicclassDBHelper
privatestringconnString="
DataSource=.;
InitialCatalog=libraryDB;
IntegratedSecurity=True;
privateSqlConnectionconnection;
publicSqlConnectionConnection
get
if(connection==null)
connection=newSqlConnection(connString);
returnconnection;
//打开数据库
publicvoidOpenConnection()
if(Connection.State==ConnectionState.Closed)
Connection.Open();
elseif(Connection.State==ConnectionState.Broken)
Connection.Close();
//关闭数据库
publicvoidCloseConnection()
if(Connection.State==ConnectionState.Open||Connection.State==ConnectionState.Broken)
}
4.2.2查询界面
FillListView();
调用搜索按钮函数
privatevoidFillListView()
搜索按钮操作
返回按钮
privatevoid借阅ToolStripMenuItem_Click(objectsender,EventArgse)
右键菜单借阅操作
privatevoid归还ToolStripMenuItem_Click(objectsender,EventArgse)
右键菜单归还操作
publicpartialclasssearchBook:
publicsearchBook()
privatevoidbtnSearch_Click(objectsender,EventArgse)
//调用搜索按钮函数
FillListView();
//搜索按钮操作
privatevoidFillListView()
if(listView1.Items.Count>
listView1.Items.Clear();
StringBuildersql=newStringBuilder();
if(comboBox1.Text.Equals("
作者"
))
sql.AppendFormat("
select*fromBookwhereauthorlike'
%"
+textBox1.Text+"
%'
);
elseif(comboBox1.Text.Equals("
书名"
select*fromBookwherebookNamelike'
编号"
select*fromBookwherebookNolike'
SqlCommandcommand=newSqlCommand(sql.ToString(),dbhelper.Connection);
SqlDataReaderreader=command.ExecuteReader();
if(!
reader.HasRows)
没有要查找的记录!
提示"
while(reader.Read())
stringbookNo=reader["
bookNo"
].ToString();
stringbookName=reader["
bookName"
stringauthor=reader["
author"
].ToString().Trim();
stringbookstate=reader["
bookstate"
;
stringlendTime=reader["
lendTime"
stringreturnTime=reader["
returnTime"
stringreaders=reader["
readers"
stringbookcount=reader["
bookcount"
ListViewItemitem=newListViewItem(bookName);
item.SubItems.Add(bookNo);
item.SubItems.Add(author);
item.SubItems.Add(bookstate);
item.SubItems.Add(lendTime);
item.SubItems.Add(returnTime);
item.SubItems.Add(bookcount);
item.SubItems.Add(readers);
listView1.Items.Add(item);
reader.Close();
请选择查找方式"
MessageBoxButtons.OK,MessageBoxIcon.Error);
//返回按钮
loginMenufrmlog=newloginMenu();
frmlog.Show();
privatevoidcontextMenuStrip1_Opening(objectsender,CancelEventArgse)
//右键菜单借阅操作
privatevoid借阅ToolStripMenuItem_Click(objectsender,EventArgse)
if(this.listView1.Items.Count>
if(this.listView1.SelectedItems[0].SubItems[6].Text.Equals(0))
这本书已被借阅完毕,无法借取"
警告"
borrowbookfrmborrow=newborrowbook();
frmborrow.Show();
frmborrow.textBox1.Text=this.listView1.SelectedItems[0].SubItems[0].Text;
frmborrow.textBox2.Text=this.listView1.SelectedItems[0].SubItems[1].Text;
frmborrow.textBox3.Text=this.listView1.SelectedItems[0].SubItems[2].Text;
frmborrow.textBox4.Text=this.listView1.SelectedItems[0].SubItems[4].Text;
frmborrow.textBox5.Text=this.listView1.SelectedItems[0].SubItems[5].Text;
//右键菜单归还操作
privatevoid归还ToolStripMenuItem_Click(objectsender,EventArgse)
if(this.listView1.Items.Count==0)