《c图管理完整源代码仿真实现 .docx》由会员分享,可在线阅读,更多相关《c图管理完整源代码仿真实现 .docx(51页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精品名师归纳总结摘要:图书馆作为一种信息资源的集散的,图书借阅频繁,用户治理多变,包含大量的信息数据。对于这些数据的治理,需要一个完善的图书治理系统来实现对图书,用户的实时治理。系统的主要任务就是对图书书目、图书借阅、图书用户查询进行统一治理,达到各类用户的需求。治理员对数据库进行操作,完成借阅、添加、删除、统计等各功能。关键词:图书馆。信息治理。图书治理( 1 ) C# 图书治理系统,一般来说,其开发环境应当为Windows系统下安装的Visual Studio,最新版是 2021 版。(2)假如系统需要使用数据库系统,仍应当依据图书系统使用的数据库,安装相应的数据库系统。如SQL 的话,应
2、当安装微软的SQL Server 2005/2021 。仍可以使用其它的数据库,如 access、oracle 等等。 1.登陆界面主要代码:publicpartialclassLoginForm :Form publicstaticstringuacc 。publicstaticstringupsw 。publicstaticstringuname。publicstaticstringusex 。publicstaticstringupart。publicstaticstringuright。publicLoginFormInitializeComponent。privatevoidlogi
3、nbtn_Clickobjectsender,EventArgs eif this .useracctxt.Text.Trim = & this .pswtxt.Text = MessageBox.Show 请输入您的用户名和密码! , 提示! 。return 。trystringsql 。sql =select * from tb_user where uacc=+this .useracctxt.Text + and upsw= + this .pswtxt.Text +。OleDbDataReader dr =DBHelp.OleReadersql。dr.Read。ifdr.HasRow
4、suacc =this .useracctxt.Text。upsw =this .pswtxt.Text。uname = druname.ToString。usex = drusex .ToString。upart = drupart.ToString。可编辑资料 - - - 欢迎下载精品名师归纳总结uright = druright.ToString。MainForm af =newMainForm this 。this .Hide。this .useracctxt.Clear。this .pswtxt.Clear。af.Show。elseMessageBox.Show 账号或密码错误! ,
5、 提示! 。this .useracctxt.Clear。this .pswtxt.Clear。this .useracctxt.Focus。catch Exception MessageBox.Show 数据库无法连接! , 警告! 。privatevoidcancelbtn_Clickobjectsender,EventArgs eApplication.Exit。privatevoidLoginForm_Closingobjectsender,FormClosingEventArgseApplication.Exit。2. 主界面(图较小,自己可以拉大点)主要代码就不写了,很简洁。3.
6、权限设置主要代码:publicpartialclassRightSet:FormpublicRightSetInitializeComponent。privatevoidRightSet_Loadobjectsender,EventArgs ethis .rightbox.SelectedIndex = 0。可编辑资料 - - - 欢迎下载精品名师归纳总结/this.treeright.ExpandAll。Fill。privatevoidokbtn_Clickobjectsender,EventArgs eif this .txtnum.Text =string.EmptyMessageBox
7、.Show 请输入最大借阅图书数量! , 提示! 。return 。if this .txtday.Text =string.EmptyMessageBox.Show 请输入最大借阅图书时间! , 提示! 。return 。if this .txtcost.Text =string.EmptyMessageBox.Show 请输入借书押金金额! , 提示! 。return 。if this .txtfine.Text =string.EmptyMessageBox.Show 请输入超期罚款金额! , 提示! 。return 。if this .txttim.Text =string.Empty
8、MessageBox.Show 请输入图书遗失罚款倍数! , 提示! 。return 。ArrayListarr =newArrayList 。foreach TreeNode nodesinthis.treeright.Nodesifnodes.Checked可编辑资料 - - - 欢迎下载精品名师归纳总结elsearr.Add1 。arr.Add0 。可编辑资料 - - - 欢迎下载精品名师归纳总结foreach TreeNode nodein nodes.Nodesifnode.Checked可编辑资料 - - - 欢迎下载精品名师归纳总结elsearr.Add1 。arr.Add0 。
9、可编辑资料 - - - 欢迎下载精品名师归纳总结string a=newstring 11 。for inti = 0。 i arr.Count。 i+ifarri.ToString.Trim =1 可编辑资料 - - - 欢迎下载精品名师归纳总结elseai =yes 。ai =no 。可编辑资料 - - - 欢迎下载精品名师归纳总结stringsql =string.Empty 。sql +=select * from tb_right where uright=+this .rightbox.Text + 。DataTable dt =DBHelp.ExeOleCommandsql 。b
10、ool b =false 。while dt.Rows.Count .= 0b =true 。break 。stringsql1 。ifbsql1 =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=+ a0 +,。s
11、ql1 +=rum=+ a1 +,。sql1 +=sql1 +=rrm=+ a2 +,。rborm=+ a3 +,。sql1 +=ris=+ a4 +,。可编辑资料 - - - 欢迎下载精品名师归纳总结sql1 +=rbis=+ a5 +,。sql1 +=ruis=+ a6 +,。sql1 +=rboris=+ a7 +,。sql1 +=rblp=+ a8 +,。sql1 +=rbl=+ a9 +,。sql1 +=rlp=+ a10 + 。sql1 +=where uright=+ this .rightbox.Text + 。elsesql1 =insert into tb_righturi
12、ght,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 +,+ a0 +,+ a1 +,+ a2 +,+ a3 +,+ a4+ ,+ a5 +,+ a6 +,+ a7 +,+ a8 +,+
13、a9 +,+ a10 + 。DataTable dt1 = DBHelp.ExeOleCommandsql1 。Fill。privatevoid Fillstring 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 用
14、户信息查询,rboris as 借阅历史查询 ,rblp as 图书挂失处理 ,rbl as 图书挂失 ,rlp as 挂失处理 fromtb_right 。DataTable dt = DBHelp.ExeOleCommandsql 。this .dataGridView1.DataSource = dt。privatevoidcell_clickobjectsender,DataGridViewCellEventArgsethis .rightbox.Text =this .dataGridView11,this .dataGridView1.CurrentCell.RowIndex.Va
15、lue.ToString.Trim。this .txtnum.Text =this .dataGridView12,this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txtday.Text =this .dataGridView13,this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txtcost.Text =this .dataGridView14,this .dataGridView1.CurrentCell.RowInde
16、x.Value.ToString.Trim。this .txtfine.Text =this .dataGridView15,可编辑资料 - - - 欢迎下载精品名师归纳总结this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txttim.Text =this .dataGridView16,this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。ArrayListlist =newArrayList 。stringsql =select * fr
17、om tb_right where uright=+ this .rightbox.Text + 。DataTable dt =DBHelp.ExeOleCommandsql 。ifdt.Rows.Count .= 0for inti = 0。 i 11。 i+list.Adddt.Rows07+i.ToString。ArrayListarr =newArrayList 。foreach TreeNode nodesinthis.treeright.Nodesarr.Addnodes。foreach TreeNode nodein nodes.Nodesarr.Addnode。for inti
18、 = 0。 i list.Count。 i+iflisti.ToString =yes TreeNodearri.Checked =true 。elseTreeNodearri.Checked =false 。4. 权限修改主要代码:publicpartialclassUserRight:FormpublicUserRightInitializeComponent。privatevoidbtncancel_Clickobjectsender,EventArgs e可编辑资料 - - - 欢迎下载精品名师归纳总结this .Close。privatevoidUserRight_Loadobjec
19、tsender,EventArgs ethis .checkbox.SelectedIndex = 0。this .partbox.SelectedIndex = 0。privatevoidFillif this .checkbox.Text = MessageBox.Show 请选择要使用的查询字段! , 提示! 。return 。if this .partbox.Text = MessageBox.Show 请选择用户所在的部门! , 提示! 。return 。stringsql =string.Empty 。sql +=select uid as ID号,uacc as帐号,uname
20、as姓名,usex as性别 ,upart as部 门,utelphone as移动电话 ,uphone as固定电话 ,udate as注册日期 ,uright as权限 from tb_user。if this .checktxt.Text .= stringc =this .checkbox.SelectedIndex.ToString。switchccase0 : / 用户帐号if this .checktxt.Text .=string.Empty可编辑资料 - - - 欢迎下载精品名师归纳总结break 。sql += where uacc like %+ this .checkt
21、xt.Text +% 。可编辑资料 - - - 欢迎下载精品名师归纳总结case1 : / 用户姓名if this .checktxt.Text .=string.Empty可编辑资料 - - - 欢迎下载精品名师归纳总结break 。default: break 。sql += where uname like %+this .checktxt.Text +% 。可编辑资料 - - - 欢迎下载精品名师归纳总结if this .partbox.SelectedIndex.ToString .=0 可编辑资料 - - - 欢迎下载精品名师归纳总结elsesql += and upart=+th
22、is .partbox.Text + 。可编辑资料 - - - 欢迎下载精品名师归纳总结if this .partbox.SelectedIndex.ToString .=0 sql += where upart=+this .partbox.Text +。sql += order by uacc asc。DataTable dt =DBHelp.ExeOleCommandsql 。this .dataGridView1.DataSource = dt。privatevoidcheckbtn_Clickobjectsender,EventArgs eFill。privatevoidcell_c
23、lickobjectsender,DataGridViewCellEventArgsethis .txtuacc.Text =this .dataGridView11,this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txtname.Text =this .dataGridView12,this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txtsex.Text =this .dataGridView13,this .dataGri
24、dView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txtpart.Text =this .dataGridView14,this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txttel.Text =this .dataGridView15,this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txtphone.Text =this .dataGridView16,this .d
25、ataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txtdate.Text =this .dataGridView17,this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txtright.Text =this .dataGridView18,this .dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim。this .txtright.Enabled =true 。privatevoid
26、btnchange_Clickobjectsender,EventArgs eif this .txtuacc.Text = MessageBox.Show 执行操作前,请先在下表选择要修改的用户! , 提示! 。可编辑资料 - - - 欢迎下载精品名师归纳总结return 。DialogResultres 。res=MessageBox.Show 您确定要修改该用户吗? , 提示! ,MessageBoxButtons .YesNo 。ifres =DialogResult.Yesstringsql =string.Empty 。sql +=update tb_user set uright
27、=+this .txtright.Text+ 。sql += where uacc=+this .txtuacc.Text+。DataTable dt =DBHelp.ExeOleCommandsql 。MessageBox.Show 修改成功! , 恭喜! 。Fill。5. 添加图书信息主要代码:publicpartialclassNewBook:FormpublicNewBookInitializeComponent。privatevoidretbtn_Clickobjectsender,EventArgs ethis .Hide。privatevoidsavebtn_Clickobjec
28、tsender,EventArgs eif 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 请输入图书的信息! , 提示!
29、 。return 。if this .bookcosttxt.Text = MessageBox.Show 请输入图书的信息! , 提示! 。return 。if this .bookwritertxt.Text = MessageBox.Show 请输入图书的信息! , 提示! 。return 。if this .bookpubtxt.Text = MessageBox.Show 请输入图书的信息! , 提示! 。return 。if this .numtxt.Text = MessageBox.Show 请输入图书的信息! , 提示! 。return 。if this .notetxt.T
30、ext = MessageBox.Show 请输入图书的信息! , 提示! 。return 。/string pat3 = u4e00-u9fa5+$。/ 全为汉字/string pat4 = u4e00-u9fa5+|A-Za-z+$。/ 汉字或字母/string pat5 = u4e00-u9fa52,4$。/ 两到四位汉字stringpat1 =d-*9dxX$。/ 图书的 ISBN号格式 X-XXXX-XXXX-X或X-XXX-XXXXX-X( X为数字,以图书实际 ISBN号为准)stringpat2 =+.1-90-9*$。/ 正整数stringpat3 =0|1-90-9*.0-
31、92.$。/ 双精度浮点数bool m1 =Program.match this .isbntxt.Text, pat1。 bool m2 =Program.match this .numtxt.Text, pat2。 bool m3 =Program.match this .bookcosttxt.Text, pat3。if.m1可编辑资料 - - - 欢迎下载精品名师归纳总结MessageBox.Show 图书的 ISBN号格式为 X-XXXX-XXXX-X或X-XXX-XXXXX-X( X为数字,以图书实际 ISBN号为准)! , 提示! 。this .isbntxt.Text = 。r
32、eturn 。if.m2MessageBox.Show 图书购买数量应为大于 0的整数! , 提示! 。this .numtxt.Text = 。return 。if.m3MessageBox.Show 图书价格应为 XX.XX元! , 提示! 。this .bookcosttxt.Text = 。return 。intnum。num =Convert .ToInt32this .numtxt.Text。for inti = 1, k =Convert .ToInt32this .booknotxt.Text。 i = num。 i+, k+stringsql 。sql =insert int
33、o tb_bookbno,bname,bclass,bisbn,bcost,adder,adddate,bauthor,bpub,bstate,bnote+values+ k.ToString +,+this .booknametxt.Text +,+this .classtxt.Text +,+this .isbntxt.Text +,+this .bookcosttxt.Text +,+ LoginForm .uname +,+ DateTime .Now.ToString +,+this .bookwritertxt.Text +,+ this .bookpubtxt.Text +,在库
34、 ,+ this .notetxt.Text +。DataTable dt =DBHelp.ExeOleCommandsql 。MessageBox.Show 注册成功! , 恭喜! 。this .Hide。privatevoidrebtn_Clickobjectsender,EventArgs ethis .isbntxt.Clear。Clears。privatevoidClearsthis .booknametxt.Clear。/this.isbntxt.Clear。 this .bookcosttxt.Clear。this .bookwritertxt.Clear。可编辑资料 - - -
35、 欢迎下载精品名师归纳总结this .bookpubtxt.Clear。this .notetxt.Clear。 this .numtxt.Clear。privatevoidNewBook_Load objectsender,EventArgs e/*string sql。sql = select bno from tb_book order by bno asc。DataTable dt = DBHelp.ExeOleCommandsql。for int i = 0, k = 10000001。 i 1。 i+, k+for int j = 0。 j dt.Rows.Count。 j+if
36、dt.Rowsj0.ToString.Trim.Equalsk.ToString k+。this.booknotxt.Items.Addk.ToString。this.booknotxt.SelectedIndex = 0。this.classtxt.SelectedIndex = 0。*/ stringsql 。sql =select top 1 bno from tb_book order by bno desc。DataTable dt =DBHelp.ExeOleCommandsql 。intk 。for inti = 0。 i 1。 i+ifdt.Rows00.ToString =
37、可编辑资料 - - - 欢迎下载精品名师归纳总结elsek = 10000001。k =Convert .ToInt32dt.Rows00.ToString。k+。可编辑资料 - - - 欢迎下载精品名师归纳总结this .booknotxt.Items.Addk.ToString。this .booknotxt.SelectedIndex = 0。this .classtxt.SelectedIndex = 0。privatevoidfindbtn_Clickobjectsender,EventArgs e可编辑资料 - - - 欢迎下载精品名师归纳总结if this .isbntxt.Text = MessageBox.Show 请输入图书的 ISBN号! , 提示! 。return 。stringsql 。sql =select * from tb_book where bisbn=+this .isbntxt.Text + 。OleDbDataReader dr =DBHelp.OleReadersql。dr.Read