ArrayList arylst = new ArrayList();
ToolStripMenuItem[] menu = new ToolStripMenuItem[] {
this.menuEmployee,this.menuCompany,this.menuCustomer,this.menuGoodsIn,this.menuGoodsOut,this.menuSellGoods,
this.menuGoodsBack,this.menuDepotChange,this.menuDepotAlarm,this.menuSysUser,this.menuPopedomSet,this.menuDatabak,this.menuReBakData
};
DataSet P_ds = G_SqlClass.GetDs("SELECT * FROM v_UserView WHERE SysLoginName = '"+ PropertyClass.SendNameValue+"'"); for (int i = 0; i < 13; i++)
{
arylst.Add(P_ds.Tables[0].Rows[0][14+i].ToString());
}
for (int j = 0; j < arylst.Count; j++)
{
if (arylst[j].ToString() == "False")
{
menu[j].Visible = false;
}
else
{
menu[j].Visible = true;
}
}
这段代码中的arylst.Add(P_ds.Tables[0].Rows[0][14+i].ToString());其中i代表了什么?Tables[0].Rows[0][14+i]这段是什么意思?
ToolStripMenuItem[] menu = new ToolStripMenuItem[] {
this.menuEmployee,this.menuCompany,this.menuCustomer,this.menuGoodsIn,this.menuGoodsOut,this.menuSellGoods,
this.menuGoodsBack,this.menuDepotChange,this.menuDepotAlarm,this.menuSysUser,this.menuPopedomSet,this.menuDatabak,this.menuReBakData
};
DataSet P_ds = G_SqlClass.GetDs("SELECT * FROM v_UserView WHERE SysLoginName = '"+ PropertyClass.SendNameValue+"'"); for (int i = 0; i < 13; i++)
{
arylst.Add(P_ds.Tables[0].Rows[0][14+i].ToString());
}
for (int j = 0; j < arylst.Count; j++)
{
if (arylst[j].ToString() == "False")
{
menu[j].Visible = false;
}
else
{
menu[j].Visible = true;
}
}
这段代码中的arylst.Add(P_ds.Tables[0].Rows[0][14+i].ToString());其中i代表了什么?Tables[0].Rows[0][14+i]这段是什么意思?
Tables[0]代表tables集合中的第一张table
Rows[0]代表rows集合中的第一行
Rows[0][14+i]代表rows集合中的第一行的第14+i列的值
数据库表里的从第15列(索引14)开始,应该分别代表了一个menu,依次取出来后,在
for (int j = 0; j < arylst.Count; j++)
{
if (arylst[j].ToString() == "False")
{
menu[j].Visible = false;
}
else
{
menu[j].Visible = true;
}
}
这个循环中依次设置各个menu的可见性.+i的作用当然就是为了和各个menu对应,menu一共应该是13个