C#编写图书管理系统

上传人:枕*** 文档编号:130389605 上传时间:2022-08-04 格式:DOC 页数:59 大小:465KB
收藏 版权申诉 举报 下载
C#编写图书管理系统_第1页
第1页 / 共59页
C#编写图书管理系统_第2页
第2页 / 共59页
C#编写图书管理系统_第3页
第3页 / 共59页
资源描述:

《C#编写图书管理系统》由会员分享,可在线阅读,更多相关《C#编写图书管理系统(59页珍藏版)》请在装配图网上搜索。

1、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,

2、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) u

3、acc = this.useracctxt.Text; upsw = this.pswtxt.Text; 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(); else MessageBox.Show(账号或密码错误!,

4、提示!); 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.主界面(

5、图较小,自己可以拉大点)重要代码就不写了,很简朴。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

6、.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(请输入超期罚款金额!,

7、提示!); 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 ar

8、r.Add(0); string a=new string11; for (int i = 0; i arr.Count; i+) if (arri.ToString().Trim() = 1) ai = yes; else ai = 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 !=

9、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= + a0 + ,; sql1 +=

10、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 + ; else sql1 = insert into

11、 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 + , + a0 + , + a1 + , + a2 + , + a3 + , +

12、a4 + , + a5 + , + a6 + , + a7 + , + a8 + , + a9 + , + a10 + ); 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 权限管理,rb

13、orm 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.dat

14、aGridView11, this.dataGridView1.CurrentCell.RowIndex.Value.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

15、.Text = this.dataGridView14, this.dataGridView1.CurrentCell.RowIndex.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().Tri

16、m(); 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.Rows07+i.ToString(); ArrayList arr = new ArrayList(); foreach (TreeNode nodes in t

17、his.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; else (TreeNode)arri).Checked = false; 4.权限修改重要代码:public partial class UserRight : Form public UserRight() Initialize

18、Component(); 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 (

19、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.SelectedIn

20、dex.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.ToS

21、tring() != 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,

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

23、 this.txtsex.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.To

24、String().Trim(); this.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.CurrentCe

25、ll.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 = Dialog

26、Result.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.添加图书信息(bno,bname,bclass,bisbn,bcost,adder,adddate,bauthor,bpub,bstate,bnote重要代码:public

27、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

28、.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(请输入图书旳信息!, 提示!)

29、; return; if (this.bookpubtxt.Text = ) MessageBox.Show(请输入图书旳信息!, 提示!); return; if (this.numtxt.Text = ) MessageBox.Show(请输入图书旳信息!, 提示!); return; if (this.notetxt.Text = ) MessageBox.Show(请输入图书旳信息!, 提示!); return; /string pat3 = u4e00-u9fa5+$;/全为中文 /string pat4 = (u4e00-u9fa5+|A-Za-z+)$;/中文或字母 /strin

30、g 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, pat1); bool m2 = Program.match(this.numtxt.Text, pat2); bool m3 = Pr

31、ogram.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) MessageBox.Show(图书价格应为XX.XX元!, 提示!); this.bookcostt

32、xt.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 into tb_book(bno,bname,bclass,bisbn,bcost,adder,adddate,bauthor,bpub,bstate,bnote) + values( + k.ToString() + , + this.booknametxt

33、.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.

34、Hide(); private void rebtn_Click(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 N

35、ewBook_Load(object sender, EventArgs e) /* string 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.Item

36、s.Add(k.ToString(); this.booknotxt.SelectedIndex = 0; this.classtxt.SelectedIndex = 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; else k = Convert.ToInt32(d

37、t.Rows00.ToString(); k+; this.booknotxt.Items.Add(k.ToString(); this.booknotxt.SelectedIndex = 0; this.classtxt.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 wher

38、e bisbn= + this.isbntxt.Text + ; OleDbDataReader dr = DBHelp.OleReader(sql); dr.Read(); if (dr.HasRows) this.booknametxt.Text = drbname.ToString().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.numtxt.Enabled = true;

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


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