版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、高级程序设计语言图书管理系统设计报告学院: 国土资源工程学院 专业: 测 绘 工 程 成员:*指导教师:黄云铠日期: 2014年11月5日1 系统设计1.1 设计目标本系统是针对图书管理工作过程进行设计的,主要实现如下目标:注册用户可以登录此系统;非注册用户注册后可以使用本系统;读者可以查询、借阅、归还图书等; 管理员可以对读者、图书进行管理。1.2数据库设计概述1.2.1概念结构设计将从需求分析中得到的数据信息抽象为概念模型,经分析可得到数据库的E-R模型。如图所示。 图书名称作者编号出版日期价格种类图1-1 图书实体ER图密码 读者XX编号专业借阅时间借书量年龄性别图1-2 实体读者ER图
2、用户密码类型编号图1- 3 用户实体ER图1.2 项目规划图书管理系统是一个典型的数据库应用程序,由应用程序和后台数据库两部分构成。(1)应用程序应用程序主要包括登录,注册,用户信息,读者信息,图书信息管理,借阅图书,综合查询,信息等几个部分组成。(2)数据库 数据库负责对图书信息,用户信息等数据的管理。2 数据库设计说明书21 数据库表结构2.1.1 图书表book2.1.2 借阅信息表borrow2.1.2用户信息表Reader2.1.4 用户信息权限表right2.1.5用户账号表user2.1.6 管理员账号表usererheper2.2数据关系图2.3图书管理系统暂有数据(模拟运行)
3、2.3.1管理员学工号:2014701020 :邢吉昌密码:1112.3.2普通用户学工号:2014701021 :猪八戒密码:333学工号:2014701022 :悟空密码:4442.3.3图书信息编号 作者 书名 出版日期 价格 书类H319584781 MARK C#入门经典 清华大学 2011/4/5 21.56 计算机H319584782 哪吒 和猴子的那些事 天庭文印 2010/1/2 216.5 情感H319584783二郎神 我也可以闹天宫 天庭文印 2009/8/1 29.32 技术3 程序功能的实现3.1登陆界面已注册用户登录时,用户类别选择普通用户或管理员,不选择会出现提
4、示主要代码如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1publicpartialclassLoginForm : Form publicstring password;
5、privateint ErrorTimes;string User, Pwd;bool flagshow = false;privatebool yanzhengshuru() password = textBox3.Text;if(Typename.Text.Trim()="") MessageBox.Show("请选择登录类型","登录提示",MessageBoxButtons.OK,MessageBoxIcon.Information); Typename.Focus();returnfalse; elseif(loginid.
6、Text.Trim()="") MessageBox.Show("请输入用户名", "登录提示",MessageBoxButtons.OK, MessageBoxIcon.Information); loginid.Focus();returnfalse; elseif (password = "") MessageBox.Show("请输入密码", "登录提示",MessageBoxButtons.OK, MessageBoxIcon.Information); textB
7、ox3.Focus();returnfalse; else returntrue; public LoginForm() InitializeComponent(); privatevoid cancelbtn_Click(object sender, EventArgs e) Application.Exit(); privatevoid LoginForm_Load(object sender, EventArgs e) privatevoid LoginForm_Closing(object sender, FormClosingEventArgs e) Application.Exit
8、(); privatevoid loginbtn_Click(object sender, EventArgs e) if (yanzhengshuru() if (Typename.Text.Trim() = "管理员") SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True"); conConnection.Open();string cmd = "sel
9、ect AdminID,AdminPass from userhelper "SqlCommand = newSqlCommand(cmd, conConnection);SqlDataReader reader = .ExecuteReader();while (reader.Read() User = reader"AdminID".ToString(); Pwd = reader"AdminPass".ToString();if (User.Trim() = loginid.Text & Pwd.Trim() = textBox3
10、.Text) flagshow = true; reader.Close(); conConnection.Close();if (flagshow = true) this.Hide();admin f1 = newadmin (); f1.ShowDialog(); else if (Typename.Text.Trim() = "普通用户") SqlConnection conConnection1 = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated S
11、ecurity=True"); conConnection1.Open();stringd = "select ReaderID,ReaderPassword from reader "SqlCommandm = newSqlCommand(cnd, conConnection1);SqlDataReader reader1 =m.ExecuteReader();while (reader1.Read() User = reader1"ReaderID".ToString(); Pwd = reader1"ReaderPassword
12、".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 (ErrorTime
13、s >= 3) MessageBox.Show("登录次数过多,程序将关闭");/Application.Exit();return; privatevoid label1_Click(object sender, EventArgs e) privatevoid label2_Click(object sender, EventArgs e) privatevoid label3_Click(object sender, EventArgs e) privatevoid button1_Click(object sender, EventArgs e) this.H
14、ide();注册 f1 = new注册(); f1.ShowDialog(); privatevoid usercomboBox_SelectedIndexChanged(object sender, EventArgs e) privatevoid useracctxt_TextChanged(object sender, EventArgs e) privatevoid textBox3_TextChanged(object sender, EventArgs e) 3.2登陆界面如果学号已经存在,则会出现“*用户名已经存在,请重新输入”的提示,当重新输入密码时,如果两次密码不一样,则会出
15、现“*请注意,两次密码不一样”的提示主要代码如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1publicpartialclass注册 : Form public 注册()
16、InitializeComponent(); publicbool UserFlag;privatevoid textBox3_TextChanged(object sender, EventArgs e) if (textBox2.Text.Trim() != textBox3.Text.Trim() label6.Visible = true; else label8.Visible = true; label6.Visible = false; privatevoid 注册_Load(object sender, EventArgs e) privatevoid textBox1_Tex
17、tChanged(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True"); conConnection.Open();string cmd = "select ReaderID from reader "SqlCommand = newSqlCommand(cmd ,conConnection );SqlData
18、Reader readerUser = .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; Us
19、erFlag = false; privatevoid button1_Click(object sender, EventArgs e) int index = textBox4.Text.IndexOf("");if (index < 1) label10.Visible = true; label10.Text = "格式不正确,请重新输入" else label10.Visible = true; label10.Text = "格式正确" if(UserFlag=true ) MessageBox.Show("
20、;用户已经存在,请重新输入!");return; if (UserFlag=false) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True"); conConnection.Open();string cmd = "insert into reader(ReaderID,ReaderPassword,ReaderEmall) values ('"+
21、textBox1.Text+"',"+"'"+textBox2.Text+"',"+"'"+textBox4.Text+"')"SqlCommand = newSqlCommand(cmd,conConnection ); .ExecuteNonQuery(); conConnection.Close();MessageBox.Show("注册成功!点击确定,返回登录界面。","提示");this.Close();L
22、oginForm f2 = newLoginForm(); 3.3管理员操作界面using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1publicpartialclassadmin : Form public admin() Initial
23、izeComponent(); privatevoid 查看用户信息ToolStripMenuItem_Click(object sender, EventArgs e) 权限设置 f8 = new权限设置(); f8.ShowDialog(); privatevoid 查看用户信息ToolStripMenuItem1_Click(object sender, EventArgs e) 用户信息 fi = new用户信息(); fi.ShowDialog(); privatevoid 新增用户ToolStripMenuItem1_Click(object sender, EventArgs e
24、) 新增用户 f2 = new新增用户(); f2.ShowDialog(); privatevoid 删除用户ToolStripMenuItem1_Click(object sender, EventArgs e) 用户信息 f3 = new用户信息(); f3.button2.Visible = true; f3.ShowDialog(); privatevoid 录入书籍ToolStripMenuItem_Click(object sender, EventArgs e) 书籍信息 f5 = new书籍信息(); f5.ShowDialog(); privatevoid 删除书籍Tool
25、StripMenuItem_Click(object sender, EventArgs e) 删除书籍 f6 = new删除书籍(); f6.ShowDialog(); privatevoid 还书处理ToolStripMenuItem_Click(object sender, EventArgs e) 还书处理 f9 = new还书处理(); f9.ShowDialog(); privatevoid admin_Load(object sender, EventArgs e) privatevoid 借阅处理ToolStripMenuItem_Click(object sender, Ev
26、entArgs e) 借阅处理 f10 = new借阅处理(); f10.ShowDialog(); 3.3.1管理用户管理用户下共有三个子菜单新增用户界面主要代码如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespa
27、ce WindowsFormsApplication1publicpartialclass新增用户 : Form public 新增用户() InitializeComponent(); privatevoid button1_Click(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True"); conConnection.Open
28、();string cmd = "insert into reader(ReaderID,ReaderName,ReaderPassword,ReaderSex,ReaderAge,ReaderDept,ReaderZhuanYe,MaxNumber,ReaderEmall) values ('" + textBox1.Text + "'," + "'" + textBox2.Text + "'," + "'" + textBox3.Text + &quo
29、t;'," + "'" + textBox4.Text + "'," + "'" + textBox5.Text + "'," + "'" + textBox6.Text + "'," + "'" + textBox7.Text + "'," + "'" + textBox8.Text + "',"
30、+ "'" + textBox9.Text + "')"SqlCommand = newSqlCommand(cmd, conConnection); .ExecuteNonQuery(); conConnection.Close();MessageBox.Show("添加成功!点击确定,返回登录界面。", "提示");this.Close(); 删除用户界面输入学号即可查询用户信息,如图,点击删除即删除该用户主要代码如下:using System;using System.Colle
31、ctions.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1publicpartialclass用户信息 : Form bool UserFlag;public 用户信息() InitializeComponent(); privatevoid but
32、ton1_Click(object sender, EventArgs e) if(UserFlag=false ) MessageBox.Show("不存在该用户,请核对后再输入","警告");return; if (UserFlag = true) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True"); conConnection.Open(
33、);string cmd = "select * from reader"SqlCommand =newSqlCommand (cmd,conConnection); mandText = "select * from reader"SqlDataReader dr = .ExecuteReader();while (dr.Read() label11.Visible = true; textBox2.Text = dr"ReaderName".ToString().Trim(); textBox3.Text = dr"Re
34、aderPassword".ToString().Trim(); textBox4.Text = dr"ReaderSex".ToString().Trim(); textBox5.Text = dr"ReaderAge".ToString().Trim(); textBox6.Text = dr"ReaderDept".ToString().Trim(); textBox7.Text = dr"ReaderZhuanYe".ToString().Trim(); textBox8.Text = dr&qu
35、ot;MaxNumber".ToString().Trim(); textBox9.Text = dr"ReaderEmall".ToString().Trim(); conConnection.Close(); privatevoid textBox1_TextChanged(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated Secur
36、ity=True"); conConnection.Open();string cmd = "select ReaderID from reader "SqlCommand = newSqlCommand(cmd, conConnection);SqlDataReader readerUser = .ExecuteReader();while (readerUser.Read() if (textBox1.Text = readerUser"ReaderID".ToString().Trim() UserFlag = true;return;
37、elseif (textBox1.Text != readerUser"ReaderID".ToString().Trim() UserFlag = false; privatevoid button2_Click(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True"); conConnection.Open()
38、;string cmd = "delete from reader where ReaderID='" + textBox1.Text.Replace("'", "''") + "'"SqlCommand = newSqlCommand(cmd, conConnection); .ExecuteNonQuery(); conConnection.Close();MessageBox.Show("是否确认删除", "提示"); 3.3.1
39、.3 查看用户信息界面该界面与删除用户界面代码基本相似,主要是将查询按钮隐藏,故代码不再列出3.3.2图书管理图书查询下共有2个子菜单录入书籍页面主要代码如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace Wi
40、ndowsFormsApplication1publicpartialclass书籍信息 : Form public 书籍信息() InitializeComponent(); privatevoid button1_Click(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True"); conConnection.Open();st
41、ring cmd = "insert into book (BookID,BookWrite,BookName,BookPublish,BookPublishDate,BookPrice,BookSort) values ('" + textBox1.Text + "'," + "'" + textBox2.Text + "'," + "'" + textBox3.Text + "'," + "'"
42、+ textBox4.Text + "'," + "'" + textBox5.Text + "'," + "'" + textBox6.Text + "'," + "'" + textBox7.Text + "')"SqlCommand = newSqlCommand(cmd, conConnection); .ExecuteNonQuery(); conConnection.Close();Mes
43、sageBox.Show("录入成功", "提示"); textBox1.Text = "" textBox2.Text = "" textBox3.Text = "" textBox4.Text = "" textBox5.Text = "" textBox6.Text = "" textBox7.Text = "" 删除书籍删除书籍之前如需确认是否是所需删除的书籍,以防删除错误,可以先将所需删除的书
44、籍的书名输入,点击检索后会出现该书的详细信息,若确认无误后点击删除即可删除该书主要代码如下:using System;using System.Collections.Generic;using System ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1publicpartialclass删
45、除书籍 : Form bool UserFlag;public 删除书籍() InitializeComponent(); privatevoid button1_Click(object sender, EventArgs e) if (UserFlag = false) MessageBox.Show("不存在此书,请核对后再输入", "警告");return; if (UserFlag = true) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpre
46、ss;Initial Catalog=学生管理数据库;Integrated Security=True"); conConnection.Open();string cmd = "select * from book"SqlCommand = newSqlCommand(cmd, conConnection); mandText = "select * from book"SqlDataReader dr = .ExecuteReader();while (dr.Read() textBox1.Text = dr"BookID&quo
47、t;.ToString().Trim(); textBox2.Text = dr"BookWrite".ToString().Trim(); textBox4.Text = dr"BookPublish".ToString().Trim(); textBox5.Text = dr"BookPublishDate".ToString().Trim(); textBox6.Text = dr"BookPrice".ToString().Trim(); textBox7.Text = dr"BookSort&q
48、uot;.ToString().Trim(); conConnection.Close(); privatevoid textBox3_TextChanged(object sender, EventArgs e) SqlConnection conConnection = newSqlConnection("Data Source=.sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True"); conConnection.Open();string cmd = "select BookName from book "SqlCommand = newSqlCommand(cmd, conConnection);SqlDataReader readerUser = .ExecuteReader();while (readerUser.Read() if (textBox1.Text = readerUser"BookName".ToString().Trim() UserFlag = true;return; elseif (textBox1.Text != readerUser"BookName".ToString
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026镍基合金在汽车工业应用现状及未来需求预测报告
- 2026铸造材料产业链分析及技术突破与投资价值报告
- 2026钛合金行业技术发展动态与应用前景及投资风险评估报告
- 2026年天门职业学院单招职业适应性测试题库含答案详解(突破训练)
- 2026年太原城市职业技术学院单招职业技能测试题库附答案详解(轻巧夺冠)
- 2026年宁夏银川市单招职业适应性考试题库及答案详解(典优)
- 2026年天府新区航空旅游职业学院单招职业适应性测试题库含答案详解(完整版)
- 2026年天津电子信息职业技术学院单招职业适应性考试题库附参考答案详解(突破训练)
- 2025江西省财通供应链金融集团有限公司劳务派遣制人员招聘8人笔试历年备考题库附带答案详解
- 2025江苏云港发展集团有限公司招聘工作人员3人笔试历年典型考点题库附带答案详解
- 物业小区控烟监督制度
- 2026年郑州市检验检测有限公司公开招聘19人笔试备考题库及答案解析
- 多模式镇痛临床实践与应用
- 2026吉林农业大学三江实验室办公室招聘工作人员笔试备考试题及答案解析
- 脑中风科普知识讲座
- 历史试题-汕头市2025-2026学年度普通高中毕业班教学质量监测(含解析)
- 部队食堂制度规范标准
- 二十届中纪委五次全会知识测试题及答案解析
- 2026年沈阳艺考乐理真题及答案
- 房内装修拆除合同范本
- DB23∕T 3242-2022 秸秆固化成型燃料站设计技术规范
评论
0/150
提交评论