IList<ZhenInfo> LzhenInfo = (IList<ZhenInfo>)Session["zhenInfo"]; //使用IList来存储要删除的实体列表
//循环gridview中的数据到实例类中
for (int i = 0; i < GridView1.Rows.Count; i++)
{
ZhenInfo zhenInfo = new ZhenInfo();
zhenInfo.ZhenID = GridView1.Rows[i].Cells[0].ToString();
zhenInfo.ZhenName = GridView1.Rows[i].Columns[1].ToString();
zhenInfo.Manager = GridView1.Rows[i].Columns[2].ToString();
zhenInfo.Post = GridView1.Rows[i].Columns[3].ToString();
zhenInfo.CunNUM = Convert.ToInt32(GridView1.Rows[i].Columns[4].ToString());
zhenInfo.ZuNUM = Convert.ToInt32(GridView1.Rows[i].Columns[5].ToString());
zhenInfo.Tel1 = GridView1.Rows[i].Columns[6].ToString();
LzhenInfo.Add(zhenInfo);
}
SJShuRuMange sJShuRu = new SJShuRuMange(); //调用接口
bool bl = sJShuRu.delZhenInfoS(LzhenInfo); //执行批量删除操作
//执行批量删除操作
public bool DeleteListXXCZInfo(IList<ZhenInfo> zhenInfos)
{
int delcount = 0;
string[] delSql = new string[zhenInfos.count];
try
{
for(int i=0;i<zhenInfos.count;i++)
{
delSql[i]="delete from ZhenInfo where ID='"+zhenInfos[i].ID+"'";
}
delcount=SQLDaoImpl.ExeSqlCommands(ConnHelper.getConnectionString(), delSql, false);
}
catch (Exception ex)
{
throw ex;
}
if(delcount>0)
{
return true;
}
else
{
return false;
}
}
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。