收藏 分销(赏)

图书管理系统(内附源代码).doc

上传人:精*** 文档编号:2645640 上传时间:2024-06-03 格式:DOC 页数:61 大小:569.04KB 下载积分:16 金币
下载 相关 举报
图书管理系统(内附源代码).doc_第1页
第1页 / 共61页
图书管理系统(内附源代码).doc_第2页
第2页 / 共61页


点击查看更多>>
资源描述
图书管理系统(内附源代码) ———————————————————————————————— 作者: ———————————————————————————————— 日期: 61 个人收集整理 勿做商业用途 本人是一个初学者,2个月前学习C#,学习过程中遇到过许多困难无法独立解决,现在做成了第一个系统:图书管理系统,各项功能均能顺利实现,因为知道很多初学者和我一样苦无求学之道,现在将部分主要源码上传,希望能得到高手的指点. 下面就是该系统的主要功能及代码: 1。登陆界面 主要代码: public partial class LoginForm : Form{ public static string uacc; public static string upsw; public static string uname; public static string usex; public static string upart; public static string uright; public LoginForm() { InitializeComponent(); } private void loginbtn_Click(object sender, EventArgs e) { if (this.useracctxt。Text。Trim() == ”” && this.pswtxt。Text == ””) { MessageBox。Show(”请输入您的用户名和密码!", "提示!”); return; } try { string sql; sql = "select * from tb_user where uacc='” + this.useracctxt。Text + ”’ and upsw=’" + this。pswtxt。Text + "'”; OleDbDataReader dr = DBHelp.OleReader(sql); dr.Read(); if (dr。HasRows) { uacc = this。useracctxt。Text; upsw = this。pswtxt。Text; uname = dr["uname"]。ToString(); usex = dr["usex"]。ToString(); upart = dr["upart”]。ToString(); uright = dr[”uright”]。ToString(); MainForm af = new MainForm(this); this.Hide(); this。useracctxt。Clear(); this.pswtxt。Clear(); af.Show(); } else { MessageBox。Show(”账号或密码错误!”, "提示!”); this.useracctxt.Clear(); this.pswtxt。Clear(); this.useracctxt。Focus(); } } catch (Exception) { MessageBox。Show("数据库无法连接!", "警告!”); } } private void cancelbtn_Click(object sender, EventArgs e) { Application.Exit(); } private void LoginForm_Closing(object sender, FormClosingEventArgs e) { Application。Exit(); } } 2.主界面(图较小,自己可以拉大点) 主要代码就不写了,很简单。 3.权限设置 主要代码: public partial class RightSet : Form { public RightSet() { InitializeComponent(); } private void RightSet_Load(object sender, EventArgs e) { this.rightbox.SelectedIndex = 0; //this.treeright.ExpandAll(); Fill(); } private void okbtn_Click(object sender, EventArgs e) { if (this.txtnum.Text == string。Empty) { MessageBox.Show(”请输入最大借阅图书数量!”, "提示!"); return; } if (this.txtday。Text == string.Empty) { MessageBox.Show(”请输入最大借阅图书时间!”, "提示!”); return; } if (this。txtcost。Text == string。Empty) { MessageBox.Show(”请输入借书押金金额!”, ”提示!”); return; } if (this。txtfine.Text == string.Empty) { MessageBox.Show("请输入超期罚款金额!”, "提示!"); return; } if (this.txttim。Text == string。Empty) { MessageBox.Show("请输入图书遗失罚款倍数!”, ”提示!"); return; } ArrayList arr = new ArrayList(); foreach (TreeNode nodes in this.treeright.Nodes) { if (nodes.Checked) { arr.Add(”1”); } else { arr。Add("0”); } foreach(TreeNode node in nodes。Nodes) { if (node.Checked) { arr.Add("1"); } else { arr.Add(”0”); } } } string[] a=new string[11]; for (int i = 0; i 〈 arr.Count; i++) { if (arr[i]。ToString().Trim() == ”1") { a[i] = ”yes”; } else { a[i] = ”no”; } } string sql = string.Empty; sql += "select * from tb_right where uright=’" + this.rightbox。Text + ”'"; DataTable dt = DBHelp。ExeOleCommand(sql); bool b = false; while (dt.Rows.Count != 0) { b = true; break; } string sql1; if (b) { sql1 = ”update tb_right set "; sql1 += ”maxbook=’” + this。txtnum.Text + "',”; sql1 += "maxdate=’" + this。txtday。Text + ”’,"; sql1 += "rcost=’" + this.txtcost。Text + ”',”; sql1 += "rfine=’" + this.txtfine。Text + ”’,”; sql1 += "rtim=’" + this。txttim。Text + ”',”; sql1 += ”rbm=’" + a[0] + ”',”; sql1 += "rum=’” + a[1] + ”’,"; sql1 += ”rrm=’" + a[2] + "',”; sql1 += "rborm='” + a[3] + "’,"; sql1 += "ris=’” + a[4] + "',"; sql1 += "rbis=’" + a[5] + "',”; sql1 += ”ruis=’" + a[6] + ”',"; sql1 += "rboris=’" + a[7] + ”’,"; sql1 += "rblp=’” + a[8] + ”’,"; sql1 += "rbl=’" + a[9] + ”’,"; sql1 += "rlp='" + a[10] + ”’ "; sql1 += ”where uright='” + this。rightbox。Text + ”'”; } else { sql1 = "insert into tb_right(uright,maxbook,maxdate,rcost,rfine,rtim,rbm,rum,rrm,rborm,ris,rbis,ruis,rboris,rblp,rbl,rlp)”; sql1 += " values(’" + this。rightbox。Text + "','" + this.txtnum。Text + "’,’" + this.txtday.Text + "’,'" + this。txtcost.Text + ”',’" + this.txtfine。Text + "’,’” + this。txttim。Text + ”',’” + a[0] + ”’,'" + a[1] + "’,’" + a[2] + ”’,’" + a[3] + ”’,'” + a[4] + "',’” + a[5] + "’,'” + a[6] + ”','” + a[7] + "',’" + a[8] + ”’,’" + a[9] + ”’,’” + a[10] + "’)”; } DataTable dt1 = DBHelp。ExeOleCommand(sql1); Fill(); } private void Fill() { string sql; sql = "select rid as ID号,uright as 用户身份, maxbook as 最大借书数量,maxdate as 最大借阅时间,rcost as 押金,rfine as 超期罚率,rtim as 遗失赔率,rbm as 图书管理,rum as 用户管理,rrm as 权限管理,rborm as 借阅管理,ris as 信息查询,rbis as 图书信息查询,ruis as 用户信息查询,rboris as 借阅历史查询,rblp as 图书挂失处理,rbl as 图书挂失,rlp as 挂失处理 from tb_right”; DataTable dt = DBHelp.ExeOleCommand(sql); this.dataGridView1。DataSource = dt; } private void cell_click(object sender, DataGridViewCellEventArgs e) { this.rightbox.Text = this.dataGridView1[1, this。dataGridView1。CurrentCell.RowIndex].Value.ToString()。Trim(); this。txtnum.Text = this.dataGridView1[2, this。dataGridView1。CurrentCell。RowIndex].Value.ToString()。Trim(); this.txtday。Text = this.dataGridView1[3, this。dataGridView1。CurrentCell。RowIndex]。Value。ToString()。Trim(); this。txtcost。Text = this.dataGridView1[4, this.dataGridView1。CurrentCell。RowIndex].Value.ToString()。Trim(); this.txtfine。Text = this.dataGridView1[5, this。dataGridView1.CurrentCell。RowIndex]。Value.ToString().Trim(); this.txttim.Text = this.dataGridView1[6, this.dataGridView1。CurrentCell。RowIndex]。Value.ToString().Trim(); ArrayList list = new ArrayList(); string sql = "select * from tb_right where uright=’” + this.rightbox.Text + "'"; DataTable dt = DBHelp。ExeOleCommand(sql); if (dt。Rows。Count != 0) { for (int i = 0; i < 11; i++) { list.Add(dt.Rows[0][7+i]。ToString()); } ArrayList arr = new ArrayList(); foreach (TreeNode nodes in this。treeright.Nodes) { arr.Add(nodes); foreach(TreeNode node in nodes.Nodes) { arr.Add(node); } } for (int i = 0; i 〈 list。Count; i++) { if (list[i]。ToString() == ”yes") { ((TreeNode)arr[i]).Checked = true; } else { ((TreeNode)arr[i]).Checked = false; } } } } 4。权限修改 主要代码: public partial class UserRight : Form { public UserRight() { InitializeComponent(); } private void btncancel_Click(object sender, EventArgs e) { this。Close(); } private void UserRight_Load(object sender, EventArgs e) { this.checkbox.SelectedIndex = 0; this.partbox。SelectedIndex = 0; } private void Fill() { if (this.checkbox.Text == "") { MessageBox。Show(”请选择要使用的查询字段!”, "提示!”); return; } if (this。partbox。Text == "”) { MessageBox.Show(”请选择用户所在的部门!”, ”提示!”); return; } string sql = string。Empty; sql += "select uid as ID号,uacc as 帐号,uname as 姓名,usex as 性别,upart as 部门,utelphone as 移动电话,uphone as 固定电话,udate as 注册日期,uright as 权限 from tb_user”; if (this。checktxt.Text != ”") { string c = this。checkbox.SelectedIndex。ToString(); switch (c) { case ”0”://用户帐号 if (this。checktxt.Text != string。Empty) { sql += " where uacc like '%” + this.checktxt.Text + ”%’"; } break; case "1”://用户姓名 if (this.checktxt.Text != string。Empty) { sql += " where uname like '%” + this。checktxt。Text + ”%’”; } break; default: break; } if (this。partbox.SelectedIndex。ToString() != ”0”) { sql += ” and upart=’” + this。partbox。Text + "'”; } } else { if (this。partbox。SelectedIndex。ToString() != ”0”) { sql += " where upart=’" + this。partbox.Text + ”'"; } } sql += ” order by uacc asc"; DataTable dt = DBHelp。ExeOleCommand(sql); this。dataGridView1。DataSource = dt; } private void checkbtn_Click(object sender, EventArgs e) { Fill(); } private void cell_click(object sender, DataGridViewCellEventArgs e) { this.txtuacc。Text = this.dataGridView1[1, this。dataGridView1。CurrentCell.RowIndex]。Value.ToString().Trim(); this。txtname。Text = this.dataGridView1[2, this。dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim(); this。txtsex。Text = this.dataGridView1[3, this。dataGridView1。CurrentCell.RowIndex].Value.ToString()。Trim(); this.txtpart.Text = this.dataGridView1[4, this。dataGridView1.CurrentCell.RowIndex]。Value.ToString()。Trim(); this。txttel。Text = this。dataGridView1[5, this.dataGridView1.CurrentCell.RowIndex]。Value.ToString().Trim(); this。txtphone.Text = this.dataGridView1[6, this.dataGridView1.CurrentCell。RowIndex]。Value。ToString().Trim(); this.txtdate。Text = this.dataGridView1[7, this。dataGridView1.CurrentCell。RowIndex].Value.ToString()。Trim(); this。txtright.Text = this。dataGridView1[8, this.dataGridView1。CurrentCell。RowIndex].Value.ToString()。Trim(); this.txtright.Enabled = true; } private void btnchange_Click(object sender, EventArgs e) { if (this.txtuacc。Text == "”) { MessageBox。Show(”执行操作前,请先在下表选择要修改的用户!", ”提示!"); return; } DialogResult res; res=MessageBox。Show(”您确定要修改该用户吗?”, ”提示!”, MessageBoxButtons.YesNo); if (res == DialogResult。Yes) { string sql = string.Empty; sql += ”update tb_user set uright=’”+this。txtright。Text+"'”; sql += ” where uacc=’”+this。txtuacc.Text+"’”; DataTable dt = DBHelp.ExeOleCommand(sql); MessageBox.Show(”修改成功!",”恭喜!”); Fill(); } } } 5。添加图书信息 主要代码: public partial class NewBook : Form { public NewBook() { InitializeComponent(); } private void retbtn_Click(object sender, EventArgs e) { this。Hide(); } private void savebtn_Click(object sender, EventArgs e) { if (this。booknotxt.Text == ”") { MessageBox。Show("请输入图书的信息!", "提示!"); return; } if (this.booknametxt.Text == ””) { MessageBox。Show(”请输入图书的信息!”, "提示!”); return; } if (this。classtxt.Text == "”) { MessageBox.Show("请输入图书的信息!”, "提示!”); return; } if (this。isbntxt。Text == ”") { MessageBox.Show("请输入图书的信息!”, ”提示!”); return; } if (this。bookcosttxt。Text == "”) { MessageBox。Show(”请输入图书的信息!”, "提示!”); return; } if (this.bookwritertxt。Text == "") { MessageBox。Show("请输入图书的信息!", ”提示!"); return; } if (this.bookpubtxt。Tex
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服