图书管理系统系统设计含代码.docx
《图书管理系统系统设计含代码.docx》由会员分享,可在线阅读,更多相关《图书管理系统系统设计含代码.docx(54页珍藏版)》请在冰豆网上搜索。
图书管理系统系统设计含代码
《高级程序设计语言》
图书管理系统设计报告
学 院:
国土资源工程学院
专 业:
测绘工程
成 员:
********************************
指导教师:
黄云铠
日 期:
2014年11月5日
1系统设计
1.1设计目标
本系统是针对图书管理工作过程进展设计的,主要实现如下目标:
注册用户可以登录此系统;
非注册用户注册后可以使用本系统;
读者可以查询、借阅、归还图书等;
管理员可以对读者、图书进展管理。
概念结构设计
将从需求分析中得到的数据信息抽象为概念模型,经分析可得到数据库的E-R模型。
如下列图。
图1-1图书实体ER图
图1-2实体读者ER图
图1-3用户实体ER图
1.2项目规划
图书管理系统是一个典型的数据库应用程序,由应用程序和后台数据库两局部构成。
〔1〕应用程序
应用程序主要包括登录,注册,用户信息,读者信息,图书信息管理,借阅图书,综合查询,信息等几个局部组成。
〔2〕数据库数据库负责对图书信息,用户信息等数据的管理。
2数据库设计说明书
2.1数据库表结构
2.1.1图书表book
2.1.2借阅信息表borrow
2.1.4用户信息权限表right
2.1.6管理员账号表usererheper
2.3图书管理系统暂有数据〔模拟运行〕
学工号:
2014701020某某:
邢吉昌密码:
111
学工号:
2014701021某某:
猪八戒密码:
333
学工号:
2014701022某某:
孙悟空密码:
444
编号作者书名出版日期价格书类
H319584781MARKC#入门经典清华大学2011/4/521.56计算机
H319584782哪吒和猴子的那些事天庭文印2010/1/2216.5情感
H319584783二郎神我也可以闹天宫天庭文印2009/8/129.32技术
3程序功能的实现
已注册用户登录时,用户类别选择普通用户或管理员,不选择会出现提示
主要代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsFormsApplication1
{
publicpartialclassLoginForm:
Form
{
publicstringpassword;
privateintErrorTimes;
stringUser,Pwd;
boolflagshow=false;
privateboolyanzhengshuru()
{
password=textBox3.Text;
if(Typename.Text.Trim()=="")
{
MessageBox.Show("请选择登录类型","登录提示",
MessageBoxButtons.OK,MessageBoxIcon.Information);
Typename.Focus();
returnfalse;
}
elseif(loginid.Text.Trim()=="")
{
MessageBox.Show("请输入用户名","登录提示",
MessageBoxButtons.OK,MessageBoxIcon.Information);
loginid.Focus();
returnfalse;
}
elseif(password=="")
{
MessageBox.Show("请输入密码","登录提示",
MessageBoxButtons.OK,MessageBoxIcon.Information);
textBox3.Focus();
returnfalse;
}
else
{
returntrue;
}
}
publicLoginForm()
{
Initializeponent();
}
privatevoidcancelbtn_Click(objectsender,EventArgse)
{
Application.Exit();
}
privatevoidLoginForm_Load(objectsender,EventArgse)
{
}
privatevoidLoginForm_Closing(objectsender,FormClosingEventArgse)
{
Application.Exit();
}
privatevoidloginbtn_Click(objectsender,EventArgse)
{
if(yanzhengshuru())
{
if(Typename.Text.Trim()=="管理员")
{
SqlConnectionconConnection=newSqlConnection("DataSource=.\sqlexpress;InitialCatalog=学生管理数据库;IntegratedSecurity=True");
conConnection.Open();
stringcmd="selectAdminID,AdminPassfromuserhelper";
Sqlmand=newSqlmand(cmd,conConnection);
SqlDataReaderreader=.ExecuteReader();
while(reader.Read())
{
User=reader["AdminID"].ToString();
Pwd=reader["AdminPass"].ToString();
if(User.Trim()==loginid.Text&Pwd.Trim()==textBox3.Text)
{
flagshow=true;
}
}
reader.Close();
conConnection.Close();
if(flagshow==true)
{
this.Hide();
adminf1=newadmin();
f1.ShowDialog();
}
}
else
{
if(Typename.Text.Trim()=="普通用户")
{
SqlConnectionconConnection1=newSqlConnection("DataSource=.\sqlexpress;InitialCatalog=学生管理数据库;IntegratedSecurity=True");
conConnection1.Open();
stringd="selectReaderID,ReaderPasswordfromreader";
Sqlmandm=newSqlmand(d,conConnection1);
SqlDataReaderreader1=m.ExecuteReader();
while(reader1.Read())
{
User=reader1["ReaderID"].ToString();
Pwd=reader1["ReaderPassword"].ToString();
if(User.Trim()==loginid.Text&Pwd.Trim()==textBox3.Text)
{
flagshow=true;
}
}
reader1.Close();
conConnection1.Close();
if(flagshow==true)
{
this.Hide();
读者查阅f1=new读者查阅();
f1.ShowDialog();
}
else
{
MessageBox.Show("用户名不存在或密码错误!
","提示");
ErrorTimes++;
if(ErrorTimes>=3)
{
MessageBox.Show("登录次数过多,程序将关闭");
//Application.Exit();
return;
}
}
}
}
}
}
privatevoidlabel1_Click(objectsender,EventArgse)
{
}
privatevoidlabel2_Click(objectsender,EventArgse)
{
}
privatevoidlabel3_Click(objectsender,EventArgse)
{
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
this.Hide();
注册f1=new注册();
f1.ShowDialog();
}
privatevoiduserboBox_SelectedIndexChanged(objectsender,EventArgse)
{
}
privatevoiduseracctxt_TextChanged(objectsender,EventArgse)
{
}
privatevoidtextBox3_TextChanged(objectsender,EventArgse)
{
}
}
}
如果学号已经存在,如此会出现“*用户名已经存在,请重新输入〞的提示,当重新输入密码时,如果两次密码不一样,如此会出现“*请注意,两次密码不一样〞的提示
主要代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsFormsApplication1
{
publicpartialclass注册:
Form
{
public注册()
{
Initializeponent();
}
publicboolUserFlag;
privatevoidtextBox3_TextChanged(objectsender,EventArgse)
{
if(textBox2.Text.Trim()!
=textBox3.Text.Trim())
{
label6.Visible=true;
}
else
{
label8.Visible=true;
label6.Visible=false;
}
}
privatevoid注册_Load(objectsender,EventArgse)
{
}
privatevoidtextBox1_TextChanged(objectsender,EventArgse)
{
SqlConnectionconConnection=newSqlConnection("DataSource=.\sqlexpress;InitialCatalog=学生管理数据库;IntegratedSecurity=True");
conConnection.Open();
stringcmd="selectReaderIDfromreader";
Sqlmand=newSqlmand(cmd,conConnection);
SqlDataReaderreaderUser=.ExecuteReader();
while(readerUser.Read())
{
if(textBox1.Text==readerUser["ReaderID"].ToString().Trim())
{
label7.Visible=true;
UserFlag=true;
return;
}
elseif(textBox1.Text!
=readerUser["ReaderID"].ToString().Trim())
{
label7.Visible=false;
label9.Visible=true;
UserFlag=false;
}
}
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
intindex=textBox4.Text.IndexOf("");
if(index<1)
{
label10.Visible=true;
label10.Text="格式不正确,请重新输入";
}
else
{
label10.Visible=true;
label10.Text="格式正确";
}
if(UserFlag==true)
{
MessageBox.Show("用户已经存在,请重新输入!
");
return;
}
if(UserFlag==false)
{
SqlConnectionconConnection=newSqlConnection("DataSource=.\sqlexpress;InitialCatalog=学生管理数据库;IntegratedSecurity=True");
conConnection.Open();
stringcmd="insertintoreader(ReaderID,ReaderPassword,ReaderEmall)values('"+textBox1.Text+"',"+"'"+textBox2.Text+"',"+"'"+textBox4.Text+"')";
Sqlmand=newSqlmand(cmd,conConnection);
.ExecuteNonQuery();
conConnection.Close();
MessageBox.Show("注册成功!
点击确定,返回登录界面。
","提示");
this.Close();
LoginFormf2=newLoginForm();
}
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWindowsFormsApplication1
{
publicpartialclassadmin:
Form
{
publicadmin()
{
Initializeponent();
}
privatevoid查看用户信息ToolStripMenuItem_Click(objectsender,EventArgse)
{
权限设置f8=new权限设置();
f8.ShowDialog();
}
privatevoid查看用户信息ToolStripMenuItem1_Click(objectsender,EventArgse)
{
用户信息fi=new用户信息();
fi.ShowDialog();
}
privatevoid新增用户ToolStripMenuItem1_Click(objectsender,EventArgse)
{
新增用户f2=new新增用户();
f2.ShowDialog();
}
privatevoid删除用户ToolStripMenuItem1_Click(objectsender,EventArgse)
{
用户信息f3=new用户信息();
f3.button2.Visible=true;
f3.ShowDialog();
}
privatevoid录入书籍ToolStripMenuItem_Click(objectsender,EventArgse)
{
书籍信息f5=new书籍信息();
f5.ShowDialog();
}
privatevoid删除书籍ToolStripMenuItem_Click(objectsender,EventArgse)
{
删除书籍f6=new删除书籍();
f6.ShowDialog();
}
privatevoid还书处理ToolStripMenuItem_Click(objectsender,EventArgse)
{
还书处理f9=new还书处理();
f9.ShowDialog();
}
privatevoidadmin_Load(objectsender,EventArgse)
{
}
privatevoid借阅处理ToolStripMenuItem_Click(objectsender,EventArgse)
{
借阅处理f10=new借阅处理();
f10.ShowDialog();
}
}
}
管理用户下共有三个子菜单
新增用户界面
主要代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsFormsApplication1
{
publicpartialclass新增用户:
Form
{
public新增用户()
{
Initializeponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
SqlConnectionconConnection=newSqlConnection("DataSource=.\sqlexpress;InitialCatalog=学生管理数据库;IntegratedSecurity=True");
conConnection.Open();
stringcmd="insertintoreader(ReaderID,ReaderName,ReaderPassword,ReaderSex,ReaderAge,ReaderDept,ReaderZhuanYe,MaxNumber,ReaderEmall)values('"+textBox1.Text+"',"+"'"+textBox2.Text+"',"+"'"+textBox3.Text+"',"+"'"+textBox4.Text+"',"+"'"+textBox5.Text+"',"+"'"+textBox6.Text+"',"+"'"+textBox7.Text+"',"+"'"+textBox8.Text+"',"+"'"+textBox9.Text+"')";
Sqlmand=newSqlmand(cmd,conConnection);
.ExecuteNonQuery();
conConnection.Close();
MessageBox.Show("添加成功!
点击确定,返回登录界面。
","提示");
this.Close();
}
}
}
输入学号即可查询用户信息,如图,点击删除即删除该用户
主要代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsFormsApplication1
{
publicpartialclass用户信息:
Form
{
boolUserFlag;
public用户信息()
{
Initializeponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
if(UserFlag==false)
{
MessageBox.Show("不存在该用户,请核对后再输入","警告");
return;
}
if(UserFlag==true)
{
SqlConnectionconConnection=newSqlConnection("DataSource=.\sqlexpress;InitialCatalog=学生管理数据库;IntegratedSecurity=True");
conConnection.Open();
stringcmd="select*fromreader";
Sqlmand=newSqlmand(cmd,conConnection);
.mandText="select*fromreader";
SqlDataReaderdr=.ExecuteReader();
whil