您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > C#实验c_图书管理系统源代码
更多实例访问成功网=newOleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\\test.mdb;);cn.Open();cn.Close();//读取数据到DataTableOleDbConnectioncn=newOleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\\test.mdb;);DataTableuserTbl=newDataTable();OleDbDataAdapterda=newOleDbDataAdapter(SELECT*FROM[User],cn);da.Fill(userTbl);//插入一条记录OleDbConnectioncn=newOleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\\test.mdb;);OleDbCommandcmd=newOleDbCommand(INSERTINTO[User]([ID],[UserName],[UserPassword])VALUES(1,'user_ab','123'),cn);cn.Open();cmd.ExecuteNonQuery();cn.Close();//更新OleDbConnectioncn=newOleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\\test.mdb;);OleDbCommandcmd=newOleDbCommand(UPDATE[User]SET[UserPassword]='newpwd'WHERE[UserName]='user_ab',cn);cn.Open();cmd.ExecuteNonQuery();cn.Close();更多实例访问成功网主要代码:publicpartialclassLoginForm:Form{publicstaticstringuacc;publicstaticstringupsw;publicstaticstringuname;publicstaticstringusex;publicstaticstringupart;publicstaticstringuright;publicLoginForm(){InitializeComponent();}privatevoidloginbtn_Click(objectsender,EventArgse){if(this.useracctxt.Text.Trim()==&&this.pswtxt.Text==){MessageBox.Show(请输入您的用户名和密码!,提示!);return;}try{stringsql;sql=select*fromtb_userwhereuacc='+this.useracctxt.Text+'andupsw='+this.pswtxt.Text+';OleDbDataReaderdr=DBHelp.OleReader(sql);dr.Read();if(dr.HasRows){uacc=this.useracctxt.Text;upsw=this.pswtxt.Text;uname=dr[uname].ToString();usex=dr[usex].ToString();更多实例访问成功网=dr[upart].ToString();uright=dr[uright].ToString();MainFormaf=newMainForm(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(数据库无法连接!,警告!);}}privatevoidcancelbtn_Click(objectsender,EventArgse){Application.Exit();}privatevoidLoginForm_Closing(objectsender,FormClosingEventArgse){Application.Exit();}}2.主界面(图较小,自己可以拉大点)更多实例访问成功网】主要代码就不写了,很简单。3.权限设置主要代码:publicpartialclassRightSet:Form{publicRightSet(){InitializeComponent();更多实例访问成功网}privatevoidRightSet_Load(objectsender,EventArgse){this.rightbox.SelectedIndex=0;//this.treeright.ExpandAll();Fill();}privatevoidokbtn_Click(objectsender,EventArgse){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;}if(this.txtfine.Text==string.Empty){MessageBox.Show(请输入超期罚款金额!,提示!);return;}if(this.txttim.Text==string.Empty){MessageBox.Show(请输入图书遗失罚款倍数!,提示!);return;}ArrayListarr=newArrayList();foreach(TreeNodenodesinthis.treeright.Nodes){if(nodes.Checked){arr.Add(1);}更多实例访问成功网{arr.Add(0);}foreach(TreeNodenodeinnodes.Nodes){if(node.Checked){arr.Add(1);}else{arr.Add(0);}}}string[]a=newstring[11];for(inti=0;iarr.Count;i++){if(arr[i].ToString().Trim()==1){a[i]=yes;}else{a[i]=no;}}stringsql=string.Empty;sql+=select*fromtb_rightwhereuright='+this.rightbox.Text+';DataTabledt=DBHelp.ExeOleCommand(sql);boolb=false;while(dt.Rows.Count!=0){b=true;break;}stringsql1;更多实例访问成功网(b){sql1=updatetb_rightset;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+=whereuright='+this.rightbox.Text+';}else{sql1=insertintotb_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]+');}DataTabledt1=DBHelp.ExeOleCommand(sql1);Fill();}privatevoidFill(){stringsql;sql=selectridasID号,urightas用户身份,maxbookas最大借书数量,maxdateas最大借阅时间,rcostas押金,rfineas超期罚率,rtimas遗失赔率,rbmas图书管理,rumas用户管理,rrmas权限管理,rbormas借阅管理,risas信息查询,rbisas图书信息查询,ruisas用户信息查询,rborisas借阅历史查询,rblpas图书挂失处理,rblas图书挂失,rlpas挂失处理fromtb_right;更多实例访问成功网=DBHelp.ExeOleCommand(sql);this.dataGridView1.DataSource=dt;}privatevoidcell_click(objectsender,DataGridViewCellEventArgse){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.Row
本文标题:C#实验c_图书管理系统源代码
链接地址:https://www.777doc.com/doc-3391458 .html