资源描述
** 学 院
计 算 机 科 学 系
实训项目结题报告
项目名称 图书管理系统
课程名称 C# Winform 程序设计实践
专业 软件技术 班 级 软件121
项目组编号 项目经理 **
实训时间 2023.1.3
项目经理填写成员,实训成绩由教师填写:
成员
**
**
**
个人成绩
项目组
总成绩
教师
署名
项目需求概要:
计算机技术的迅猛发展,特别是随着网络技术的出现标志着信息时代已经来临。信息化浪潮、网络革命在给社会带来冲击的同时,也使图书馆业务受到了强烈的冲击,图书馆传统的管理和服务方式已不能适应读者对日益增长的文献信息的需求,建设图书馆信息网络系统,是图书馆现代化建设的客观规定。建设以计算机为核心的图书馆信息网络,实现图书馆管理和服务的自动化,更好地为科技工作服务,是图书馆发展的必由之路。
随着图书馆规模的不断扩大,图书数量也相应的增长,
有关图书的各种信息量也成倍增长,面对着庞大的信息量,
传统的人工方式管理睬导致图书馆管理上的混乱,人力与
物力过多浪费,图书馆管理费用的增长,从而使图书馆的
承担过重,影响整个图书馆的运作和控制管理,因此,必
须制定一套合理、有效,规范和实用的图书管理系统,对
图书资料进行集中统一的管理变得非常有必要。所以,图
书管理系统的制作是急切的和必须的。
项目计划:
将项目分为5个模块:
1、 数据库的设计
2、 界面的设计
3、 第一个任务:平常操作:
A、 图书归还
B、 图书借出
C、 借阅情况
4、 第二个任务:资料管理
A、 添加书籍
B、 修改书籍
C、 删除书籍
D、 查询书籍
5、 第三个任务:用户管理
A、 用户查询
B、 用户修改
C、 用户删除
D、 用户增长
项目具体设计:
1. 程序清单:
11个界面设计
frmBookAdd.cs
书籍添加
frmReturnBooks.cs
归还书籍
frmBorrowBooks.cs
借出书籍
frmChangePassword.cs
密码修改
frmBookManage.cs
书籍管理
frmReaderManage.cs
用户管理
frmLogin.cs
登陆
frmMain.cs
主界面
frmAddReader.cs
添加用户
frmoperation.cs
用户管理(注销与挂失)
frmUpdateBooks.cs
图书修改
frmQueryReader.cs
查询用户
frmfindBooks.cs
查询图书
具体设计简介:
操作流程
1、 数据库设计:
2、 界面的设计:13个界面
3、第一个任务:平常操作:
E、 图书归还
F、 图书借出
3、第三个任务:用户管理
G、 用户查询
H、 用户修改
I、 用户删除
J、 用户增长
具体设计
登陆:
主界面:
实现,图书管理,用户管理,图书借阅,图书归还,修改用户密码等界面的跳转
借阅书籍:
先查询读者的信息,
再根据读者额的相关信息做图书的借阅:
读者信息:
图书借阅:
private void button1_Click(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder();
builder.Append("select * from Bookstore where bookid like'" + tbbooksid.Text.ToString().Trim() + "'");
dgvBooksINfor.AutoGenerateColumns = false;
SqlConnection sc1 = new SqlConnection("data source=(local);initial catalog=BMS;integrated security=true");
SqlDataAdapter sda1 = new SqlDataAdapter(builder.ToString(), sc1);
dsbook = new DataSet();
sda1.Fill(dsbook);
bsbook = new BindingSource(dsbook, "Table");
//renovate();
if (tbname.Text == "")
{
MessageBox.Show("请?先è选?择?读á者?,?然?后ó再ù增?加ó图?书酣?");
return;
}
if (tbbooksid.Text == "")
{
MessageBox.Show("请?选?择?图?书酣?", "系μ统?提 示?");
return;
}
//手?动ˉ添 加ó行D
bsbook = new BindingSource(dsbook, "Table");
DataRowView drv = (DataRowView)bsbook.Current;
if (Convert.ToInt32(drv["count"]) < 1)//判断是否可以借出
{
MessageBox.Show("图书酣库存局限性,暂时骸不能借è出!", "系统提醒");
return;
}
if (tbrentnum.Text.ToString()=="0")//根据当獭前用户判断用户的可借本数簓
{
MessageBox.Show("当獭前用户的可借本数簓达成最大洙值", "系统提醒");
return;
}
DataGridViewRow row = new DataGridViewRow();
DataGridViewCheckBoxCell cb1 = new DataGridViewCheckBoxCell();
cb1.Value = false;
row.Cells.Add(cb1);
DataGridViewTextBoxCell tb2 = new DataGridViewTextBoxCell();
tb2.Value = drv["bookid"].ToString();
row.Cells.Add(tb2);
DataGridViewTextBoxCell tb3 = new DataGridViewTextBoxCell();
tb3.Value = drv["name"].ToString();
row.Cells.Add(tb3);
DataGridViewTextBoxCell tb4 = new DataGridViewTextBoxCell();
tb4.Value = drv["ISBN"].ToString();
row.Cells.Add(tb4);
DataGridViewTextBoxCell tb5 = new DataGridViewTextBoxCell();
tb5.Value = drv["className"].ToString();
row.Cells.Add(tb5);
DataGridViewTextBoxCell tb6 = new DataGridViewTextBoxCell();
tb6.Value = DateTime.Now.ToLongDateString();
row.Cells.Add(tb6);
DataGridViewTextBoxCell tb7 = new DataGridViewTextBoxCell();
tb7.Value = DateTime.Now.AddDays(Convert.ToInt32(tbrentTime.Text.Trim()));
row.Cells.Add(tb7);
DataGridViewTextBoxCell tb_8 = new DataGridViewTextBoxCell();
tb_8.Value = drv["price"].ToString();
row.Cells.Add(tb_8);
dgvBooksINfor.Rows.Add(row);
drv["count"] = Convert.ToInt32(drv["count"]) - 1;// count--;
}
图书归还:
图书借阅情况查询:
private void btnfindid_Click(object sender, EventArgs e)
{
tbid.Clear();
tbname.Clear();
tbreadtype.Clear();
tbtype.Clear();
dgvBooksINfor.Rows.Clear();
StringBuilder builder = new StringBuilder();
builder.Append("select * from Readers where id like'" + tbreadid.Text.ToString().Trim() + "'or id like'%" + tbreadid.Text.ToString().Trim() + "%'");
dgvBooksINfor.AutoGenerateColumns = false;
SqlConnection sc = new SqlConnection("data source=(local);initial catalog=BMS;integrated security=true");
SqlDataAdapter sda = new SqlDataAdapter(builder.ToString(), sc);
dsRead = new DataSet();
sda.Fill(dsRead);
bsread = new BindingSource(dsRead, "Table");
tbid.DataBindings.Add("Text", bsread, "id");
tbname.DataBindings.Add("Text", bsread, "name");
tbreadtype.DataBindings.Add("Text", bsread, "readTYpe");
tbtype.DataBindings.Add("Text", bsread, "type");
// tbreadid.Clear();
//ReturnBooks();
StringBuilder builder1 = new StringBuilder();
builder1.Append("select * from BorrowBooks where readId like'" + tbreadid.Text.ToString().Trim() + "'order by borrowTime asc");//order by borrowTime asc
dgvBooksINfor.AutoGenerateColumns = false;
SqlConnection sc2 = new SqlConnection("data source=(local);initial catalog=BMS;integrated security=true");
SqlDataAdapter sda1 = new SqlDataAdapter(builder1.ToString(), sc2);
dsbook = new DataSet();
sda1.Fill(dsbook);
图书借阅归还:
private void btreturnbooks_Click(object sender, EventArgs e)
{
if (tbtype.Text == "挂骸 || tbtype.Text == "冻结á")
{
MessageBox.Show("读者已经-" + tbtype.Text + ",不能进行归还", "系统提醒?");
return;
}
foreach (DataGridViewRow row in dgvBooksINfor.Rows)
{
//DataGridViewCheckBoxCell cb = (DataGridViewCheckBoxCell)row.Cells[0];
if (row.Cells[0] != null && Convert.ToBoolean(row.Cells[0].Value) == true)
{
//数簓据Y库a中D的?已?连?接ó问ê题琣的?编括 写′
SqlConnection scinsert = new SqlConnection("data source=(local);initial catalog=BMS;integrated security=true");
scinsert.Open();
SqlCommand scmdinsert = new SqlCommand("update Bookstore set count=count+1 where bookid='"+row.Cells[1].Value.ToString()+"'", scinsert);
scmdinsert.ExecuteNonQuery();
scinsert.Close();
}
MessageBox.Show("归还成é功!", "系统提醒");
}
}
书籍管理:
修改书籍、添加书籍、删除书籍、查询书籍、书籍类型的树状图
private void bt_DB_addbook_Click(object sender, EventArgs e)//增?加ó图?书酣
{
frmAddBooks frm = new frmAddBooks(dsRead, dr, sdaRead, tableBookType);
frm.Show();
}
private void bt_DB_deletebook_Click(object sender, EventArgs e)//删?除y图?书酣
{
if (dgvReadManage.SelectedRows.Count == 0)
{
//return;
MessageBox.Show("请?您ú选?择?要癮删?除y的?行D再ù进?行D操ù作痢 !?","系μ统?提 示?");
}
for (int i = 0; i < this.dgvReadManage.SelectedRows.Count; i++)
{
this.dgvReadManage.Rows.Remove(this.dgvReadManage.SelectedRows[i]);
}
sdaRead.Update(dsRead);
dsRead.AcceptChanges();
MessageBox.Show("保馈 存?成é功|!?","系μ统?提 示?");
}
private void bt_DB_updatebook_Click(object sender, EventArgs e)//修T改?图?书酣
{
if (dgvReadManage.SelectedRows.Count == 0)
{
MessageBox.Show("请?选?中D要癮修T改?的?行D后ó在ú进?行D修T改?!?");
return;
}
DataGridViewRow dgvrow = dgvReadManage.SelectedRows[0];
string id1 = dgvrow.Cells[1].Value.ToString().Trim();
DataRow[] dr = dsRead.Tables[0].Select("bookid='" + id1 + "'");
frmUpdateBooks frm = new frmUpdateBooks(dsRead,tableBookType,dr[0]);
frm.Show();
bs = new BindingSource(dsRead, "Table");
}
private void bt_DB_findbook_Click(object sender, EventArgs e)//查é询ˉ图?书酣
{
frmfindBooks fr = new frmfindBooks(dsRead);
fr.Show();
}
private void bt_DB_exit_Click(object sender, EventArgs e)
{
frmMain frm = new frmMain(user);
frm.Show();
this.Close();
}
private void frmBookManage_Load(object sender, EventArgs e)
{
//dgvReadManage的填充
SqlConnection sc = new SqlConnection
("data source=(local);initial catalog=BMS;integrated security=true");
sdaRead = new SqlDataAdapter("select * from Bookstore", sc);
SqlCommandBuilder scb = new SqlCommandBuilder(sdaRead);
dsRead = new DataSet();
sdaRead.Fill(dsRead);
dgvReadManage.AutoGenerateColumns = false;
dgvReadManage.DataSource = dsRead.Tables[0];
//获取书酣籍列表括
SqlDataAdapter sdrBookType = new SqlDataAdapter("select * from BooksType", sc);
tableBookType = new DataTable();
sdrBookType.Fill(tableBookType);
dgvReadManage.AutoGenerateColumns = false;
dgvReadManage.DataSource = dsRead.Tables[0].DefaultView;
if (!TV_Bookstype.Nodes.ContainsKey("所ù有瓺书酣 籍?"))
{
TreeNode root = new TreeNode("所ù有瓺书酣 籍?");
root.Name = "所ù有瓺书酣 籍?";
root.Tag = "-1";
TV_Bookstype.Nodes.Add(root);
foreach (DataRow row in tableBookType.Rows)
{
TreeNode tn = new TreeNode(row["name"].ToString().Trim());
tn.Name = row["name"].ToString().Trim();
tn.Tag = row["id"].ToString();
if (!root.Nodes.ContainsKey(tn.Name))
{
root.Nodes.Add(tn);
}
}
TV_Bookstype.ExpandAll();
TV_Bookstype.HideSelection = false;
TV_Bookstype.SelectedNode = TV_Bookstype.Nodes[0];
}
}
private void dgvReadManage_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
if (this.dgvReadManage.Rows.Count != 0)
{
for (int i = 0; i < this.dgvReadManage.Rows.Count; )
{
this.dgvReadManage.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(111, 222, 233); i += 2;
}
} ?
}
书籍类型的树状图(鼠标双击)
private void TV_Bookstype_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
TreeNode clickedNode = e.Node;
SqlConnection sc = new SqlConnection("data source=(local);initial catalog=BMS;integrated security=true");
sdaRead = new SqlDataAdapter("select name from Bookstore where classNumber='" + clickedNode.Tag.ToString() + "'", sc);
DataSet ds = new DataSet();
sdaRead.Fill(ds);
foreach (DataRow row in ds.Tables[0].Rows)
{
TreeNode tn = new TreeNode(row["name"].ToString().Trim());
tn.Name = row["name"].ToString().Trim();
tn.Tag = "0";
if (!clickedNode.Nodes.ContainsKey(tn.Name))
{
clickedNode.Nodes.Add(tn);
}
}
}
private void TV_Bookstype_AfterSelect(object sender, TreeViewEventArgs e)
{
if (e.Node.Tag.ToString() =="-1")
{
dsRead.Tables[0].DefaultView.RowFilter = " ";
}
else
{
dsRead.Tables[0].DefaultView.RowFilter = "classNumber='" + e.Node.Tag.ToString() + "'";
}
}
private void btundistype_Click(object sender, EventArgs e)
{
TV_Bookstype.Hide();
}
private void btdispalytype_Click(object sender, EventArgs e)
{
TV_Bookstype.Show();
}
private void dgvReadManage_DoubleClick(object sender, EventArgs e)
{
}
添加书籍
public partial class frmAddBooks : Form
{
public frmBookManage frm1 = null;
private SqlDataAdapter sda;
private DataSet dsRead;
private DataRow dr;
private DataTable tableBookType;
public frmAddBooks(DataSet _dsRead, DataRow _dr, SqlDataAdapter _sda, DataTable _tableBookType)
{
InitializeComponent();
dsRead = _dsRead;
dr = _dr;
sda = _sda;
tableBookType = _tableBookType;
tbnZC.Text = "1";
//tbpublish.Text = dr["name"].ToString();
//tbnAddress.Text = dr["address"].ToString();
}
private void btnagain_Click(object sender, EventArgs e)
{
if (tbbookid.Text == "" && tbname.Text == "")
{
MessageBox.Show("请?您ú填?写′完 整?信?息¢", "系μ统?提 示?");
}
DataRow drRead = dsRead.Tables[0].NewRow();
//if (opfpicture.FileName != "")
//{
// Stream streamPhoto = opfpicture.OpenFile();
// byte[] bytePhoto = new byte[streamPhoto.Length];
// streamPhoto.Read(bytePhoto, 0, bytePhoto.Length);
// drRead["photo"] = bytePhoto;
//}
drRead["bookid"] = tbbookid.Text;
drRead["ISBN"] = tbISBN.Text;
drRead["name"] = tbname.Text;
drRead["classNumber"] = cbclassNum.SelectedValue
展开阅读全文