logo资料库

用c#实现的图书管理系统(有图示,源代码).doc

第1页 / 共59页
第2页 / 共59页
第3页 / 共59页
第4页 / 共59页
第5页 / 共59页
第6页 / 共59页
第7页 / 共59页
第8页 / 共59页
资料共59页,剩余部分请下载后查看
成功信息网 www.020chenggong.com 一个图书馆的管理系统,用 c#做的,visual studio2008 编写的。代码经测试全部实现,暂时 未发现什么 bug,在年纪的评比中得到了第一名的成绩。下面把这些代码分享给你们,希望 能对你们有所帮助。 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, EventArgs e) { if (this.useracctxt.Text.Trim() == "" && this.pswtxt.Text == "") { } try { MessageBox.Show("请输入您的用户名和密码!", "提示!"); return; string sql; sql = "select * from tb_user where uacc='" + this.useracctxt.Text + "' and upsw='" + this.pswtxt.Text + "'www.feipin100.com"; OleDbDataReader dr = DBHelp.OleReader(sql); dr.Read(); if (dr.HasRows) {
成功信息网 www.020chenggong.com uacc = this.useracctxt.Text; upsw = this.pswtxt.Text; uname = dr["uname"].ToString(); usex = dr["usex"].ToString(); upart = dr["upart"].ToString(); uright = dr["uright"].ToString(); MainForm af = new MainForm(this); this.Hide(); this.useracctxt.Clear(); this.pswtxt.Clear(); af.Show(); } else { MessageBox.Show("账号或密码错误!", "提示!"); 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.主界面(图较小,自己可以拉大点) 主要代码就不写了,很简单。
成功信息网 www.020chenggong.com 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.txtnum.Text == string.Empty) { } MessageBox.Show("请输入最大借阅图书数量!", "提示!"); return; if (this.txtday.Text == string.Empty) { } MessageBox.Show("请输入最大借阅图书时间!", "提示!"); return; if (this.txtcost.Text == string.Empty)
成功信息网 www.020chenggong.com { } 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 (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 string[11]; for (int i = 0; i < arr.Count; i++) { if (arr[i].ToString().Trim() == "1") {
成功信息网 www.020chenggong.com a[i] = "yes"; } else a[i] = "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 = "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='" + a[0] + "',"; sql1 += "rum='" + a[1] + "',"; sql1 += "rrm='" + a[2] + "',"; sql1 += "rborm='" + a[3] + "',"; sql1 += "ris='" + a[4] + "',"; sql1 += "rbis='" + a[5] + "',"; sql1 += "ruis='" + a[6] + "',"; sql1 += "rboris='" + a[7] + "',"; sql1 += "rblp='" + a[8] + "',"; sql1 += "rbl='" + a[9] + "',"; sql1 += "rlp='" + a[10] + "' "; sql1 += "where uright='" + this.rightbox.Text + "'"; } else
成功信息网 www.020chenggong.com { sql1 = "insert into 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 + "','" + a[0] + "','" + a[1] + "','" + a[2] + "','" + a[3] + "','" + a[4] + "','" + a[5] + "','" + a[6] + "','" + a[7] + "','" + a[8] + "','" + a[9] + "','" + a[10] + "')"; } 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 用户信息查 询,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.dataGridView1[1, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim(); this.txtnum.Text = this.dataGridView1[2, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim(); this.txtday.Text = this.dataGridView1[3, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim(); this.txtcost.Text = this.dataGridView1[4, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim(); this.txtfine.Text = this.dataGridView1[5, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim(); this.txttim.Text = this.dataGridView1[6, this.dataGridView1.CurrentCell.RowIndex].Value.ToString().Trim(); ArrayList list = new ArrayList(); string sql = "select * from tb_right where uright='" + this.rightbox.Text + "'";
成功信息网 www.020chenggong.com DataTable dt = DBHelp.ExeOleCommand(sql); if (dt.Rows.Count != 0) { for (int i = 0; i < 11; i++) { } list.Add(dt.Rows[0][7+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 (list[i].ToString() == "yes") { } ((TreeNode)arr[i]).Checked = true; else { } ((TreeNode)arr[i]).Checked = false; } } 4.权限修改
成功信息网 www.020chenggong.com 主要代码: public partial class UserRight : Form { public 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; private void Fill() { if (this.checkbox.Text == "") { } MessageBox.Show("请选择要使用的查询字段!", "提示!"); return;
分享到:
收藏