C#编写图书管理系统.docx
《C#编写图书管理系统.docx》由会员分享,可在线阅读,更多相关《C#编写图书管理系统.docx(76页珍藏版)》请在冰豆网上搜索。
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()
lnitializeComponent();
privatevoidloginbtn_Click(objectsender,EventArgse)
{
if(this.useracctxt.Text.Trim()==""&&this.pswtxt.Text=="")
{
MessageBoxShow(”请输入您的用户名和密码!
","提示!
”);
return;
}
try
{
stringsql;
andupsw='"
sql="select*fromtb_userwhereuacc='"+this.useracctxt.Text+
+this.pswtxt.Text+""';
OleDbDataReaderdr=DBHelpOleReader(sql);
dr.Read();
if(dr.HasRows)
{
uacc=
upsw=uname=dr[
this.useracctxt.Text;
this.pswtxt.Text;
"uname"].ToString();
upart=dr["upart"].ToString();
uright=dr["uright"].ToString();
MainFormaf=newMainForm(this);
this.Hide();
this.useracctxt.Clear();
this.pswtxt.Clear();
af.Show();
}
else
{
MessageBoxShow(”账号或密码错误!
","提示!
”);
this.useracctxt.Clear();
this.pswtxt.Clear();
this.useracctxt.Focus();
}
}
catch(Exception)
{
MessageBoxShow(”数据库无法连接!
","警告!
");
}
}
privatevoidcancelbtn_Click(objectsender,EventArgse)
{
Application.Exit();
}
privatevoidLoginForm_Closing(objectsender,FormClosingEventArgse)
{
Application.Exit();
}
}
2.主界面(图较小,自己可以拉大点)
♦田社管理系统
主要代码就不写了,很简单
3.权限设置
主要代码:
publicpartialclassRightSet:
Form
{
publicRightSet()
{
lnitializeComponent();
}
privatevoidRightSet_Load(objectsender,EventArgse){
this.rightbox.Selectedlndex=0;
〃this.treeright.ExpandAII();
Fill();
privatevoidokbtn_Click(objectsender,EventArgse)
{
if(this.txtnum.Text==string.Empty)
{
MessageBoxShow(”请输入最大借阅图书数量!
",”提示!
”);
return;
}
if(this.txtday.Text==string.Empty)
{
MessageBoxShow(”请输入最大借阅图书时间!
",”提示!
”);
return;
}
if(this.txtcost.Text==string.Empty)
{
MessageBoxShow(”请输入借书押金金额!
","提示!
”);
return;
}
if(this.txtfine.Text==string.Empty)
{
MessageBoxShow(”请输入超期罚款金额!
","提示!
”);
return;
}
if(this.txttim.Text==string.Empty)
{
MessageBoxShow(”请输入图书遗失罚款倍数!
",”提示!
”);
return;
}
ArrayListarr=newArrayList();
foreach(TreeNodenodesinthis.treeright.Nodes)
{
if(nodes.Checked)
{
arr.Add("1");
}
else
{
arr.Add("0");
}
foreach(TreeNodenodeinnodes.Nodes)
{
if(node.Checked)
"1");
arr.Add(
}
else
{
arr.Add("0");
}
}
}
string[]a=newstring[11];
for(inti=0;i{
if(arr[i].ToString().Trim()=="1")
{
a[i]="yes";
}
else
{
a[i]="no";
}
}
stringsql=string.Empty;
.rightbox.Text+
sql+="select*fromtb_rightwhereuright='"+this
DataTabledt=DBHelp.ExeOleCommand(sql);
boolb=false;
while(dt.Rows.Count!
=0)
{
b=true;
break;
}
stringsql1;
if(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+=
sql1+=
sql1+=
"rtim='"
"rbm='"
"rum="'
+this
+a[0]+
+a[1]+
.txttim.Text+"',"
IIIII.
JJ
IIIII.
JJ
sql1+=
"rrm="'
+a[2]+
IIIII.
JJ
sql1+=
"rborm='"
'+a[3]+"',";
sql1+=
"ris='"
+a[4]+
IIIII.
JJ
sql1+=
"rbis='"
+a[5]+
IIIII.
JJ
sql1+=
"ruis='"
+a⑹+
IIIII.
JJ
sql1+=
"rboris='"
+a【7]
1IIIII.
JJ
sql1+=
"rblp='"
+a[8]+
IIIII.
JJ
sql1+=
"rbl='"
+a[9]+
IIIII.
JJ
sql1+=
"rlp='"
+a[10]+
IIIII.
>
sql1+=
"whereuright='"
+this.rightbox.Text
}
else
{
sqll="insertinto
tb_right(uright,maxbook,maxdate,rcost,fine,rtim,rbm,rum,rrm,rborm,ris,rbis,ruis,rboris,rblp
rbl,rlp)"
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";
DataTabledt=DBHelp.ExeOleCommand(sql);
this.dataGridView1.DataSource=dt;
privatevoidcell_click(objectsender,DataGridViewCellEventArgse)
{
this.dataGridView1.CurrentCell.Rowlndex].Value.ToString().Trim();
this.txtnum.Text=this.dataGridView1[2,
this.dataGridView1.CurrentCell.Rowlndex].Value.ToString().Trim();
this.txtday.Text=this.dataGridView1[3,
this.dataGridView1.CurrentCell.Rowlndex].Value.ToString().Trim();
this.txtcost.Text=this.dataGridView1[4,
this.dataGridView1.CurrentCell.Rowlndex].Value.ToString().Trim();
this.txtfine.Text=this.dataGridView1[5,
this.dataGridView1.CurrentCell.Rowlndex].Value.ToString().Trim();
this.txttim.Text=this.dataGridView1[6,
this.dataGridView1.CurrentCell.Rowlndex].Value.T