public void Clear_Table(Control.ControlCollection GBox, string TName)
{
string sID = "";
foreach (Control C in GBox)//这一句是什么意思啊
{
if (C.GetType().Name == "CheckBox")//C怎么出来的它代表什么
{
sID = C.Name;
if (sID.IndexOf(TName) > -1)
{
if (((CheckBox)C).Checked == true)
{
string TableName = "";
string[] Astr = sID.Split(Convert.ToChar('_'));
TableName = "tb_" + Astr[1];
if (Astr[1].ToUpper() == ("Clew").ToUpper())
{
MyDataClass.getsqlcom("update " + TableName + " set Fate=0,Unlock=0 where ID>0");
}
else
{
MyDataClass.getsqlcom("Delete " + TableName);
if (Astr[1].ToUpper() == ("Login").ToUpper())
{
MyDataClass.getsqlcom("Delete tb_UserPope");
MyDataClass.getsqlcom("insert into " + TableName + " (ID,Name,Pass) values('0001','TSoft','111')");
ADD_Pope("0001", 1);
}
}
}
}
}
}
}
{
string sID = "";
foreach (Control C in GBox)//这一句是什么意思啊
{
if (C.GetType().Name == "CheckBox")//C怎么出来的它代表什么
{
sID = C.Name;
if (sID.IndexOf(TName) > -1)
{
if (((CheckBox)C).Checked == true)
{
string TableName = "";
string[] Astr = sID.Split(Convert.ToChar('_'));
TableName = "tb_" + Astr[1];
if (Astr[1].ToUpper() == ("Clew").ToUpper())
{
MyDataClass.getsqlcom("update " + TableName + " set Fate=0,Unlock=0 where ID>0");
}
else
{
MyDataClass.getsqlcom("Delete " + TableName);
if (Astr[1].ToUpper() == ("Login").ToUpper())
{
MyDataClass.getsqlcom("Delete tb_UserPope");
MyDataClass.getsqlcom("insert into " + TableName + " (ID,Name,Pass) values('0001','TSoft','111')");
ADD_Pope("0001", 1);
}
}
}
}
}
}
}
{
string sID = "";
foreach (Control C in GBox)//遍历GBox集合里面的每一个控件
{
if (C.GetType().Name == "CheckBox")//当前遍历到的控件
{
sID = C.Name;
if (sID.IndexOf(TName) > -1)
{
if (((CheckBox)C).Checked == true)
{
string TableName = "";
string[] Astr = sID.Split(Convert.ToChar('_'));
TableName = "tb_" + Astr[1];
if (Astr[1].ToUpper() == ("Clew").ToUpper())
{
MyDataClass.getsqlcom("update " + TableName + " set Fate=0,Unlock=0 where ID>0");
}
else
{
MyDataClass.getsqlcom("Delete " + TableName);
if (Astr[1].ToUpper() == ("Login").ToUpper())
{
MyDataClass.getsqlcom("Delete tb_UserPope");
MyDataClass.getsqlcom("insert into " + TableName + " (ID,Name,Pass) values('0001','TSoft','111')");
ADD_Pope("0001", 1);
}
}
}
}
}
}
}
比如if (sID.IndexOf(TName) > -1)
这句是什么意思啊
还有这个else
{
MyDataClass.getsqlcom("Delete " + TableName);
if (Astr[1].ToUpper() == ("Login").ToUpper())
{
MyDataClass.getsqlcom("Delete tb_UserPope");
MyDataClass.getsqlcom("insert into " + TableName + " (ID,Name,Pass) values('0001','TSoft','111')");
ADD_Pope("0001", 1);
}
}
{
string sID = "";
foreach (Control C in GBox)//遍历GBox集合里面的每一个控件
{
if (C.GetType().Name == "CheckBox")//当前遍历到的控件 如果是checkbox类型的话
{
sID = C.Name;
if (sID.IndexOf(TName) > -1)匹配(比较)Tname和c.name,不相等返回-1,
{
if (((CheckBox)C).Checked == true)
{
string TableName = "";
string[] Astr = sID.Split(Convert.ToChar('_'));将c.name按_分开,并放在数组中,例如ca_hh_aa就分为
Astr[0]=ca,Astr[1]=hh,Astr[2]=aa
TableName = "tb_" + Astr[1];//tableName的值为tb_加上c.name的_后的字符。
if (Astr[1].ToUpper() == ("Clew").ToUpper())//若c.name的_后的字符为clew,将表中数据都置0
{
MyDataClass.getsqlcom("update " + TableName + " set Fate=0,Unlock=0 where ID>0");
}
else
{
MyDataClass.getsqlcom("Delete " + TableName);
if (Astr[1].ToUpper() == ("Login").ToUpper())//若
{
MyDataClass.getsqlcom("Delete tb_UserPope");
MyDataClass.getsqlcom("insert into " + TableName + " (ID,Name,Pass) values('0001','TSoft','111')");
ADD_Pope("0001", 1);
}
}
}
}
}
}
}
那几代码调用了IndexOf()方法进行比较
GBOX中的每一个控件c
if (C.GetType().Name == "CheckBox")//C怎么出来的它代表什么
if(c.类型名=="CheckBox")
sID.IndexOf(TName) > -1
sId名称包含TName
{
string sID = "";
foreach (Control C in GBox)//遍历所有的GBox集合中的控件
{
if (C.GetType().Name == "CheckBox")//当前遍历到的控件 如果是checkbox类型的话
{
sID = C.Name; //赋checkBox的ID 号
if (sID.IndexOf(TName) > -1) //如果该checkbox存在
{
if (((CheckBox)C).Checked == true) //如果checkbox被选中的话
{
string TableName = ""; //变量初始化,不过最好用string.Empty
string[] Astr = sID.Split(Convert.ToChar('_')); //将checkbox的ID号按'_'分解 eg:chk_tb1 ->Astr[1]=tb1
TableName = "tb_" + Astr[1]; //给变量赋值如:tb_tb1
if (Astr[1].ToUpper() == ("Clew").ToUpper()) //如果分解的SID(控件编号ID)的‘-’后部分等于'clew' 最好用eqals方法
{
MyDataClass.getsqlcom("update " + TableName + " set Fate=0,Unlock=0 where ID>0"); //将所有的表两个字段更新为0(sql语 //句返回)
}
else
{
MyDataClass.getsqlcom("Delete " + TableName); //否则删除表sql语句返回) if (Astr[1].ToUpper() == ("Login").ToUpper()) //如果分解SID(控件编号ID)的‘-’后部分等于'login' 最好用eqals方法
{
MyDataClass.getsqlcom("Delete tb_UserPope"); //后面的就不啰嗦啦。。同理
MyDataClass.getsqlcom("insert into " + TableName + " (ID,Name,Pass) values('0001','TSoft','111')");
ADD_Pope("0001", 1);
}
}
}
}
}
}
}