图书馆管理系统设计.pdf
图书馆管理系统设计(总 24页)本页仅作为文档封面,使用时可以删除 This document is for reference only-rar21year.March 毕业设计_图书管理系统 一、数据库设计数据库设 CREATE DATABASE TSGL GO USE TSGL GO CREATE TABLE Bmanage(bId varchar(10)PRIMARY KEY,bName varchar(50),-添加图书 -图书编号-书名 bNumber varchar(10),-书数目 )GO bSore varchar(50)-分类 CREATE TABLE Madmin(mName varchar(10)PRIMARY KEY,mPwd varchar(25),mAge varchar(8),mSex varchar(4),mNumber varchar(15),mrole varchar(8)GO -图书员管理 -图书管理员姓名-图书管理员密码-图书管理员年龄-图书管理员性别-图书管理员电话-图书管理员角色 CREATE TABLE Reader(rSno varchar(10)PRIMARY KEY,rName varchar(10),rPwd varchar(25),rAge varchar(8),rSex varchar(4),rState varchar(8),rNumber varchar(15),rEmail varchar(25),-读者信息表reader -读者号-姓名-密码-年龄-性别-状态-电话号码-电子邮件 rAdress varChar(50),-地址 )GO rGrade varChar(15),rClass varchar(15),rRole varchar(8)-年级-班级-角色 CREATE TABLE Rrecord(rSno varchar(10)PRIMARY KEY,rName varChar(10),bId varchar(10),bName varChar(50),bTime varchar(10),bBackTime varchar(10)GO CREATE TABLE SysSet(rRole varchar(8)PRIMARY KEY,rState varchar(8),Fine float(25),rDay varchar(8)-读者编号学号-读者姓名-图书编号-图书名称-借书时间-还书时间 -读者角色-读者可借书数-过期罚款设置-可借书天数)二、界面截图及说明 1)登录窗口(实现管理员和馆长的登陆)2)管理员窗口 3)馆长窗口 4)关于窗口 5)新增图书窗口 6)新增管理员、查找及修改窗口 7)新增读者、查找及修改窗口 8)图书的查找及修改窗口 9)借阅窗口 10)系统设置窗口 三、主要代码主要代 1)登录窗口(实现管理员和馆长的登陆)登陆检查:using System;using using;using;using;using namespace class clsLoginCheck public static DataTable CheckLogin(string UserId,string PWD)string SQLstmt=select mName,mPwd,mRole from Madmin where mName=+UserId +and mPwd=+PWD+;DataTable dt=(SQLstmt);return dt;登陆:using System;using using;using;using;using;using;using using namespace public partial class frmLogin:Form public frmLogin()InitializeComponent();private void btnLogin_Click(object sender,EventArgs e)string strUserID=string strPWD=string type=;try DataTable dt=(strUserID,strPWD);if =0)(登陆失败,请重新输入!);();return;else type=0mRole.ToString().Trim();if 馆长)if(type=馆长)();frmManager objManager=new frmManager();();else (您没有权限!);();return;else if(type=管理员)();frmAdmin objAdmin=new frmAdmin();();else (您没有权限!);();return;catch(Exception ex)throw ex;private void btnExit_Click(object sender,EventArgs e)();2)管理员窗口 using System;using using;using;using;using;using;using namespace public partial class frmAdmin:Form public frmAdmin()InitializeComponent();private void ShowForm(Form frmToShow)=;foreach(Form frmChild in if()=()();();=;return;=this;();=;private void 读者信息修改ToolStripMenuItem_Click(object sender,EventArgs e)ShowForm(new frmUpdateReader();private void 新增图书ToolStripMenuItem_Click(object sender,EventArgs e)ShowForm(new frmAddNewBook();private void 图书的查找和修改ToolStripMenuItem_Click(object sender,EventArgs e)ShowForm(new frmUpdateBook();private void 流通管理ToolStripMenuItem_Click(object sender,EventArgs e)ShowForm(new frmBorrow();private void 帮助ToolStripMenuItem_Click(object sender,EventArgs e)ShowForm(new frmAbout();private void 退出ToolStripMenuItem_Click(object sender,EventArgs e)();3)馆长窗口 using System;using using;using;using;using;using;using namespace public partial class frmManager:Form public frmManager()InitializeComponent();private void ShowForm(Form frmToShow)=;foreach(Form frmChild in if()=()();();=;return;=this;();=;private void frmManager_FormClosed(object sender,FormClosedEventArgs e)();private void 管理员信息管理ToolStripMenuItem_Click_1(object sender,EventArgs e)ShowForm(new frmSelectAdmin();private void 系统设置ToolStripMenuItem_Click_1(object sender,EventArgs e)ShowForm(new frmSys();private void 关于ToolStripMenuItem_Click(object sender,EventArgs e)ShowForm(new frmAbout();private void 退出ToolStripMenuItem_Click_1(object sender,EventArgs e)();4)关于窗口 using System;using using;using;using;using;using;using namespace public partial class frmAbout:Form public frmAbout()InitializeComponent();private void button1_Click(object sender,EventArgs e)();5)新增图书窗口 using System;using using;using;using;using;using;using using namespace public partial class frmAddNewBook:Form public frmAddNewBook()InitializeComponent();private bool ValidatInput()if =)(请输入图书编号!,输入提示,;();return false;if =)(请输入图书名称!,输入提示,;();return false;if =)(请输入图书数目!,输入提示,;();return false;if =)(请选择图书类别!,输入提示,;();return false;return true;private void btnOK_Click_1(object sender,EventArgs e)if(ValidatInput()intI用户名.ToString().Trim();intI.intI密码.ToString().Trim();intI.intI年龄.ToString().Trim();intI.intI性别.ToString().Trim();intI.intI电话.ToString().Trim();intI.intI角色.ToString().Trim();intIj.ToString();intI读者编号.ToString();intI读者姓名.ToString();intI密码.ToString();intI年龄.ToString();intI性别.ToString();intI借书状态.ToString();intI地址.ToString();intI电话.ToString();intI邮箱.ToString();intI年级.ToString();intI班级.ToString();intI角色.ToString();catch(Exception ex)(查询数据库出错!,提示,;oString().Trim();state1=0State1.ToString().Trim();state2=0State2.ToString().Trim();Day=0Day.ToString().Trim();state=state2-state1;=().Trim();catch(Exception ex)(操作数据库出错!,操作演示,;private void btnBookSelect_Click(object sender,EventArgs e)if =)(图书编号不能为空,请重新输入);else string SQL=SELECT bName,bNumber FROM Bmanage WHERE bId=+;try DataTable dt=(SQL);if =0)(无此图书!,操作提示,;else =0bName.ToString().Trim();=0bNumber.ToString().Trim();state3=0bNumber.ToString().Trim();catch(Exception ex)(操作数据库出错!,操作演示,;private void btnBorrow_Click(object sender,EventArgs e)if(state 0&state3 0)state3-;string a=().Trim();string SQL=UPDATE Bmanage SET bNumber=+a+WHERE bId=+;(SQL);rim();string sql=UPDATE Reader SET rState=+b+WHERE rSno=+;(sql);oString().Trim();DateTime beBackTime=(Day);string strsql=INSERT INTO Rrecord(rSno,rName,bId,bName,bTime,beBackTime)VALUES(+,+,+,+,+time+,+().ToString().Trim()+);if(strsql)(借书成功!);=time;(sender,e);(sender,e);else (借书失败!);private void btnBackBook_Click(object sender,EventArgs e)if =)(读者编号和图书编号不能为空!);else (sender,e);(sender,e);state3+;string a=().Trim();string SQL=+a+WHERE bId=+;(SQL);rim();string sql=UPDATE Reader SET rState=+b+WHERE rSno=+;(sql);oString().Trim();y=0rDay.ToString().Trim();=0bTime.ToString().Trim();DateTime time=;string T=().ToString().Trim();=T;TimeSpan span=);int i=;string strsql=DELETE FROM Rrecord WHERE rSno=+AND bId=+;if(strsql)if(i y)z=x*(i-y);=().Trim();(还书成功,请交罚款+元!);oString().Trim();=0 rState.ToString().Trim();=0Fine.ToString().Trim();=0rDay.ToString().Trim();private void btnUpdate_Click(object sender,EventArgs e)if =)(请选择角色!);else =string SQL=UPDATE SysSet SET rState=+,Fine=+,rDay=+WHERE rRole=+;if(SQL)=;=;=;(修改已成功);else (修改失败!,操作提示,;11)连接数据库 using System;using using;using;using using;using;namespace public class clsGlobalVar public static string StrConn=Data Source=CA1070649;Persist Security Info=True;Initial Catalog=TSGL;User ID=TEST;PASSWORD=TEST;public static SqlConnection conn=null;public static DataTable GetDataTable(string strSQL)try conn=new SqlConnection(StrConn);if =();SqlDataAdapter Adap=new SqlDataAdapter(strSQL,conn);DataTable ds=new DataTable();(ds);();return ds;catch(Exception ex)throw ex;public static string GetFieldValue(string strSQL)string fieldValue=;conn=new SqlConnection(StrConn);if =();using(SqlCommand sqlCommand=new SqlCommand(strSQL,conn)try object objFieldValue=();if(objFieldValue!=null)fieldValue=();catch(Exception e)throw new Exception,e);return fieldValue;public static bool ExecSQL(string strSQL)conn=new SqlConnection(StrConn);if =();bool result;using(SqlCommand sqlcommand=new SqlCommand(strSQL,conn)try ();result=true;catch(Exception e)throw e;return result;