图书馆管理系统设计附带源代码.docx
《图书馆管理系统设计附带源代码.docx》由会员分享,可在线阅读,更多相关《图书馆管理系统设计附带源代码.docx(71页珍藏版)》请在冰豆网上搜索。
图书馆管理系统设计附带源代码
毕业设计_图书管理系统
一、数据库设计数据库设
CREATEDATABASETSGL
GO
USETSGL
GO
CREATETABLEBmanage
(
bIdvarchar(10)PRIMARYKEY,
bNamevarchar(50),
--添加图书
--图书编号
--书名
bNumber
varchar(10),
--书数目
)
GO
bSorevarchar(50)
--分类
CREATETABLEMadmin
(
mNamevarchar(10)PRIMARYKEY,
mPwdvarchar(25),
mAgevarchar(8),
mSexvarchar(4),
mNumbervarchar(15),
mrolevarchar(8)
)
GO
--图书员管理
--图书管理员姓名
--图书管理员密码
--图书管理员年龄
--图书管理员性别
--图书管理员电话
--图书管理员角色
CREATETABLEReader
(
rSnovarchar(10)PRIMARYKEY,
rNamevarchar(10),
rPwdvarchar(25),
rAgevarchar(8),
rSexvarchar(4),
rStatevarchar(8),
rNumbervarchar(15),
rEmailvarchar(25),
--读者信息表reader
--读者号
--姓名
--密码
--年龄
--性别
--状态
--电话号码
--电子邮件
rAdress
varChar(50),
--地址
)
GO
rGradevarChar(15),
rClassvarchar(15),
rRolevarchar(8)
--年级
--班级
--角色
CREATETABLERrecord
(
rSnovarchar(10)PRIMARYKEY,
rNamevarChar(10),
bIdvarchar(10),
bNamevarChar(50),
bTimevarchar(10),
bBackTimevarchar(10)
)
GO
CREATETABLESysSet(
rRolevarchar(8)PRIMARYKEY,
rStatevarchar(8),
Finefloat(25),
rDayvarchar(8)
--读者编号学号
--读者姓名
--图书编号
--图书名称
--借书时间
--还书时间
--读者角色
--读者可借书数
--过期罚款设置
--可借书天数
)
二、界面截图及说明
1)登录窗口(实现管理员与馆长的登陆)
2)管理员窗口
3)馆长窗口
4)关于窗口
5)新增图书窗口
6)新增管理员、查找及修改窗口
7)新增读者、查找及修改窗口
8)图书的查找及修改窗口
9)借阅窗口
10)系统设置窗口
三、主要代码主要代
1)登录窗口(实现管理员与馆长的登陆)
登陆检查:
usingSystem;
usingSystem、Collections、Generic;
usingSystem、Linq;
usingSystem、Text;
usingSystem、Data;
usingprjTSGL、ClassLib、DBAccess;
namespaceprjTSGL、ClassLib、Logic
{
classclsLoginCheck
{
publicstaticDataTableCheckLogin(stringUserId,stringPWD)
{
{
stringSQLstmt="selectmName,mPwd,mRolefromMadminwheremName='"+UserId
+"'andmPwd='"+PWD+"'";
DataTabledt=clsGlobalVar、GetDataTable(SQLstmt);
returndt;
}
}
}
}
登陆:
usingSystem;
usingSystem、Collections、Generic;
usingSystem、ComponentModel;
usingSystem、Data;
usingSystem、Drawing;
usingSystem、Linq;
usingSystem、Text;
usingSystem、Windows、Forms;
usingprjTSGL、ClassLib、Logic;
namespaceprjTSGL、TSGL_UI
{
publicpartialclassfrmLogin:
Form
{
publicfrmLogin()
{
InitializeComponent();
}
privatevoidbtnLogin_Click(objectsender,EventArgse)
{
stringstrUserID=loginid、Text、Trim();
stringstrPWD=loginpwd、Text、Trim();
stringtype="";
try
{
DataTabledt=clsLoginCheck、CheckLogin(strUserID,strPWD);
if(dt、Rows、Count==0)
{
MessageBox、Show("登陆失败,请重新输入!
");
loginpwd、Focus();
return;
}
else
{
type=dt、Rows[0]["mRole"]、ToString()、Trim();
if(cboLT、Text、Trim()=="馆长")
{
if(type=="馆长")
{
this、Hide();
frmManagerobjManager=newfrmManager();
objManager、Show();
}
else
{
MessageBox、Show("您没有权限!
");
loginpwd、Focus();
return;
}
}
else
{
if(type=="管理员")
{
this、Hide();
frmAdminobjAdmin=newfrmAdmin();
objAdmin、Show();
}
else
{
MessageBox、Show("您没有权限!
");
loginpwd、Focus();
return;
}
}
}
}
catch(Exceptionex)
{
throwex;
}
}
privatevoidbtnExit_Click(objectsender,EventArgse)
{
this、Close();
}
}
}
2)管理员窗口
usingSystem;
usingSystem、Collections、Generic;
usingSystem、ComponentModel;
usingSystem、Data;
usingSystem、Drawing;
usingSystem、Linq;
usingSystem、Text;
usingSystem、Windows、Forms;
namespaceprjTSGL、TSGL_UI
{
publicpartialclassfrmAdmin:
Form
{
publicfrmAdmin()
{
InitializeComponent();
}
privatevoidShowForm(FormfrmToShow)
{
this、Cursor=Cursors、WaitCursor;
foreach(FormfrmChildinthis、MdiChildren)
{
if(frmChild、GetType()==frmToShow、GetType())
{
frmToShow、Dispose();
frmChild、Activate();
this、Cursor=Cursors、Default;
return;
}
}
frmToShow、MdiParent=this;
frmToShow、Show();
this、Cursor=Cursors、Default;
}
privatevoid读者信息修改ToolStripMenuItem_Click(objectsender,EventArgse)
{
ShowForm(newfrmUpdateReader());
}
privatevoid新增图书ToolStripMenuItem_Click(objectsender,EventArgse)
{
ShowForm(newfrmAddNewBook());
}
privatevoid图书的查找与修改ToolStripMenuItem_Click(objectsender,EventArgse)
{
ShowForm(newfrmUpdateBook());
}
privatevoid流通管理ToolStripMenuItem_Click(objectsender,EventArgse)
{
ShowForm(newfrmBorrow());
}
privatevoid帮助ToolStripMenuItem_Click(objectsender,EventArgse)
{
ShowForm(newfrmAbout());
}
privatevoid退出ToolStripMenuItem_Click(objectsender,EventArgse)
{
Application、Exit();
}
}
}
3)馆长窗口
usingSystem;
usingSystem、Collections、Generic;
usingSystem、ComponentModel;
usingSystem、Data;
usingSystem、Drawing;
usingSystem、Linq;
usingSystem、Text;
usingSystem、Windows、Forms;
namespaceprjTSGL、TSGL_UI
{
publicpartialclassfrmManager:
Form
{
publicfrmManager()
{
InitializeComponent();
}
privatevoidShowForm(FormfrmToShow)
{
this、Cursor=Cursors、WaitCursor;
foreach(FormfrmChildinthis、MdiChildren)
{
if(frmChild、GetType()==frmToShow、GetType())
{
frmToShow、Dispose();
frmChild、Activate();
this、Cursor=Cursors、Default;
return;
}
}
frmToShow、MdiParent=this;
frmToShow、Show();
this、Cursor=Cursors、Default;
}
privatevoidfrmManager_FormClosed(objectsender,FormClosedEventArgse)
{
Application、Exit();
}
privatevoid管理员信息管理ToolStripMenuItem_Click_1(objectsender,EventArgse)
{
ShowForm(newfrmSelectAdmin());
}
privatevoid系统设置ToolStripMenuItem_Click_1(objectsender,EventArgse)
{
ShowForm(newfrmSys());
}
privatevoid关于ToolStripMenuItem_Click(objectsender,EventArgse)
{
ShowForm(newfrmAbout());
}
privatevoid退出ToolStripMenuItem_Click_1(objectsender,EventArgse)
{
Application、Exit();
}
}
}
4)关于窗口
usingSystem;
usingSystem、Collections、Generic;
usingSystem、ComponentModel;
usingSystem、Data;
usingSystem、Drawing;
usingSystem、Linq;
usingSystem、Text;
usingSystem、Windows、Forms;
namespaceprjTSGL、TSGL_UI
{
publicpartialclassfrmAbout:
Form
{
publicfrmAbout()
{
InitializeComponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
this、Close();
}
}
}
5)新增图书窗口
usingSystem;
usingSystem、Collections、Generic;
usingSystem、ComponentModel;
usingSystem、Data;
usingSystem、Drawing;
usingSystem、Linq;
usingSystem、Text;
usingSystem、Windows、Forms;
usingprjTSGL、ClassLib、DBAccess;
namespaceprjTSGL、TSGL_UI
{
publicpartialclassfrmAddNewBook:
Form
{
publicfrmAddNewBook()
{
InitializeComponent();
}
privateboolValidatInput()
{
if(textBox1、Text=="")
{
MessageBox、Show("请输入图书编号!
","输入提示",MessageBoxButtons、OK,
MessageBoxIcon、Information);
textBox1、Focus();
returnfalse;
}
if(textBox2、Text=="")
{
MessageBox、Show("请输入图书名称!
","输入提示",MessageBoxButtons、OK,
MessageBoxIcon、Information);
textBox2、Focus();
returnfalse;
}
if(textBox3、Text=="")
{
MessageBox、Show("请输入图书数目!
","输入提示",MessageBoxButtons、OK,
MessageBoxIcon、Information);
textBox3、Focus();
returnfalse;
}
if(comboBox1、Text=="")
{
MessageBox、Show("请选择图书类别!
","输入提示",MessageBoxButtons、OK,
MessageBoxIcon、Information);
textBox3、Focus();
returnfalse;
}
returntrue;
}
privatevoidbtnOK_Click_1(objectsender,EventArgse)
{
if(ValidatInput())
{
//stringid=textBox1、Text;
//stringname=textBox2、Text;
//stringNumber=textBox3、Text;
//stringsore=comboBox1、Text;
stringsql="SELECT*FROMBmanageWHEREbId='"+textBox1、Text、Trim()+"'";
DataTabledt=clsGlobalVar、GetDataTable(sql);
if(dt、Rows、Count==0)
{
stringSQL="insertintoBmanage(bId,bName,bNumber,bSore)values('"+
textBox1、Text、Trim()+"','"+textBox2、Text、Trim()+"','"+textBox3、Text、Trim()+"','"
+comboBox1、Text、Trim()+"')";
try
{
boolresult=clsGlobalVar、ExecSQL(SQL);
if(result)
{
MessageBox、Show("添加成功!
","操作提示",MessageBoxButtons、OK,
MessageBoxIcon、Information);
textBox1、Text="";
textBox2、Text="";
textBox3、Text="";
comboBox1、Text="";
textBox1、Focus();
}
else
{
MessageBox、Show("添加失败!
","操作提示",MessageBoxButtons、OK,
MessageBoxIcon、Error);
}
}
catch(Exceptionex)
{
MessageBox、Show("操作数据库出错!
","操作演示",MessageBoxButtons、OK,
MessageBoxIcon、Error);
Console、WriteLine(ex、Message);
}
}
else
{
MessageBox、Show("图书编号已存在!
","操作提示",MessageBoxButtons、OK,
MessageBoxIcon、Information);
textBox1、Focus();
}
}
}
privatevoidbtnCancel_Click(objectsender,EventArgse)
{
this、Close();
}
}
}
6)新增管理员、查找及修改窗口
usingSystem;
usingSystem、Collections、Generic;
usingSystem、ComponentModel;
usingSystem、Data;
usingSystem、Drawing;
usingSystem、Linq;
usingSystem、Text;
usingSystem、Windows、Forms;
usingprjTSGL、ClassLib、DBAccess;
namespaceprjTSGL、TSGL_UI
{
publicpartialclassfrmSelectAdmin:
Form
{
publicfrmSelectAdmin()
{
InitializeComponent();
}
stringname="";
stringSQL="";
stringPWD="";
stringAge="";
stringSex="";
stringTel="";
stringRole="";
privatevoidSelectAdmin()
{
stringstrfilter="";
stringSQL="selectmNameAS用户名,mPwdAS密码,mAgeAS年龄,mSexAS性别,mNumber
AS电话,mRoleAS角色fromMadmin";
if(txtName、Text=="")
strfilter="";
else
strfilter="wheremName='"+txtName、Text、Trim()+"'";
try
{
DataTabledt=clsGlobalVar、GetDataTable(SQL+strfilter);
intintIndex=0;
if(dt、Rows、Count==0)
{
MessageBox、Show("抱歉,没有您要找的用户!
","结果提示",
MessageBoxButtons、OK,MessageBoxIcon、Information);
txtName、Text="";
txtPWD、Text="";
txtAge、Text="";
cboSex、Text="";
txt