C#实验c_图书管理系统源代码.docx
《C#实验c_图书管理系统源代码.docx》由会员分享,可在线阅读,更多相关《C#实验c_图书管理系统源代码.docx(61页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1 .登陆界面OleDbConnection cn = new OleDbConnection( uProvider=Microsoft. Jet.OLEDB .4.0; Data Source=C:test.mdb;H);cn.Open();cn.Close();/Z读取数据到DataTableOleDbConnection cn = new OleDbConnection(HProvider=Microsoft.Jet.OLEDB.4.0; Data Source=C:test.mdb;M);DataTable userTbl = new DataTable();OleDbDataAdap
2、ter da = new OleDbDataAdapter(SELECT * FROM |Usern, cn); da.Fill(userTbl);/Z插入一条记录OleDbConnection cn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:test.mdb;M);OleDbCommand cmd = new OleDbCommand(INSERT INTO User (ID, UserName, UserPassword) VALUES (1, use jab, 123), cn);cn.Op
3、en();cmd.ExecuteNonQueryO;cn.Close();/Z更新OleDbConnection cn = new OleDbConnection(ProvideiMicrosoft.Jet.OLEDB.4.0; Data Source=C:test.mdb;);OleDbCommand cmd = new OleDbCommand(UPDATE User SET UserPassword:newpwd WHERE UserName=user_ab, cn);cn.Open();cmd.ExecuteNonQueryO;cn.Close();13叵区)登录界面登录主要代码:pu
4、blic 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;pub 1 i c Logi nFormOInitializeComponent();private void loginbtn_Click(object sender, EventArgs e)(
5、if (this, useracctxt. Text. Trim() & this, pswtxt. Text =)(MessageBox. Show(请输入您的用户名和密码!二提示!); return;try(and upsw二string sql;sql = select * from tb_user where uacc二 + this, useracctxt. Text + + this, pswtxt. Text +;OleDbDataReader dr = DBHelp.OleReader(sql);dr. Read ();i f (dr. HasRows)(uacc = this
6、, useracctxt. Text;upsw = this, pswtxt. Text;uname = dr*uname*. ToStringO ;usex = dr usex*. ToStringO ; upart = dr*upart*. ToStringO ;uright = dr *uright*. ToStringO ;MainForm af = new Ma inForm(this);this. HideO ;this, useracctxt. Clear ();thi s. pswtxt. Clear ();af. Show ();elseMessageBox.Show(账号或
7、密码错误! ”,”提示!;this, useracctxt. Clear ();this, pswtxt. Clear ();this, useracctxt. Focus 0;catch (Except ion)(MessageBox.Show(“数据库无法连接!,警告!);)private void cancelbtn_Click(object sender, EventArgs e)(Application. Exit();)pri vate void I.ogi nForm_C losing (object sender, FoiinC 1 os i ngEvcn t Args e)
8、(Application.Exit ();2 .主界面(图较小,自己可以拉大点)图书管建系统主要代码就不写了,很简单。3.权限设置主要代码:public partial class RightSet : Form(pub 1i c RightSet 0Ini tial izeComponent ();private void RightSet Load(object sender, EventArgs e) (this, rightbox. Selectedlndex = 0;/this, treeright. ExpandAl 1 ();FillO;private void okbtn_Cl
9、ick(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)MessageBox. Show(请输入借书押金金额!,提示!”); return;)i f (this, txtfi
10、ne. Text = string. Empty)(UessageBox. Show (请输入超期罚款金额!,提示!”); return;if (this, txttim. Text = string. Empty)(MessageBox.Show(请输入图书遗失罚款倍数!,提示!”); return;Array Li st arr = new ArrayLi st ();foreach (TreeXode nodes in this, treeright. Nodes) (if (nodes. Checked)(arr. Add(l);elsearr. Add(0”);foreach(Tre
11、( ode node in nodes. Nodes) i f (node. Checked)(arr. Add(l);else(arr. Add ();)string a=new stringl1;for (int i = 0; i arr.Count; i+)(if (arri. ToString0. TrimO = 1)(ai = yes;)else(ai = no;string sql = string. Empty;sql += select * from tb ri ght where uright=+ this, rightbox. Text +DataTable dt = DB
12、Hc1p. ExeOleCommand(sql);bool b = false;whi le (dt. Rows. Count != 0)(b - true;break;string sqll;if (b)sqll=update tb right set ;sql 1+= maxbook=+ this, txtnum. Text +, *;sqll+= maxdate=+ this, txtday. Text +, *;sqll+= rcost=+ this, txtcost. Text +, *;sql 1+= rfine二+ this, txtfine. Text + ,;sqll+= r
13、tim= + this.txttim. Text +,;sql 1+= rbm=* + a0sql 1+= rum= + alsqll+= rrm= + a 2sqll+= rbornr + a 3sqll+= ris= + a4sqll+= rbis=,* + a5 + “,;sqll+= ruis= + aL6J +,;sqll+= rboris=, + a7 +sqll+= rblp= + a8sqll+= rbl=+ a 9 +sqll+= rip二+ a10 + ;sql 1+= where uright= * + this, rightbox. Text +elsesql1 = i
14、nsert intotb_right (uright, max book, maxdate, rcost, rfine, rtim, rbm, rum, rrm, rborm, ris, rbis, ruis, rboris, rblp ,rbl,rlp);sql 1 +=values (* * + this, right box. Text + + this, txtnum. Text + *,+this, txtday. Text +,+ this, txtcost. Text +,+ this, txtfine. Text +,+this, txttim.Text +a0+ al + a
15、2+ a3a4 + a5 +,/ + a6+ a7 +*/ + a8a9+ a10 + )DataTable dtl = DBHelp. Exe01eCommand(sql1);FillO;private void Fi 11 ()string sql;sql = select rid as ID 号,uright as 用户身份,max book as 最大借书数量,maxdate as 最 大借阅时间,rcost as押金,rfine as超期罚率,rtim as遗失赔率,rbm as图书管理,rum as用户管理,口m as权限管理,rborm as借阅管理,ris as信息査询,rbi
16、s as图书信息査询,ruis as用户信息査 询,rborisas借阅历史査询,rblp as图,挂失处理,rbl as图打挂失,rip as挂失处理from tb right;I);it dTiible dt = DBHelp. ExeOleCommand (sql);this. dataGridViewl. DataSource = dt;private void ce1l_c1ick(object sender, DataGridViewCe11EventArgs e) this, rightbox. Text = this. dataGridViewl1,this. dataGrid
17、Viewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;this, txtnum. Text = this. dataGridViewl 2,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;this, txtday. Text = this. dataGridViewl3,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;this, txtcost. Text
18、 = this. dataGridViewl 4,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;this, txtfine. Text = this. dataGridViewl5,this. dataGridViewl. CurrentCel 1. Rowindex. Value. ToStringO. TrimO ;this, txttim. Text = this. dataGridViewl6,this. dataGridViewl. CurrentCel 1. Rowindex. Value
19、. ToStringO. TrimO ;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. Rows 7+i. ToString0);)Arrayl J st arr = new ArrayLi st ();foreach (
20、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.ToStringO = yes)(TreeNode)arri). Checked = true;else(TreeNode)arri). Checked = false;)4.权限修主要代码:public partial class I sorRight :erm(public
21、UserRight()(Initial izeComponent ();pri vate voi d btncancel_Cl ick (object sender, I: vent Args e)this. CloseO;pri vate voi d Us er Ri ght_I.oad (object sender, Event Args e) this, checkbox. Selectedlndex = 0;this, partbox. Selectedlndex = 0;private void Fill()if (this, checkbox. Text = (MessageBox
22、. 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 部 f J, uteIphone as 移动电话,uphone as 固定电话,udate as 注册 II 期,uright as 权限 from tb user;if (this, checktx
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C# 实验 c_ 图书 管理 系统 源代码
限制150内