C#编写图书管理系统.docx

上传人:小飞机 文档编号:3153656 上传时间:2023-03-11 格式:DOCX 页数:76 大小:52.08KB
返回 下载 相关 举报
C#编写图书管理系统.docx_第1页
第1页 / 共76页
C#编写图书管理系统.docx_第2页
第2页 / 共76页
C#编写图书管理系统.docx_第3页
第3页 / 共76页
C#编写图书管理系统.docx_第4页
第4页 / 共76页
C#编写图书管理系统.docx_第5页
第5页 / 共76页
亲,该文档总共76页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《C#编写图书管理系统.docx》由会员分享,可在线阅读,更多相关《C#编写图书管理系统.docx(76页珍藏版)》请在三一办公上搜索。

1、C#编写图书管理系统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

2、sender, 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.HasRow

3、s) uacc = 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(账号或密码错误!, 提示!); this.u

4、seracctxt.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.主界面 主要代码就不写了,很简单。 3.权限设置 主

5、要代码: 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.txtnum.Text = string.Empty) MessageBox

6、.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(请输入超期罚款金额!, 提示!); return; if (this.txttim.Text = st

7、ring.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 arr.Add(0); string a=new string11; for (int

8、 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 != 0) b = true; break; string sql1; if (b) sql1

9、= 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 += rum= + a1 + ,; sql1 += rrm= + a2 + ,; sql1 +=

10、 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 tb_right(uright,maxbook,maxdate,rcost,rfine,

11、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 + , +

12、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 权限管理,rborm as 借阅管理,ris as 信息查询,rbis as 图书信息查询,ruis as 用户

13、信息查询,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.dataGridView11, this.dataGridView1.CurrentCell.RowIn

14、dex.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.Text = this.dataGridView14, this.dataGridView1.CurrentCell.R

15、owIndex.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; ArrayList list = new ArrayList; string sql = select * from tb_right

16、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 this.treeright.Nodes) arr.Add(nodes); foreach(TreeNode node in nodes.Nodes) arr

17、.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 InitializeComponent; private void btncancel_Click(object sender, EventArgs e) this.Close;

18、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 (this.partbox.Text = ) MessageBox.Show(请选择用户所在的部门!, 提示!); return; string sql = string.E

19、mpty; 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.SelectedIndex.ToString; switch (c) case 0:/用户帐号 if (this.checktxt.Text != string.Empty) sql += w

20、here 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.ToString != 0) sql += and upart= + this.partbox.Text + ; else if (this.partbox.SelectedInde

21、x.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, EventArgs e) Fill; private void cell_click(object sender, DataGridViewCellEventArgs e) this.

22、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.dataGridView1.CurrentCell.RowIndex.Value.ToString.Trim;

23、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.dataGridView1.CurrentCell.RowIndex.Value.ToString.

24、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; private void btnchange_Click(object sender, EventArgs e) if

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

26、Text+; DataTable dt = DBHelp.ExeOleCommand(sql); MessageBox.Show(修改成功!,恭喜!); Fill; 5.添加图书信息 (bno,bname,bclass,bisbn,bcost,adder,adddate,bauthor,bpub,bstate,bnote 主要代码: public partial class NewBook : Form public NewBook InitializeComponent; private void retbtn_Click(object sender, EventArgs e) this.H

27、ide; private void 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 = ) Messag

28、eBox.Show(请输入图书的信息!, 提示!); 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.Text = ) MessageBox.Show(请输入图书的信息!, 提示!); return; /string pat3 = u4e00-u9fa5+$;/全为汉字 /string pat4 = (u4e00-u9fa5+|A-Za-z+)$;/汉字或字母

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号