c_图书管理系统源代码大全.pdf

上传人:文*** 文档编号:88953046 上传时间:2023-05-05 格式:PDF 页数:98 大小:5.77MB
返回 下载 相关 举报
c_图书管理系统源代码大全.pdf_第1页
第1页 / 共98页
c_图书管理系统源代码大全.pdf_第2页
第2页 / 共98页
点击查看更多>>
资源描述

《c_图书管理系统源代码大全.pdf》由会员分享,可在线阅读,更多相关《c_图书管理系统源代码大全.pdf(98页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、1 .登陆界面登录界面登录用尸账号:密 码:登录I退 出主要代码:p u b l i c p a r t i a l cl a s s L o g i n F(谢:F o r m p u b l i c s t a t i c s t r i n gu a cc;p u b l i c s t a t i c s t r i n gu p s w :p u b l i c s t a t i c s t r i n gu n a m e;p u b l i c s t a t i c s t r i n gu s e x;p u b 1i c s t a t i c s t r i n gu

2、p a r t;p u b 1i c s t a t i c s t r i n gu r i g ht;p u b 1i c L o g i n F o r m()(In i t i a l i z e C o m p o n e n t 0;p r i v a t e v o i d l o g i n b t n _ C l i ck(o b j e ct s e n d e r,E v e n t A r g s e)i f (t hi s.u s e r a cct x t .Te x t .Tr i m O=*&t hi s.p s w t x t .Te x t =)M e s

3、s a g e B o x.Sho w(请输入您的用户名和密码!”,”提示!);r e t u r n;t r y(s t r i n g s q l;s q l =s e l e ct *f r o m t b _ u s e r w he r e u a cc=,u+t hi s.u s e r a cct x t.Te x t +a n du p s w=n+t hi s.p s w t x t.Te x t +Ol e D b D a t a Re a d e r d r =D B H e 1p.01e Re a d e r(s q l);d r.Re a d 0;i f (d r.H

4、 a s Ro w s)uacc=this.useracctxt.Text;upsw=this,pswtxt.Text;uname=druname.ToStr ing();u s e x =d r u s e x .To St r i n g();u p a r t =d r u p a r t I.To St r i n g();u r i g ht =d r u r i g ht .To St r i n g();M a i n F o r m a f =n e wM a i n F o r n K t hi s);t hi s.H i d e O;t hi s.u s e r a cct

5、 x t .C l e a r O;t hi s.p s w t x t .C l e a r O;a f .Sho w O;e l s eM e s s a g e B o x.Sho w C账号或密码错误!,”提示!);t hi s.u s e r a cct x t .C l e a r O;t hi s.p s w t x t .C l e a r O;t hi s.u s e r a cct x t .F o cu s O;ca t ch(E x ce p t i o n)M e s s a g e B o x.Sho w C数据库无法连接!,“警 告!”);)p r i v a t

6、 e v o i d ca n ce l b t n _ C l i ck(o b j e ct s e n d e r,E v e n t A r g s e)A p p l i ca t i o n.E x i t();p r i v a t e v o i d L o g i n F o r m _ C 1 o s i n g(o b j e ct s e n d e r,E o r m C Io s i n g E v e n t A r g s e)(A p p l i ca t i o n.E x i t();2.主界面(图较小.自己可以拉大点)所尸甘a nasi*抄-tAirw主

7、要代码就不写了,很简单。3.权限设置审 权 限设置S0用户权限设置管理权限设量用尸身份:V借书权限设置操作I 确定 最大惜书数量:I I本 超期罚款:i元/天-最长借阅时间:天 遗失赔率:倍押 金:用尸权隈一览表主要代码:p u b l i c p a r t i a l cl a s s Ri g ht Se t :F o r mp u b 1i c Ri g ht Se t 0(In i t i a l i z e C o m p o n e n t();p r i v a t e v o i d Ri g ht Se t _ L o a d(o b j e ct s e n d e r,

8、E v e n t A r g s e)(t hi s.r i g ht b o x.Se l e ct e d l n d e x =0;/t h i s.t r e e r i g ht.E x p a n d A l 1();F i l l O;p r i v a t e v o i d o k b t n _ C l i ck(o b j e ct s e n d e r,E v e n t A r g s e)(i f (t hi s.t x t n u m.Te x t =s t r i n g.E m p t y)(M e s s a g e B o x.Sho w(请输入最大借

9、阅图书数量!”提示!);r e t u r n;i f (t hi s.t x t d a y.Te x t =s t r i n g.E m p t y)(M e s s a g e B o x.Sho w(请输入最大借阅图书时间!,提示!);r e t u r n;if(this.txtcost.Text=string.Empty)M e s s a g e B o x.Sho w(请输入借书押金金额!提 示!);r e t u r n;)i f (t hi s.t x t f i n e.Te x t =s t r i n g.E m p t y)M e s s a g e B o x.

10、Sho w(请输入超期罚款金额!二”提示!);r e t u r n;i f (t hi s.t x t t i m.Te x t =s t r i n g.E m p t y)Y e s s a g e B o x.Sho w(请输入图书遗失罚款倍数!“,”提示!);r e t u r n;A r r a y L i s t a r r =n e w A r r a y!.i s t 0 ;f o r e a ch(Tr e e No d e n o d e s i n t hi s.t r e e r i g ht.No d e s)(i f (n o d e s.C he ck e d)

11、a r r.A d d CT);e l s ea r r.A d d C O);f o r e a ch(Tr e e No d e n o d e i n n o d e s.No d e s)(i f (n o d e.C he ck e d)(a n*.A d d CT);)e l s e(a r r.A d d C O);)s t r i n g a=n e w s t r i n g l l;f o r (i n t i=0;i a r r.C o u n t;i+)if(arri.ToString().Trim()=1)ai=yes;)else(a i =,no,;string s

12、ql=string.Empty;s q l +=s e l e ct *f r o m t b _ r i g ht w he r e u r i g ht=+t hi s.r i g ht b o x.Te x t +M1 M;D a t a Ta b l e d t =D B H e l p.E x e Ol e C o m m a n d(s q l);bool b=false;while(dt.Rows.Count!=0)(b =t r u e;b r e a k;string sqll;if(b)sqll=update tb_right set”;s q l l+=wm a x b

13、o o k=+t hi s.t x t n u m.Te x t +n t ii.,s q l l +=m a x d a t e=*w+t hi s.t x t d a y.Te x t+;s q l l +=r co s t=w+t hi s.t x t co s t.Te x t+n;s q l l +=r f i n e=,+t hi s.t x t f i n e.Te x tn;s q l l +=r t i m=*+t hi s.t x t t i m.Te x t+“IM;s q l l +=r b m=1 1+a 0 +s q l l+=nr u m=+a l +z n;s

14、q l l+=nr r m=,+a 2 +I”;s q l l+=nr b o r m=+a 3 +n;s q l l+=Mr i s=n+a 4 +M;s q l l+=M r b i s=n+a 5 +,n;s q l l+=Mr u i s=n+a 6 +I ”;s q l l+=r b o r i s +a 7+s q l l+=nr b l p=n+a 8 +“I”;s q l l+=”+a 9 +”Is q l l+=nr l p=,M+a 10 +1sqll+=where uright=*+this.rightbox.Textelsesqll=Minsert intotb_rig

15、ht(uright,maxbook,maxdate,rcost,rfine,rtim,rbm,rum,rrm,rborm,ris,rbis,ruis,rboris,rblp,rbl,rlp)sqll+=values(1 +this.right box.Text+z*+this,txt num.Text+this.txt day.Text+z n+t his.txtcost.Text+,*n+this.txtfine.Text+,*1 1+this,txttim.Text+-+a0+al+,-+a2+-,+a3+一+a 4+f,n+a 5+3,”+a6+n,+a7+,+a 8+,+a 9+a10

16、+D ataT able d t1=DBHelp.ExeO leCom m and(sqll);F illO ;)p riv a te v o id F i l l()(s tr in g s q l;sql=select rid as ID号,uright as 用户身份,maxbook as 最大借行数量,maxdate as 最大借阅时间,rcost a s 押金,rfine a s 超期罚率,rtim a s 遗失赔率,rbm a s 图书管理,rum a s 用户管理,rrm a s 权限管理,rborm a s 借阅管理,ris a s 信息查询,rbis a s 图书信息瓷询,r

17、uis a s 用户信息查询,rbcris a s 借阅历史查询,rblp a s 图书挂失处理,rbl a s 图/挂 失,rip a s 挂 失 处 理 from tb_rightn;DataTabl dt=DBHelp.ExeOleCommand(sql);this.dataGridViewl.DataSource=dt;)p riv a te void c e ll_ c lic k(o b je c t se n d er,D ataG ridV iew C ellE ventA rgs e)(this.rightbox.Text-this.dataGridViewl1,this.d

18、ataGridViewl.CurrentCel1.Rowindex.Value.ToString().Trim();this.txtnum.Text=this.dataGridViewl2,this.dataGridViewl.Currentcell.Rowindex.Value.ToString().Trim();this.txtday.Text=this.dataGridViewl3Zthis.dataGridViewl.Currentcell.Rowindex.Value.ToString().Trim();this.txtcost.Text=this.dataGridViewl4,th

19、is.dataGridViewl.CurrentCell.Rowindex.Value.ToString().Trim();this.txtfine.Text=this.dataGridViewl5Zthis.dataGridViewl.CurrentCell.Rowindex.Value.ToString().Trim();this.txttim.Text-this.dataGridViewl6,this.dataGridViewl.CurrentCell.Rowindex.Value.ToString().Trim();A rray L ist l i s t =new A rra y L

20、 is t();s trin g sq l=*se le c t*from tb _ rig h t where u rig h t=H+t h i s.rig h tb o x.Text+n 1;DataTable dt=DBHelp.ExeOleCommand(sql);i f (d t.Ro w s.C o u n t !=0)f o r e a chf o r (i n t i =0;i 11;i+)l i s t.A d d(d t.Ro w s 0 7+i .To St r i n g();A r r a y L i s t a r r =n e w A r r a y L i s

21、 t();(Tr e e No d e n o d e s i n t hi s.t r e e r i g ht.No d e s)(a r r.A d d(n o d e s);f o r e a ch(Tr e e No d e n o d e i n n o d e s.No d e s)a r r.A d d(n o d e);)f o r (i n t i =0;i l i s t.C o u n t;i+)(i f (l i s t i .To St r i n g O=y e s”)(Tr e e No d e)a r r i ).C he ck e d =t r u e;e

22、l s e(Tr e e No d e)a r r i ).C he ck e d =f a l s e;)4.权限修改B 用户权限修改主要代码:p u b 1i c p a r t i a l cl a s s Us e r Ri g ht :F o r mp u b 1i c Us e r Ri g ht()In i t i a l i z e C o m p o n e n t O;p r i v a t e v o i d b t n ca n ce l.C l i ck(o b j e ct s e n d e r,K v e m A r g s e)(t hi s.C l o s

23、e O;)p r i v a t e v o i d Us e r Ri g ht _ L o a d(o b j e ct s e n d e r,E v cn t;r g s e)(t hi s.che ck b o x.Se 1e c t e d In d e x =0;t hi s.p a r t b o x.Se l e ct e d In d e x =0;|p r i v a t e v o i d F i 11()i f (t hi s.che ck b o x.Te x t =)M e s s a g e B o x.Sho w(请选择要使用的查询字段!,”提示!);retu

24、rn;i f (t hi s,p a r t b o x.Te x t =*)M e s s a g e Ik)x.Sho w(M请选择用户所在的部门!“,”提示!);r e t u r n;)s t r i n g s q l =s t r i n g.E m p t y;s q l +=s e l e ct u i d a s ID号,u a cc a s 帐号,u n a m e a s 姓名,u s e x a s 性别,u p a r t a s 部H,u t e Ip ho n e a s 移动电话,u p ho n e a s 固定电话,u d a t e a s 注册日期,u

25、r i g ht a s 权限 f r o m t b _ u s e r;i f (t hi s.che ck t x t.Te x t !=(s t r i n g c=t hi s,che ck b o x.Se 1e ct e d In d e x.To St r i n g();s w i t ch(c)(ca s e 0u:用户帐号i f (t hi s.che ck t x t.Te x t !=s t r i n g.E m p t y)(s q l +=1 1 w he r e u a cc 1 汰e%+t hi s.che ck t x t .Te x t +;b r e

26、a k;ca s e ”1:/用户姓名i f (t hi s.che ck t x t.Te x t !=s t r i n g.E m p t y)s q l +=w he r e u n a m e 1 i k e +t hi s.che ck t x t.Te x t +;b r e a k;d e f a u l t-b r e a k;)i f (t hi s.p a r t l x)x.Se l e ct e d In d e x.To St r i n g O!=0)s q l +=a n d u p a r t=,+t hi s.p a r t b o x.Te x t +)e

27、 l s ei f (t hi s.p a r t b o x.Se l e ct e d In d e x.To St r i n g()!=0)sql+=where upart=+this.partbox.Text+s q l +=o r d e r b y u a cc a s c;D a t a Ta b l e d t =D B IIe l p.E x e O 1 e C o m m a n d(s q 1);t hi s.d a t a G r i d V i e w l.D a t a So u r ce =d l:p r i v a t e v o i d che ck b t

28、 n _ C 1i ck(o b j e ct s e n d e r,E v e n i A r g s e)(F i l l O;p r i v a t e v o i d ce l l _ cl i ck(o b j e ct s e n d e r,D a t a G r i d Vi e w C e 11 E v e n t A r g s e)(t hi s.t x t u a cc.Te x t =t hi s.d a t a G r i d Vi e w l l,t hi s.d a t a G r i d Vi e w l.C u r r e n t C e l 1.Ro w

29、 i n d e x .Va l u e.To St r i n g().Tr i m O;t hi s.t x t n a m e.Te x t =t hi s.d a t a G r i d Vi e w l 2,t hi s.d a t a G r i d Vi e w l.C u r r e n t C e l 1.Ro w In d e x .Va l u e.To St r i n g().Tr i m O;t hi s.t x t s e x.Te x t =t hi s.d a t a G r i d Vi e w l 3,t hi s.d a t a G r i d Vi e

30、 w l.C u r r e n t C e l 1.Ro w i n d e x .Va l u e.To St r i n g().Tr i m O;t hi s.t x t p a r t.Te x t =t hi s.d a t a G r i d Vi e w l 4,t hi s.d a t a G r i d Vi e w l.C u r r e n t C e l 1.Ro w i n d e x .Va l u e.To St r i n g().Tr i m O;t hi s.t x t t e l.Te x t =t hi s.d a t a G r i d Vi e w

31、 l 5,t hi s.d a t a G r i d Vi e w l.C u r r e n t C e l 1.Ro w i n d e x .Va l u e.To St r i n g().Tr i m O;t hi s.t x t p ho n e.Te x t =t hi s.d a t a G r i d Vi e w l 6,t hi s.d a t a G r i d Vi e w l.C u r r e n t C e l 1.Ro w i n d e x .Va l u e.To St r i n g().Tr i m O;t hi s.t x t d a t e.Te

32、 x t =t hi s.d a t a G r i d Vi e w l 7,t hi s.d a t a G r i d Vi e w l.C u r r e n t C e l 1 .Ro w i n d e x .Va l u e.To St r i n g O.Tr i m O;t hi s.t x t r i g ht.Te x t =t hi s.d a t a G r i d Vi e w l 8,t hi s.d a t a G r i d Vi e w l.C u r r e n t C e l 1.Ro w I n d e x .Va l u e.To St r i n

33、g().Tr i m O;t hi s.t x t r i g ht.E n a b l e d =t r u e;p r i v a t e v o i d b t n cha n g e _ C l i ck(o b j e ct s e n d e r,E v e n t A r g s e)(i f (t hi s.t x t u a cc.Te x t =M e s s a g e B o x.Sho w C执行操作前,请先在下表选择要修改的用户!“,”提示!);r e t u r n;DialogResult res;r e s=M e s s a g e B o x.Sho w(

34、您确定要修改该用户吗?,提示!,M e s s a g e B o x B u t t o n s.Y e s No);i f (r e s =D i a l o g Re s u l t.Y e s)(s t r i n g s q l =s t r i n g.E m p t y;s q l +=*u p d a t e t b _ u s e r s e t u r i g ht=,+t hi s.t x t r i g ht .Te x t+s q l +=w he r e u a cc=l+t hi s.t x t u a cc.Te x t+,n;D a t a Ta b l e

35、d t =OB I Ie Ip.E x e Ol e C o m m a n d(s q l);M e s s a g e B o x.Sho w(修改成功!”恭喜!);F i l K);)5.添加图书信息主要代码:p u b 1i c p a r t i a l cl a s s Ne w B o o k :F o r mp u b 1i c Ne w B o o k()In i t i a l i z e C o m p o n e n t 0;p r i v a t e v o i d r e t b t n _ C l i ck C o b j e ct s e n d e r,E v

36、 e n t A r g s e)t hi s.H i d e O;p r i v a t e v o i d s a v e b t n _ C l i ck(o b j e ct s e n d e r,E v e n t A r g s e)i f (t hi s.b o o k n o t x t.Te x t =)(M e s s a g e B o x.Sho w(H请输入图书的信息!,提示!);r e t u r n;)i f (t hi s.b o o k n a m e t x t.Te x t =)(M e s s a g e B o x.Sho w C请输入图书的信息!”

37、,提 示!);r e t u r n;)i f (t hi s.cl a s s t x t.Te x t =(M e s s a g e B o x.Sho w(请 输入图书的信息!”,提示!);r e t u r n;i f (t hi s.i s b n t x t.Te x t =)(M e s s a g e l x.Sho w C请输入图村的信息!二”提小!);r e t u r n;i f (t hi s,b o o k co s t t x t .Te x t =*)M e s s a g e B o x.Sho w(“请输入图书的信息!”,”提示!);r e t u r n;

38、i f (t hi s.b o o k w r i t e r t x t.Te x t =(M e s s a g e B o x.Sho w(请输入图书的信息!”,”提 示!);r e t u r n;)i f (t hi s.b o o k p u b t x t.Te x t =)M e s s a g e B o x.Sho w(请输入图书的信息!“,”提示!);r e t u r n;i f (t hi s.n u m t x t.Te x t =M cs s a g cI o x.Sho w C请输入图书的信息!提示!);r e t u r n;)i f (t hi s.n o

39、t e t x t.Te x t =M e s s a g e B o x.Sho w(请输入图书的信息!”,”提 示!);r e t u r n;/s t r i n g p a t 3=”W u 4e 00-W u 9f a 5+$”;全为汉字/s t r i n g p a t 4=”人(加4e 00Tu 9f a 5 +|A-Z a-z +)$”;汉字或字母/s t r i n g p a t 5=”W u 4e O(H Y u 9f a 5 2,4$”;两到四位汉字s t r i n g p a t l =,/s(W d -*)9 W d x X$n;图书的ISB N号格式X-X X

40、 X X-X X X X-X或X-X X X-X X X X X-X (X为数字,以图书实际ISB N号为准)s t r i n g p a t 2=八科?1-9 0-9*$;正整数s t r i n g p a t 3=,/s(0|1-9 0-9*)(.O9 2)?$M;双精度浮点数b o o l ml=Pro gra m.ma t c h(t his.isb nt x t.Tex t,pa t l);b o o lm2=Pro gra m.ma t c h(t his.nu mt x t .Tex t,pa ;b o o l m3=Pro gra m.ma t c h(t his,b o

41、o kc o st t x t .Tex t,pa t 3);if(!ml)Messa geB o x.Sho w C 图书的ISB N号格 弋为X-XXXX-XXXXT或X-XXX-XXXXX-X(X为数字,以图书实际ISB N号为准)!,提示!);t his.isb nt x t.Tex tret u rn;if(!m2)Messa geB o x.Sho w(图书购买数量应为大于0的整数!,”提示!);t his.nu mt x t.Tex t =;ret u rn;if(!m3)Messa geB o x.Sho w C图书价格应为XX.XX元!“,”提示!);t his.b o o

42、kc o st t x t.Tex t =;ret u rn;int mini;nu m=C o nv ert.To lnt 32(t his.nu mt x t.Tex t);for(int i=1,k=Convert.Tolnt32(this.booknotxt.Text);i=num;i+,k+)string sql;sql=insert int ot b _ b o o k(b no,b na me,b e la ss,b isb n,b c o sI,a dder.a ddda t e,b a u t ho r,b pu b.b st a t e,b no t e)n+v a lu

43、es。+k.To St r ing()+t his,b o o kna met x t.Tex t +*,+t his.c la sst x t.Tex t +,r+t his.isb nt x t.Tex t +t his.b o o kc o st t x t.Tex t +Lo ginFo rm.u na me+1,n+D a t eTime.No w.To St r i ng()+t his.b o o kw r i t er t x t.Tex t +t his,b o o kpu b t x t .Tex t +在库+t his,no t et x t .Tex t +);D a

44、t a Ta b le dt =D B H e1 p.E x eO1 eC o mma nd(sql);)Messa geB o x.Sho w(M 注册成功!恭喜!”);t his.H ideO;)priv a t e v o id reb t n_ C lic k(o b jec t sender,E v ent A rgs e)t his.isb nt x t.C lea rO;C lea rsO;priv a t e v o id C lea rs()(t his.b o o kna met x t.C lea r();/t his.isb nt x t .C lea rO;t his

45、.b o o kc o st t x t.C lea r();t his.b o o kw r it ert x t .C lea rO;t his.b o o kpu b t x t .C lea rO;t his.no t et x t.C lea rO;t his.nu nit x t .C lea r();)priv a t e v o id New B o o kJ x)a d(o b jec t sender,E v ent?rgs e)(/*st ring sql;sql=Hselec t b no fro m t b _ b o o k o rder b y b noa sc;

46、D a t a Ta b le dt =D B H e1 p.E x eO1 eC o mma nd(sql);fo r(int i =0,k=1 0 0 0 0 0 0 1;i 1;i+,k+)fo r(int j=0;j dt.R o w s.C o u nt:j+)if(dt.Rowsj0.ToStringO.TrimO.Equals(k.ToStringO)k+;t his.b o o kno t x t.It erns.A dd(k.To St r i ng();t hi s.b o o kno t x t.Selec t edlndex =0;t his.c la sst x t.

47、Selec t edlndex =0;*/st ring sql;sql=selec t t o p 1 b no fro m t b.b o o k o rder b y b no desc;D a t a Ta b le dt =D B H elp.E x eO1 eC o mma ndC sql);int k;fo r(int i =0;i 1;i+)i f(dt.R o w s0 0.To St r ing()k=1 0 0 0 0 0 0 1;elsek=C o nv ert.To lnt 32(dt.R o w s0 0.To St ring();k+;t his.b o o kn

48、o t x t.It ems.A dc K k.To St ringO);t hi s.b o o kno t x t.Selec t edlndex =0;t his.c la sst x t.Selec t edlndex =0;priv a t e v o id findb t n_ C lic k(o b jec t sender,E v ent A rgs e)(if(t his.isb nt x t.Tex t =)(Messa geB o x.Sho w(请输入图书的ISB N号!,”提示!);ret u rn;)st ring sql;sql=selec t *fro m t

49、b _ b o o k w here b isb n=,*+t his,isb nt x t .Tex t +OleD b D a t a R ea der dr=D B Ilelp.0 1 eR ea der(sq 1);dr.R ea dO;i f(dr J la sR o w s)t h is.b o o kna met x t.Tex t =drb na me.To St r i ng().Tr i m();t his.c la sst x t.Tex t =drb e la ss.To St ring().Trim();t his,b o o kc o st t x t .Tex t

50、 =dr Hb c o stH .To St r ing().TrimO;t his.b o o kw rit ert x t .Tex t =drb a u t ho rH .To St ringO.TrimO;t his,b o o kpu b t x t.Tex t =dr b pu b .To St r ing().TrimO;t his.no t et x t.Tex t =drb no t e.To St ring().TrimO;Messa gelB o x.Sho w C找到匹配图书信息,自动填充基本信息,请填充余下信息!“,”提示!);t his.nu mt x t.E na

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

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

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

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁