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

上传人:qwe****56 文档编号:71061213 上传时间:2023-01-31 格式:PDF 页数:59 大小:436.20KB
返回 下载 相关 举报
c#图书管理系统源代码大全.pdf_第1页
第1页 / 共59页
c#图书管理系统源代码大全.pdf_第2页
第2页 / 共59页
点击查看更多>>
资源描述

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

1、1.登陆界面主要代码:public partial class LoginForm:Formpublic 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)

2、if(this.useracctxt.Text.Trim()=&this.pswtxt.Text=)MessageBox.Show(请输入您的用户名和密码!,提示!);return;trystring 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.Te

3、xt;uname=druname.ToString();usex=drusex.ToString();upart=drupart.ToString();uright=druright.ToString();MainForm af=new MainForm(this);this.Hide();this.useracctxt.Clear();this.pswtxt.Clear();af.Show();elseMessageBox.Show(账号或密码错误!,提示!);this.useracctxt.Clear();this.pswtxt.Clear();this.useracctxt.Focus(

4、);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:Formpublic RightSet

5、()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)

6、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(T

7、reeNode nodes in this.treeright.Nodes)if(nodes.Checked)arr.Add(1);elsearr.Add(0);foreach(TreeNode node in nodes.Nodes)if(node.Checked)arr.Add(1);elsearr.Add(0);string a=new string11;for(int i=0;i arr.Count;i+)if(arri.ToString().Trim()=1)ai=yes;elseai=no;string sql=string.Empty;sql+=select*from tb_ri

8、ght 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+

9、,;sql1+=rtim=+this.txttim.Text+,;sql1+=rbm=+a0+,;sql1+=rum=+a1+,;sql1+=rrm=+a2+,;sql1+=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 intotb_right(uright,maxbook

10、,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+,+a9+,+a10+);DataTable dt1=DBHelp.ExeOleComman

11、d(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

12、挂失处理 from tb_right;DataTable dt=DBHelp.ExeOleCommand(sql);this.dataGridView1.DataSource=dt;private void cell_click(object sender,DataGridViewCellEventArgs e)this.rightbox.Text=this.dataGridView11,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.txtnum.Text=this.dataGridView12,thi

13、s.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.RowIndex.Value.ToString().Trim();this.txtfine.Text=this.dataGridView1

14、5,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.txttim.Text=this.dataGridView16,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(sq

15、l);if(dt.Rows.Count!=0)for(int i=0;i 11;i+)list.Add(dt.Rows07+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(listi.ToString()=yes)(TreeNode)arri).Checked=true;e

16、lse(TreeNode)arri).Checked=false;4.权限修改主要代码:public partial class UserRight:Formpublic 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;

17、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 权限 fr

18、om 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

19、;if(this.partbox.SelectedIndex.ToString()!=0)sql+=and upart=+this.partbox.Text+;elseif(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 sende

20、r,EventArgs e)Fill();private void cell_click(object sender,DataGridViewCellEventArgs e)this.txtuacc.Text=this.dataGridView11,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.txtname.Text=this.dataGridView12,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.txts

21、ex.Text=this.dataGridView13,this.dataGridView1.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.

22、txtphone.Text=this.dataGridView16,this.dataGridView1.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

23、();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_use

24、r set uright=+this.txtright.Text+;sql+=where uacc=+this.txtuacc.Text+;DataTable dt=DBHelp.ExeOleCommand(sql);MessageBox.Show(修改成功!,恭喜!);Fill();5.添加图书信息主要代码:public partial class NewBook:Formpublic NewBook()InitializeComponent();private void retbtn_Click(object sender,EventArgs e)this.Hide();private v

25、oid 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.b

26、ookcosttxt.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.Text=)MessageBox.Show(请输入图书的信息!,提示!);retu

27、rn;/string pat3=u4e00-u9fa5+$;/全为汉字/string pat4=(u4e00-u9fa5+|A-Za-z+)$;/汉字或字母/string pat5=u4e00-u9fa52,4$;/两到四位汉字string pat1=(d-*)9dxX$;/图书的ISBN号格式X-XXXX-XXXX-X或X-XXX-XXXXX-X(X为数字,以图书实际ISBN号为准)string pat2=+?1-90-9*$;/正整数string pat3=(0|1-90-9*)(.0-92)?$;/双精度浮点数bool m1=Program.match(this.isbntxt.Text

28、,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=;return;if(!m2)MessageBox.Show(图书购买数量应为大于0的整数!,提示!);this.numtxt.Text=;return;if(!m3)MessageBo

29、x.Show(图书价格应为XX.XX元!,提示!);this.bookcosttxt.Text=;return;int num;num=Convert.ToInt32(this.numtxt.Text);for(int i=1,k=Convert.ToInt32(this.booknotxt.Text);i=num;i+,k+)string sql;sql=insert intotb_book(bno,bname,bclass,bisbn,bcost,adder,adddate,bauthor,bpub,bstate,bnote)+values(+k.ToString()+,+this.boo

30、knametxt.Text+,+this.classtxt.Text+,+this.isbntxt.Text+,+this.bookcosttxt.Text+,+LoginForm.uname+,+DateTime.Now.ToString()+,+this.bookwritertxt.Text+,+this.bookpubtxt.Text+,在库,+this.notetxt.Text+);DataTable dt=DBHelp.ExeOleCommand(sql);MessageBox.Show(注册成功!,恭喜!);this.Hide();private void rebtn_Click(

31、object sender,EventArgs e)this.isbntxt.Clear();Clears();private void Clears()this.booknametxt.Clear();/this.isbntxt.Clear();this.bookcosttxt.Clear();this.bookwritertxt.Clear();this.bookpubtxt.Clear();this.notetxt.Clear();this.numtxt.Clear();private void NewBook_Load(object sender,EventArgs e)/*strin

32、g sql;sql=select bno from tb_book order by bno asc;DataTable dt=DBHelp.ExeOleCommand(sql);for(int i=0,k=10000001;i 1;i+,k+)for(int j=0;j dt.Rows.Count;j+)if(dt.Rowsj0.ToString().Trim().Equals(k.ToString()k+;this.booknotxt.Items.Add(k.ToString();this.booknotxt.SelectedIndex=0;this.classtxt.SelectedIn

33、dex=0;*/string sql;sql=select top 1 bno from tb_book order by bno desc;DataTable dt=DBHelp.ExeOleCommand(sql);int k;for(int i=0;i 1;i+)if(dt.Rows00.ToString()=)k=10000001;elsek=Convert.ToInt32(dt.Rows00.ToString();k+;this.booknotxt.Items.Add(k.ToString();this.booknotxt.SelectedIndex=0;this.classtxt.

34、SelectedIndex=0;private void findbtn_Click(object sender,EventArgs e)if(this.isbntxt.Text=)MessageBox.Show(请输入图书的ISBN号!,提示!);return;string sql;sql=select*from tb_book where bisbn=+this.isbntxt.Text+;OleDbDataReader dr=DBHelp.OleReader(sql);dr.Read();if(dr.HasRows)this.booknametxt.Text=drbname.ToStri

35、ng().Trim();this.classtxt.Text=drbclass.ToString().Trim();this.bookcosttxt.Text=drbcost.ToString().Trim();this.bookwritertxt.Text=drbauthor.ToString().Trim();this.bookpubtxt.Text=drbpub.ToString().Trim();this.notetxt.Text=drbnote.ToString().Trim();MessageBox.Show(找到匹配图书信息,自动填充基本信息,请填充余下信息!,提示!);this

36、.numtxt.Enabled=true;elseClears();MessageBox.Show(未找到匹配图书信息!,提示!);this.booknotxt.Enabled=true;this.booknametxt.Enabled=true;this.classtxt.Enabled=true;this.bookcosttxt.Enabled=true;this.bookwritertxt.Enabled=true;this.bookpubtxt.Enabled=true;this.numtxt.Enabled=true;this.notetxt.Enabled=true;6.图书信息管

37、理主要代码:public partial class BookManage:Formpublic BookManage()InitializeComponent();string bookisbn;private void BookManage_Load(object sender,EventArgs e)this.checkbox.SelectedIndex=0;this.classbox.SelectedIndex=0;private void checkbtn_Click(object sender,EventArgs e)FillGrid();private void cell_cli

38、ck(object sender,DataGridViewCellEventArgs e)FillInfo();private void nobtn_Click(object sender,EventArgs e)this.Close();private void okbtn_Click(object sender,EventArgs e)if(this.nametxt.Text=string.Empty)MessageBox.Show(执行操作前,请先选择图书!,提示!);return;/修改同ISBN图书信息string sql2=string.Empty;sql2+=update tb_

39、book set bisbn=+this.isbntxt.Text+,bname=+this.nametxt.Text+,bclass=+this.classtxt.Text+,bcost=+this.costtxt.Text+,bauthor=+this.writertxt.Text+,bpub=+this.pubtxt.Text+,adder=+this.addertxt.Text+,bnote=+this.notetxt.Text+;sql2+=where bisbn=+this.bookisbn+;DataTable dt2=DBHelp.ExeOleCommand(sql2);str

40、ing sql5=string.Empty;sql5+=update tb_borrow set bname=+this.nametxt.Text+,bisbn=+this.isbntxt.Text+;sql5+=where bisbn=+this.bookisbn+;DataTable dt5=DBHelp.ExeOleCommand(sql5);MessageBox.Show(该类图书信息修改成功!,提示!);this.checktxt.Text=;FillGrid();FillInfo();private void FillGrid()if(this.checkbox.Text=stri

41、ng.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 类别,bisbn as ISBN号,bcost as 价格,bpub as 出版社,adder as 记录员,adddate as 入库日期,bnot

42、e as 内容简介,bstate as 状态 from tb_book;if(this.checktxt.Text!=)string c=this.checkbox.SelectedIndex.ToString();switch(c)case 0:/图书名称if(this.checktxt.Text!=string.Empty)sql+=where bname like%+this.checktxt.Text+%;break;case 1:/图书编号if(this.checktxt.Text!=string.Empty)sql+=where bno like%+this.checktxt.Te

43、xt+%;break;case 2:/作者if(this.checktxt.Text!=string.Empty)sql+=where bauthor like%+this.checktxt.Text+%;break;case 3:/isbn号if(this.checktxt.Text!=string.Empty)sql+=where bisbn like%+this.checktxt.Text+%;break;case 4:/出版社if(this.checktxt.Text!=string.Empty)sql+=where bpub like%+this.checktxt.Text+%;br

44、eak;default:break;if(this.classbox.SelectedIndex.ToString()!=0)sql+=and bclass=+this.classbox.Text+;elseif(this.classbox.SelectedIndex.ToString()!=0)sql+=where bclass=+this.classbox.Text+;sql+=order by bno asc;DataTable dt=DBHelp.ExeOleCommand(sql);this.dataGridView1.DataSource=dt;private void FillI

45、nfo()this.label3.Text=this.dataGridView11,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.isbntxt.Text=this.dataGridView15,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.nametxt.Text=this.dataGridView12,this.dataGridView1.CurrentCell.RowIndex.Value.ToString

46、().Trim();this.classtxt.Text=this.dataGridView14,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.costtxt.Text=this.dataGridView16,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.writertxt.Text=this.dataGridView13,this.dataGridView1.CurrentCell.RowIndex.Value

47、.ToString().Trim();this.pubtxt.Text=this.dataGridView17,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.addertxt.Text=this.dataGridView18,this.dataGridView1.CurrentCell.RowIndex.Value.ToString().Trim();this.notetxt.Text=this.dataGridView110,this.dataGridView1.CurrentCell.RowInde

48、x.Value.ToString().Trim();this.isbntxt.Enabled=true;this.nametxt.Enabled=true;this.classtxt.Enabled=true;this.costtxt.Enabled=true;this.writertxt.Enabled=true;this.pubtxt.Enabled=true;this.notetxt.Enabled=true;this.bookisbn=this.isbntxt.Text;7.用户信息添加主要代码:public partial class RegisterForm:Formpublic

49、RegisterForm()InitializeComponent();private void regbtn_Click(object sender,EventArgs e)if(this.usernametxt.Text=string.Empty)MessageBox.Show(请输入用户姓名!,提示!);return;if(this.sextxt.Text=string.Empty)MessageBox.Show(请输入用户性别!,提示!);return;if(this.partcob.Text=string.Empty)MessageBox.Show(请输入用户所在部门!,提示!);r

50、eturn;if(this.telphonetxt.Text=string.Empty)MessageBox.Show(请输入用户移动电话!,提示!);return;if(this.phonetxt.Text=string.Empty)MessageBox.Show(请输入用户固定电话!,提示!);return;string pat1=0-98,11$;bool m1=Program.match(this.telphonetxt.Text,pat1);bool m2=Program.match(this.phonetxt.Text,pat1);if(!m1)MessageBox.Show(电话

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

当前位置:首页 > 技术资料 > 其他杂项

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

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