您好,欢迎来到爱够旅游网。
搜索
您的当前位置:首页图书管理系统系统设计(含代码)

图书管理系统系统设计(含代码)

来源:爱够旅游网


《高级程序设计语言》

图书管理系统设计报告

学 院: 国土资源工程学院 专 业: 测 绘 工 程

成 员:******************************** 指导教师: 黄云铠 日 期: 2014年11月5日

精选

1 系统设计 1.1 设计目标

本系统是针对图书管理工作过程进行设计的,主要实现如下目标: 注册用户可以登录此系统; 非注册用户注册后可以使用本系统; 读者可以查询、借阅、归还图书等; 管理员可以对读者、图书进行管理。 1.2数据库设计概述 1.2.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.2用户信息表Reader

2.1.4 用户信息权限表right

2.1.5用户账号表user

2.1.6 管理员账号表usererheper

精选

2.2数据关系图

2.3图书管理系统暂有数据(模拟运行) 2.3.1管理员

学工号:2014701020 姓名:邢吉昌密码:111 2.3.2普通用户

学工号:2014701021 姓名:猪八戒密码:333 学工号:2014701022 姓名:孙悟空密码:444 2.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登陆界面

精选

已注册用户登录时,用户类别选择普通用户或管理员,不选择会出现提示

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1 {

public partial class LoginForm : Form {

public string password; private int ErrorTimes; string User, Pwd; bool flagshow = false; private bool yanzhengshuru()

精选

{

password = textBox3.Text; if(Typename.Text.Trim()==\"\") {

MessageBox.Show(\"请选择登录类型\",\"登录提示\",

MessageBoxButtons.OK,MessageBoxIcon.Information); Typename.Focus(); return false; }

else if(loginid.Text.Trim()==\"\") {

MessageBox.Show(\"请输入用户名\", \"登录提示\",

MessageBoxButtons.OK, MessageBoxIcon.Information); loginid.Focus(); return false;

}

else if (password == \"\") {

MessageBox.Show(\"请输入密码\", \"登录提示\",

MessageBoxButtons.OK, MessageBoxIcon.Information); textBox3.Focus(); return false; } else {

return true; } }

public LoginForm() {

InitializeComponent(); }

private void cancelbtn_Click(object sender, EventArgs e) {

Application.Exit(); }

private void LoginForm_Load(object sender, EventArgs e) { }

private void LoginForm_Closing(object sender, FormClosingEventArgs e) {

Application.Exit();

精选

}

private void loginbtn_Click(object sender, EventArgs e) {

if (yanzhengshuru()) {

if (Typename.Text.Trim() == \"管理员\") {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"select AdminID,AdminPass from userhelper \"; SqlCommand com = new SqlCommand(cmd, conConnection); SqlDataReader reader = com.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();

admin f1 = new admin (); f1.ShowDialog(); } } else {

if (Typename.Text.Trim() == \"普通用户\") {

SqlConnection conConnection1 = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection1.Open();

string cnd = \"select ReaderID,ReaderPassword from reader \"; SqlCommand cnm = new SqlCommand(cnd, conConnection1); SqlDataReader reader1 = cnm.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; } } } } } }

private void label1_Click(object sender, EventArgs e) { }

private void label2_Click(object sender, EventArgs e) { }

private void label3_Click(object sender, EventArgs e) { }

private void button1_Click(object sender, EventArgs e) {

精选

this.Hide();

注册 f1 = new 注册(); f1.ShowDialog(); }

private void usercomboBox_SelectedIndexChanged(object sender, EventArgs e) { }

private void useracctxt_TextChanged(object sender, EventArgs e) { }

private void textBox3_TextChanged(object sender, EventArgs e) { } } }

3.2登陆界面

如果学号已经存在,则会出现“*用户名已经存在,请重新输入”的提示,当重新输入密码时,如果两次密码不相同,则会出现“*请注意,两次密码不一样”的提示

精选

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1 {

public partial class 注册 : Form {

public 注册() {

精选

InitializeComponent(); }

public bool UserFlag;

private void textBox3_TextChanged(object sender, EventArgs e) {

if (textBox2.Text.Trim() != textBox3.Text.Trim()) {

label6.Visible = true; } else {

label8.Visible = true; label6.Visible = false; } }

private void 注册_Load(object sender, EventArgs e) { }

private void textBox1_TextChanged(object sender, EventArgs e) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"select ReaderID from reader \";

SqlCommand com = new SqlCommand(cmd ,conConnection ); SqlDataReader readerUser = com.ExecuteReader(); while (readerUser.Read ()) {

if(textBox1.Text ==readerUser[\"ReaderID\"].ToString().Trim()) {

label7.Visible = true; UserFlag = true; return; }

else if (textBox1.Text != readerUser[\"ReaderID\"].ToString().Trim()) {

label7.Visible = false; label9.Visible = true; UserFlag = false; } } }

private void 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(\"用户已经存在,请重新输入!\"); return; }

if (UserFlag==false) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"insert into reader(ReaderID,ReaderPassword,ReaderEmall) values ('\"+textBox1.Text+\"',\"+\"'\"+textBox2.Text+\"',\"+\"'\"+textBox4.Text+\"')\"; SqlCommand com = new SqlCommand(cmd,conConnection ); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"注册成功!点击确定,返回登录界面。\",\"提示\"); this.Close();

LoginForm f2 = new LoginForm();

} } } }

3.3管理员操作界面

精选

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; namespace WindowsFormsApplication1 {

public partial class admin : Form {

public admin() {

InitializeComponent(); }

private void 查看用户信息ToolStripMenuItem_Click(object sender, EventArgs e) {

权限设置 f8 = new 权限设置(); f8.ShowDialog(); }

private void 查看用户信息ToolStripMenuItem1_Click(object sender, EventArgs e) {

用户信息 fi = new 用户信息(); fi.ShowDialog(); }

private void 新增用户ToolStripMenuItem1_Click(object sender, EventArgs e) {

新增用户 f2 = new 新增用户();

精选

f2.ShowDialog(); }

private void 删除用户ToolStripMenuItem1_Click(object sender, EventArgs e) {

用户信息 f3 = new 用户信息(); f3.button2.Visible = true; f3.ShowDialog(); }

private void 录入书籍ToolStripMenuItem_Click(object sender, EventArgs e) {

书籍信息 f5 = new 书籍信息(); f5.ShowDialog(); }

private void 删除书籍ToolStripMenuItem_Click(object sender, EventArgs e) {

删除书籍 f6 = new 删除书籍(); f6.ShowDialog(); }

private void 还书处理ToolStripMenuItem_Click(object sender, EventArgs e) {

还书处理 f9 = new 还书处理(); f9.ShowDialog(); }

private void admin_Load(object sender, EventArgs e) { }

private void 借阅处理ToolStripMenuItem_Click(object sender, EventArgs e) {

借阅处理 f10 = new 借阅处理(); f10.ShowDialog(); } } }

3.3.1管理用户

管理用户下共有三个子菜单

3.3.1.1

新增用户界面

精选

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient;

namespace WindowsFormsApplication1 {

public partial class 新增用户 : Form {

public 新增用户() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open(); string cmd = \"insert into

reader(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 + \"')\";

SqlCommand com = new SqlCommand(cmd, conConnection); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"添加成功!点击确定,返回登录界面。\", \"提示\"); this.Close(); } } }

3.3.1.2删除用户界面

输入学号即可查询用户信息,如图,点击删除即删除该用户

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data;

精选

using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1 {

public partial class 用户信息 : Form {

bool UserFlag; public 用户信息() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

if(UserFlag==false ) {

MessageBox.Show(\"不存在该用户,请核对后再输入\",\"警告\"); return; }

if (UserFlag == true) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"select * from reader\";

SqlCommand com=new SqlCommand (cmd,conConnection); com.CommandText = \"select * from reader\"; SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) {

label11.Visible = true;

textBox2.Text = dr[\"ReaderName\"].ToString().Trim(); textBox3.Text = dr[\"ReaderPassword\"].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[\"MaxNumber\"].ToString().Trim(); textBox9.Text = dr[\"ReaderEmall\"].ToString().Trim(); }

conConnection.Close();

精选

} }

private void textBox1_TextChanged(object sender, EventArgs e) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"select ReaderID from reader \"; SqlCommand com = new SqlCommand(cmd, conConnection); SqlDataReader readerUser = com.ExecuteReader(); while (readerUser.Read()) {

if (textBox1.Text == readerUser[\"ReaderID\"].ToString().Trim()) {

UserFlag = true; return; }

else if (textBox1.Text != readerUser[\"ReaderID\"].ToString().Trim()) {

UserFlag = false; } } }

private void button2_Click(object sender, EventArgs e) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"delete from reader where ReaderID='\" + textBox1.Text.Replace(\"'\", \"''\") + \"'\"; SqlCommand com = new SqlCommand(cmd, conConnection); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"是否确认删除\", \"提示\"); } } }

3.3.1.3 查看用户信息界面

精选

该界面与删除用户界面代码基本相似,主要是将查询按钮隐藏,故代码不再列出 3.3.2图书管理

图书查询下共有2个子菜单 3.3.2.1录入书籍页面

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq;

精选

using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1 {

public partial class 书籍信息 : Form {

public 书籍信息() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"insert into book

(BookID,BookWrite,BookName,BookPublish,BookPublishDate,BookPrice,BookSort) values ('\" + textBox1.Text + \"',\" + \"'\" + textBox2.Text + \"',\" + \"'\" + textBox3.Text + \"',\" + \"'\" + textBox4.Text + \"',\" + \"'\" + textBox5.Text + \"',\" + \"'\" + textBox6.Text + \"',\" + \"'\" + textBox7.Text + \"')\"; SqlCommand com = new SqlCommand(cmd, conConnection); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"录入成功\", \"提示\"); textBox1.Text = \"\"; textBox2.Text = \"\"; textBox3.Text = \"\"; textBox4.Text = \"\"; textBox5.Text = \"\"; textBox6.Text = \"\"; textBox7.Text = \"\"; } } }

3.3.2.2删除书籍

精选

删除书籍之前如需确认是否是所需删除的书籍,以防删除错误,可以先将所需删除的书籍的书名输入,点击检索后会出现该书的详细信息,若确认无误后点击删除即可删除该书

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1

精选

{

public partial class 删除书籍 : Form {

bool UserFlag; public 删除书籍() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

if (UserFlag == false) {

MessageBox.Show(\"不存在此书,请核对后再输入\", \"警告\"); return; }

if (UserFlag == true) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"select * from book\";

SqlCommand com = new SqlCommand(cmd, conConnection); com.CommandText = \"select * from book\"; SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) {

textBox1.Text = dr[\"BookID\"].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\"].ToString().Trim(); }

conConnection.Close(); } }

private void textBox3_TextChanged(object sender, EventArgs e) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"select BookName from book \";

SqlCommand com = new SqlCommand(cmd, conConnection); SqlDataReader readerUser = com.ExecuteReader();

精选

while (readerUser.Read()) {

if (textBox1.Text == readerUser[\"BookName\"].ToString().Trim()) {

UserFlag = true; return; }

else if (textBox1.Text != readerUser[\"BookName\"].ToString().Trim()) {

UserFlag = false; } } }

private void button2_Click(object sender, EventArgs e) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"delete from book where BookName='\" + textBox3.Text.Replace(\"'\", \"''\") + \"'\"; SqlCommand com = new SqlCommand(cmd, conConnection); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"是否确认删除\", \"提示\"); } } }

3.3.3权限设置

该界面可以设置普通用户的最大借书数量、最长借阅时间、超期罚款(元/天)、遗失赔率等,主要代码如下:

using System;

精选

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1 {

public partial class 权限设置 : Form {

public 权限设置() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"insert into Right(MaxNum,MaxTime,Fine,Times) values ('\" + textBox1.Text + \"',\" + \"'\" + textBox2.Text + \"',\" + \"'\" + textBox3.Text + \"',\" + \"'\" + textBox4.Text + \"')\"; SqlCommand com = new SqlCommand(cmd, conConnection); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"修改成功\", \"提示\"); this.Close(); } } }

3.3.4还书处理

精选

输入书籍号后即可查询借阅人超期信息及图书信息,无误后点击归还确认。操作后界面如下:

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.OleDb; using System.Data.SqlClient; namespace WindowsFormsApplication1 {

public partial class 还书处理 : Form {

bool UserFlag; public 还书处理() {

InitializeComponent(); }

private void button2_Click(object sender, EventArgs e) {

if (UserFlag == false) {

MessageBox.Show(\"不存在此书,请核对后再输入\", \"警告\"); return; }

if (UserFlag == true) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\");

精选

conConnection.Open();

string cmd = \"select * from book\";

SqlCommand com = new SqlCommand(cmd, conConnection); com.CommandText = \"select * from book\"; SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) {

textBox11.Text = dr[\"BookWrite\"].ToString().Trim(); textBox12.Text = dr[\"BookName\"].ToString().Trim(); textBox13.Text = dr[\"BookPublish\"].ToString().Trim(); textBox14.Text = dr[\"BookPublishDate\"].ToString().Trim(); textBox15.Text = dr[\"BookPrice\"].ToString().Trim(); textBox16.Text = dr[\"BookSort\"].ToString().Trim(); }

conConnection.Close();

SqlConnection conConnection1 = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection1.Open();

string cmd1 = \"select s.*,g.* from borrow s,reader g where s.ReaderID=g.ReaderID\"; SqlCommand com1 = new SqlCommand(cmd1, conConnection1);

com1.CommandText = \"select s.*,g.* from borrow s,reader g where s.ReaderID=g.ReaderID\"; SqlDataReader dr1 = com1.ExecuteReader(); while (dr1.Read()) {

textBox2.Text = dr1[\"BorrowDate\"].ToString().Trim(); textBox3.Text = dr1[\"ReturnDate\"].ToString().Trim(); textBox4.Text = dr1[\"ReaderID\"].ToString().Trim(); textBox5.Text = dr1[\"ReaderName\"].ToString().Trim(); textBox6.Text = dr1[\"ReaderSex\"].ToString().Trim(); textBox7.Text = dr1[\"ReaderDept\"].ToString().Trim(); textBox8.Text = dr1[\"ReaderZhuanYe\"].ToString().Trim(); DateTime t1 = DateTime.Now;

DateTime t2 = (DateTime )dr1[\"ReturnDate\"]; TimeSpan ts = t1-t2 ;

int d = ts.Days; textBox9.Text = Convert.ToString( d); if (d <= 0) {

textBox10.Text =Convert.ToString (0); } else {

textBox10.Text = Convert.ToString (d * 0.1); }

精选

}

conConnection1.Close(); } }

private void textBox1_TextChanged(object sender, EventArgs e)

{ SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"select BookID from book \";

SqlCommand com = new SqlCommand(cmd, conConnection); SqlDataReader readerUser = com.ExecuteReader(); while (readerUser.Read()) {

if (textBox1.Text == readerUser[\"BookID\"].ToString().Trim()) {

UserFlag = true; return; }

else if (textBox1.Text != readerUser[\"BookID\"].ToString().Trim()) {

UserFlag = false; } } }

private void button1_Click(object sender, EventArgs e) {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"delete from borrow where BookID=('\"+textBox1.Text +\"')\"; SqlCommand com = new SqlCommand(cmd, conConnection); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"添加成功!点击确定,返回登录界面。\", \"提示\"); this.Close(); } } }

3.3.5借阅处理

精选

输入用户名及书籍编号,点击借阅即借书成功,操作后界面如下:

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1 {

public partial class 借阅处理 : Form {

public 借阅处理() {

InitializeComponent();

精选

}

private void button1_Click(object sender, EventArgs e) {

if(textBox1.Text.Trim()==\"\")

{MessageBox.Show(\"请输入用户名\",\"提示\"); return; }

if (textBox2.Text.Trim() ==\"\" ) {

MessageBox.Show(\"请输入书籍编号\", \"提示\"); return; }

string time = DateTime.Now.ToString(); DateTime dt = DateTime.Now.Date.AddDays(30); string returntime = dt.ToString(); textBox4.Text = time; textBox5.Text = returntime;

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string conn=@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"; string tt=\"select BookName from book where BookID='\"+textBox2.Text+\"'\"; SqlDataAdapter da = new SqlDataAdapter(tt,conn); DataSet ds = new DataSet(); da.Fill(ds);

textBox3.Text = ds .Tables[0].Rows[0][0].ToString();

string cmd = \"insert into borrow(ReaderID,BookID,BorrowDate,ReturnDate) values ('\" + textBox1.Text + \"',\" + \"'\" + textBox2.Text + \"',\" + \"'\" + textBox4.Text + \"',\" + \"'\" + textBox5.Text + \"')\"; SqlCommand com = new SqlCommand(cmd, conConnection); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"借阅成功\", \"提示\"); } } }

3.4读者查询

3.4.1读者查询界面

精选

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; namespace WindowsFormsApplication1 {

public partial class 读者查阅 : Form {

public 读者查阅() {

InitializeComponent(); }

private void 读者信息ToolStripMenuItem_Click(object sender, EventArgs e) {

借阅信息 f2 = new 借阅信息(); f2.ShowDialog(); }

private void 图书查询ToolStripMenuItem_Click(object sender, EventArgs e) {

图书查询 f1 = new 图书查询(); f1.ShowDialog(); }

private void 图书续借ToolStripMenuItem_Click(object sender, EventArgs e) {

图书续借 f3 = new 图书续借();

精选

f3.ShowDialog(); }

private void 图书挂失ToolStripMenuItem_Click(object sender, EventArgs e) {

图书挂失 f4 = new 图书挂失(); f4.ShowDialog(); } } }

3.4.2图书查询

该页面支持模糊查询,输入关键字即可查询相关书籍,操作界面如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient;

精选

using System.Configuration; namespace WindowsFormsApplication1 {

public partial class 图书查询 : Form {

public 图书查询() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

FillGrid(); }

private void FillGrid() {

if (this.textBox1.Text == string.Empty) {

MessageBox.Show(\"请输入你要使用的检索条件!\", \"提示!\"); return; }

string sql = string.Empty;

sql += \"select BookID as ID号, BookWrite as 作者, BookName as 书名,BookPublish as 出版社, BookPublishDate as 出版日期, BookPrice as 价格, BookSort as 书类 from book\"; if (this.textBox1.Text != \"\") {

sql += \" where BookName like '%\" + this.textBox1.Text + \"%'\"; }

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open(); string cmd = sql ;

DataSet dataset = new DataSet();

SqlDataAdapter myDataAdapter = new SqlDataAdapter(cmd,conConnection ); myDataAdapter.Fill(dataset);

dataGridView1.DataSource = dataset.Tables[0]; } } }

3.4.3借阅信息

精选

输入学号后点击查询,即可查到已有借阅信息,查询后界面如下

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; using System.Configuration; namespace WindowsFormsApplication1 {

public partial class 借阅信息 : Form {

public 借阅信息() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

精选

FillGrid(); }

private void FillGrid() {

if (this.textBox1.Text == string.Empty) {

MessageBox.Show(\"请输入你要使用的学号!\", \"提示!\"); return; }

string sql = string.Empty;

sql += \"select s.BookID as ID号, s.BookWrite as 作者, s.BookName as 书名,s.BookPublish as 出版社, s.BookPublishDate as 出版日期, s.BookPrice as 价格,g.BorrowDate as 借阅日期 from book s,borrow g\";

if (this.textBox1.Text != \"\") {

sql += \" where s.BookID=g.BookID\"; }

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open(); string cmd = sql;

DataSet dataset = new DataSet();

SqlDataAdapter myDataAdapter = new SqlDataAdapter(cmd, conConnection); myDataAdapter.Fill(dataset);

dataGridView1.DataSource = dataset.Tables[0]; } } }

3.4.3图书续借

输入书籍编号,点击续借即可。 主要代码如下:

using System;

精选

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1 {

public partial class 图书续借 : Form {

public 图书续借() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

if (textBox1.Text.Trim() == \"\") {

MessageBox.Show(\"请输入书籍编号\", \"提示\"); return; } else {

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string conn = @\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\";

string tt = \"select BookName from book where BookID='\" + textBox1.Text + \"'\"; SqlDataAdapter da = new SqlDataAdapter(tt, conn); DataSet ds = new DataSet(); da.Fill(ds);

textBox2.Text = ds.Tables[0].Rows[0][0].ToString();

string cmd = \"update borrow set ReturnDate=DateTime.Now.Date.AddDays(15) where BookID='\" + textBox1.Text + \"'\";

SqlCommand com = new SqlCommand(cmd, conConnection); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"续借成功\", \"提示\"); textBox1.Text = \"\"; textBox2.Text = \"\"; }

精选

} } }

3.4.4图书挂失

输入图书编号即可挂失,操作后界面如下

主要代码如下:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication1 {

public partial class 图书挂失 : Form {

public 图书挂失() {

InitializeComponent();

精选

}

private void button1_Click(object sender, EventArgs e) {

if (textBox1.Text.Trim() == \"\") {

MessageBox.Show(\"请输入书籍编号\", \"提示\"); return; }

string conn = @\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"; string tt = \"select BookName from book where BookID='\" + textBox1.Text + \"'\"; SqlDataAdapter da = new SqlDataAdapter(tt, conn); DataSet ds = new DataSet(); da.Fill(ds);

textBox2.Text = ds.Tables[0].Rows[0][0].ToString();

SqlConnection conConnection = new SqlConnection(@\"Data Source=.\\sqlexpress;Initial Catalog=学生管理数据库;Integrated Security=True\"); conConnection.Open();

string cmd = \"update borrow set Lost=1 where BookID='\" + textBox1.Text + \"'\";

//string cmd = \"insert into borrow(ReaderID,BookID,BorrowDate,ReturnDate) values ('\" + textBox1.Text + \"',\" + \"'\" + textBox2.Text + \"',\" + \"'\" + textBox4.Text + \"',\" + \"'\" + textBox5.Text + \"',)\"; SqlCommand com = new SqlCommand(cmd, conConnection); com.ExecuteNonQuery(); conConnection.Close();

MessageBox.Show(\"挂失成功\", \"提示\"); textBox1.Text = \"\"; textBox2.Text = \"\"; } } }

附录:软件基本信息

精选

1、软件系统的名称:图书管理系统 2、开发者:小组全体成员

姓名 学号 邢吉昌 2014701020 魏广宇 2014701016 吴 阳 2014701018 袁清冽 2014701023 张建柱 2014701024

3、该软件系统同其他系统或其他机构的基本的相互来往关系:该系统可以联网运营,简单方便

精选

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- igbc.cn 版权所有 湘ICP备2023023988号-5

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务