c#图书管理系统源代码.docx

上传人:无*** 文档编号:68365756 上传时间:2022-12-27 格式:DOCX 页数:103 大小:69.73KB
返回 下载 相关 举报
c#图书管理系统源代码.docx_第1页
第1页 / 共103页
c#图书管理系统源代码.docx_第2页
第2页 / 共103页
点击查看更多>>
资源描述

《c#图书管理系统源代码.docx》由会员分享,可在线阅读,更多相关《c#图书管理系统源代码.docx(103页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、主要代码:pub 1ic partialclass :nl-orm : l-onn publicstaticstring uacc;publicstaticstring upsw;publicstaticstring uname;publicstaticstring usex;publicstaticstring upart;publi cstaticstring uright;public LoginFormOInitializeComponent();1.登陆界面private void loginbtn Click (object sender, EvcntArgs e)if (this

2、, useracctxt. Text. TrimO & this, pswtxt. Text =return;try(string sql;sql = select * from tb user where uacc=, + this, useracctxt. Text + and upsw=,+ this, pswtxt. Text +;OleDbDatdReader dr = DBIIelp. OleReader(sql);dr. Read 0 ;if (dr. HasRows)(uacc = this.useracctxt. Text;upsw = this.pswtxt. Text;u

3、name = druname. ToStringO ;usex = drusex. ToStringO ;upart = drupart. ToStringO ;uright = dr*uright*. ToStringO ;MainForm af = new MainForm(this);this. Hide();this, useracctxt. Clear 0;this, pswtxt. Clear();af. Show ();)else(MessageBox.Show (“账号或密码错误!提示!);this. useracctxt. Clear ();this, pswtxt. Cle

4、ar ();this, useracctxt. Focus 0;)catch (Except ion)(VessageBox. Show (数据库无法连接!,警告!”);)private void cancelbtn_Click(object sender, EventArgs e)(Application. Exit();private void LoginForm_Closing(object sender, l;orm(JosingEventArgs e)Appli ceil ion. Exit ();)2 .主界面(图较小,自己可以拉大点)主要代码就不写了,很简单。3 .权限设置主要代

5、码:public partial class RightSet : Formpublic RightSet0(InitializeComponent();)e)private void RightSet_Load(object sender,(this, rightbox. Selectedlndex = 0;/this, treeright. ExpandAl 1 ();FillO;private void okbtn_Click(object sender, EventArgs e)if (this, txtnum. Text = string. Empty)MessageBox.Show

6、(请输入最大借阅图书数量!”,提示!”); 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)McssageBox.Show(请输入超期罚款金额!,”提示!); return;if (this, txttim. Textstr

7、ing. Empty)MessageBox.Show(请输入图书遗失罚款倍数!,”提示!;return;I i st arr = new0 ;foreach (TreeXode nodes in this.treeright. Nodes)if (nodes. Checked)arr. Add(l);elsearr. Add(0);foreach(TreeNode node in nodes. Nodes)i f (node. Checked)arr. Add (1);elsearr. Add (0”);string a=new stringl1;for (int i = 0; i arr.

8、Count; i+)if (arri. ToStringO. TrimO = T)ai = yes”;elseai = nostring sql = string. Empty:sql += select * from tb_right where urighl=+ this, rightbox. Text +DataTable dt = DBHeIp. ExeOleCommand(sql): bool b = false;while (dt. Rows. Count != 0)b = true;break;string sqll;if (b)sql1 = update tb_right se

9、t ;sql1+=maxbook=+ thi s. txtnum.Text +sql1+=maxdate=+ this, txtday. Text +sql 1+=rcost=+this, txtcost. Text +sql 1+=*rfine=,*+this, txtfine. Text +sqll += *rtim=+ this, txttim. Text +sqll += rbm=+ a0 + sqll += rum= + al +sqll += rrm=, + a2 +sqll += rborm= + a3sqll += ris=+ a4 +sqll += rbis=,* + a5

10、+ *,;sqll += ruis=, + a6 + ,:sqll += *rboris=* * + a7 +sqll += rblp= + a8sqll += rbl= + a 9 +sqll += rip=+ a10 +;sqll +二where uright= + this.rightbox. Text +;)else(sql! 二 insert intotb_right (uright, raaxbook, maxdate, rcost, rfine, rtim, rbm, rum, rrm, rborm, ris, rbis, ruis, rboris, rblp ,rbl,rlp)

11、;sqll + 二values( + this, rightbox. Text +,+ this, txtnum. Text +,+this, txtday. Text + *, * + this, txtcost. Text + *, + this, txtfine. Text + +this, txttim. Text +a0+ al+ a2a3 + + a4 + a5+ a6+ a7+ a8a9+ a10 + )DataTable dtl = DBHelp. ExeOleCommand(sqll);FillO;private void Fill ()string sql;sql = se

12、lect rid as ID 号,uright as 用户身份,max book as 最大借书数鼠,maxdate as 最大借阅时间,rcost as押金,rfineas超期罚率,rtim as遗失赔率,rbm as图书管理,rum as用户管理,门m as权限管理,rborm as借阅管理,ris as信息查询,rbis as图书信息查询,ruis as用户信息查询,rborisas借阅历史査询,rblp as图书挂失处理,rbl as图书挂失,rip as挂失处理from tb_right*;DataTable dt = DBHe1p. ExeOleCommand(sql);this.

13、 dataGridViewl. DataSource = dt;private void cell_click(object sender, DataGridViewCe11EventArgs e)this, rightbox. Text = this. dataGridViewl 1, this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;this, txtnum. Text = this. dataGridViewl2,this. dataGridViewl. CurrentCel 1. Rowindex

14、. Value. ToStringO. TrimO ;this, txtday.Text = this. dataGridViewl3,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;this, txtcost. Text = this. dataGridViewl4,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;this, txtfine. Text = this. dataGridViewl5,this.

15、dataGridViewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;this, txttim. Text = this. dataGridViewl6,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;ArrayList list = new ArrayList();string sql = select * from tb_right where uright二 + this, rightbox. Text +DataTable dt = DB

16、Help. ExeOleConunand(sql);if (dt. Rows. Count != 0)for (int i = 0; i 11; i+)1 ist. Add(dt. Rows0 7+i. ToStringO);ArrayList arr = new ArrayLi st ();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+)

17、if (listi. ToStringO = yes)(T)(?eNode)arri). Checked = true;else(TreeNode)arri). Checked = false;4 .权限修改主要代码:public partial class UserRight : Form(public UserRight0(InitializeComponent();private void btncancel_Click(object sender, EventArgs e)(this. CloseO;)private void UserRight Load(object sender,

18、 EventArgs e)(thi s.checkbox. Seiectedlndex = 0;this, partbox. Selectedlndex = 0;private void Fill ()if (this, checkbox. Text =VcssageBox. Show(请选择要使用的査询字段!”,提示!”); return;if (this, part box. Text =)MessageBox.Show(请选择用户所在的部门!,提示!”); return;string sql = string. Empty;sql += sei ect ui d as 11) uacc

19、as 帐号,unamc as 姓名,usex as 性别,upart as 部f J, uteIphone as 移动电话,uphone as 固定电话,udate as 注册 II 期,uright as 权限 from tb user;if (this, checktxt. Text !=)string c = this, checkbox. Selectedlndex. ToStringO ;switch (c)(case ”:用户帐号if (this, checktxt. Text != string. Empty)(sql += where uacc 1 ike * % + this

20、, checktxt. Text + %;)break;case 1:用户姓名if (this, checktxt. Text != string. Empty)(sql += where uname like * % + this.checktxt. Text + %* *)break;default:break;if (this, partbox. Selectedlndex. ToStringO != 0)sql += and upart=+ this, partbox. Text + )else(if (this, partbox. Selected Index. ToStringO

21、!= 0)(sql += where upart=+ thi s. partbox. Text +)sql += order by uacc asc;DataTable dt = DBHelp. ExeOleCommand(sql);this. dataGridViewl. DataSource = dt;pri vate voi d checkbtn_Click (object sender, Invent Args e)FillO;private void cel l_c lick (object sender, Da t tiGi, i dV i ewCe 11 E ent A s e)

22、this, txtuacc. Text = this. dataGridViewll, this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToString(). TrimO ;this, txtname. Text = this. dataGridViewl2,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToString(). TrimO ;this, txtsex. Text = this. dataGridViewl 3,this. dataGridViewl. Current

23、Cel 1. Rowindex. Value. ToString(). TrimO ;this, txtpart. Text = this. dataGridViewl4,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToString(). TrimO ;this, txttel. Text = this. dataGridViewl 5,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToString(). TrimO ;this, txtphone. Text = this.

24、dataGridViewl 6,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToString0. TrimO ;this, txtdate. Text = this. dataGridViewl7,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToString(). TrimO ;this, txtright. Text = this. dataGridViewl 8, this. dataGridViewl. CurrentCel 1. Rowindex. Value. To

25、StringO. TrimO ;this, txtright.Enabled = true;if (this, txtuacc. Text =MessageBox. Show(执行操作前,请先在下表选择要修改的用户!* 提示!”);return;DialogResult res;res二山Show(您确定要修改该用丿、吗?,提小!,.iif (res = DialogResult.Yes)(string sql = string. Empty;sql +=update tb_user set uright= +this. txtright. Text+ ;sql += * where uacc

26、二+this. txtuacc. Text+ ;DcitaTable dt = DBHelp. ExeOleCommand (sql);Mes sage Box. Show (修改成功!,恭喜!);FillO;5 .添加图书信息主要代码:public partial class NewBook : Formpublic NewBook()InitializeComponent();private void retbtn Click (object sender, EventArgs e)this. Hide ();private void savebtn_Click(object sender

27、, EventArgs e)if (this, booknotxt. Text =)MessageBox.Show(请输入图书的信息! ”,提示!);return;if (this, bookname txt. Text =(MessageBox. Show(请输入图书的信息!”,提示!); return;if (this, classtxt. Text =)(MessageBox. Show(请输入图书的信息!,提示!); return;if (this, isbntxt. Text = (MessageBox. Show (请输入图书的信息!,提示!); return;)if (this,

28、 bookcosttxt. Text )(MessageBox. Show(请输入图书的信息!,提示!); return; if (this, bookwritertxt. Text =)MessagcBox. Show (请输入图书的信息!,提示!;return:)if (this, bookpubtxt. Text =)(MessageBox. Show (请输入图书的信息!”,提示!); return;if (this, numtxt. Text =)(MessagcBox. Show(请输入图书的信息!,提示!”); return:)if (this, notetxt. Text =)

29、(MessageBox. Show(请输入图书的信息!,提示!); return;/string pat3 =u4e00-u9fa5+$” ;/全为汉字/string pat4 =(u4e00-u9fa5+ A-Za-z+)$”;汉字或字母/string pat5 =u4e00-u9fa5 2, 4 $”;两到四位汉字string patl =(d-*) 9 dxX$”;图书的ISBN号格式X-XXXX-XXXX-X或X-XH-XXXH-X (X为数字,以图书实际ISBN号为准)string pat2 =+?1-9 9*$”;正整数string pat3 = (0 1-9 0-9*) (. 0

30、-9 2)?$”;双精度浮点数bool ml = Program, match (this, isbntxt. Text, patl);bool m2 = Progriun. match (this, numtxt. Text, pat2);bool m3 = Program, match (this, book cost txt. Text, pat3);if (!ml)(McssageBcx.Show(图的ISBN号格式为X-XXXX-XXXX-X或X-XXX-XXXXX-X (X为数字,以 图书实际ISBN号为准)!,提示!”);this, isbntxt. Text = *;retur

31、n;)if (!m2)MessageBox.Show(图书购买数量应为大于的整数!,提示!);this, numtxt. Text return;if (!m3)MessageBox. Show (图书价格应为 XX. XX 元!”,提示!”);this, bookcosttxt. Text = return;int num;num = Convert. Tolnt32(this, numtxt. Text);for (int i = 1, k = Convert. Tolnt32 (this, booknotxt. Text); i = num; i+, k+)string sql;sql

32、= insert intotb_book (bno, bname, bclass, bisbn, bcost, adder, adddate, bauthor, bpub, bstate, bnote)”+ values (* * + k. ToString0 +,+ this, booknametxt. Text + +this, classtxt. Text + ,+ this, isbntxt. Text +,+ this, bookcosttxt. Text +,+Log in Form, uname +,+ Dat eTime. Now. ToString () +,+ this,

33、bookwritertxt. Text +this, bookpubtxt. Text + ,在库,+ thi s. notetxt. Text + );L,dt = DBIIc I p. ExeOleCommand (sql);MessageBox.Show (注册成功!,“恭喜! );this. Hide();private void rebtn_Click(object sender, EventArgs e)this, isbntxt. Clear0 ;Clears ();private void Clears 0thi s. book name txt. Cl ear ();/thi

34、s, isbntxt. ClearO ;this, bookcosttxt. ClearO ;this. bookwritertxt. ClearO ;this, bookpubtxt. Clear 0;this, notetxt. ClearO;thi s. numtxt. Clear ();private void NewBook Load(object sender, EventArgs e)/*string sql;sql = select bno from tbbook order by bno asc;DataTable dt = DBHelp. ExeOleCommand(sql

35、);for (int i = 0, k = 10000001; i 1; i+, k+)(for (int j = 0; j dt. Rows. Count; j+)(if (dt. Rowstj 0. ToStringO. Trim(). Equals(k. ToStringO) k+;)this, booknotxt. Items. Add(k. ToStringO);this, booknotxt. Selectedlndex = 0;this, classtxt. Selectedlndex = 0;string sql;sql = select top 1 bno from tb b

36、ook order by bno desc;DataTable dt = DBHelp. ExeOleCommand(sql);int k;for (int i = 0; i 1; i+)if (dt. Rows 0 0. ToStringO = *)(k = 10000001;else(k = Convert. Tolnt32 (dt. Rows 0 0. ToString();k+;)this, booknotxt. Items. Add(k. ToStringO);this, booknotxt. Selectedlndex = 0;this, classtxt. SelectedInd

37、ex = 0;private void findbtn_Click(object sender, EventArgs e)if (this, isbntxt. Text =MessageBox.Show请输入图书的:SBN号!”,提示!);return;string sql;sql = select * from tb_book where bisbn=, + this, isbntxt. Text +OleDbDataReader dr = DBHelp. OleReader(sql);dr. Read 0 ;i f (dr. HasRows)this, bookname txt. Text

38、 = dr*bname. ToStringO. Trim();thi s. classtxt. Text = dr be lass. ToStringO. TrimO ;this, bookcosttxt. Text = dr*bcost. ToStringO. TrimO ;this, bookwritertxt. Text = drbauthor. ToStringO. TrimO ;this. bookpubtxt. Text = drbpub. ToStringO. TrimO ;this, notetxt. Text = dr*bnote. ToStringO. TrimO ;eB

39、.Show(找到匹配闇行信息,自动填充基本信息,请填充余卜信息! ”,提示!;this, numtxt. Enabled = true;else(ClearsO;MessageBox. Show (未找到匹配图书信息!”,提示!);this, booknotxt. Enabled = true;this, bookname txt. Enabled = true;this, classtxt. Enabled = true;this, bookcosttxt. Enabled = true;this, bookwritertxt. Enabled = true;this, bookpubtxt

40、.Enabled = true;this, numtxt. Enabled = true;this, notetxt. Enabled = true;6 .图书信息管理主要代码:public partial class BookManage : Formpublic BookManage()InitializeComponent();string bookisbn;private void BookManage Load(object sender, EventArgs e)this, checkbox. Selectedlndex = 0;this, classbox. Selectedln

41、dex = 0;private void checkbtn_Click (object sender, liventArgs e)FillGridO;private void cel l_c lick (object sender, Da t tiGi, i dV i ewCe 11 E ent A s e)FilllnfoO;private void nobtn_Click(object sender, EventArgs e)this. CloseO;private void okbtn_Click(object sender, EventArgs e)if (this, nametxt.

42、 Text = string. Empty)MessageBox.Show(执行操作前,请先选择图书! 提示!;return;修改同ISBN图书信息string sql2= string. Empty;sql2 += update tb book set bisbn:+ this.isbntxt.Text +,bname=十this, nametxt. Text + *, bclass=, * + this, classtxt. Text + *, bcost=* + this, costtxt. Text + ”,baulhor =+ this, writertxt. Text +, bpu

43、b二+ this, pubtxt. Text +, adder=+this, addertxt. Text +, bnote= + this, notetxt. Text +sql2 += where bisbn二+ this.bookisbn +DataTable dt2 = DBHelp. Exe01eCommand(sql2);string sql5 = string. Empty;sql5 += update tb borrow set bname= + this, nametxt. Text +, bisbn =+this, isbntxt.zText +;sql5 += where

44、 bisbn:+ this, bookisbn + *DataTable dt5 = DBHelp. Exe01eCommand(sql5);MessageBox.Show(该类图书信息修改成功!,提示!);this, checktxt. Text 二 ;FillGridO;FilllnfoO;pri vate void Fi UGridOif (this, checkbox. Text = string. Empty)MessageBox.Show(请输入你要使用的检索条件!”,提示!”); return;if (this, classbox. Text = string. Empty)MessageBox.Show(请输入你要查找的图书类型!,提示!”); return;string sql = string. Empty;sql += select bid as ID号,bno as 图书编号,bname as 图书名称,bauthor as 作者, bclass as 类别,bi sbn as ISBN号,bcost

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com