62,268
社区成员
发帖
与我相关
我的任务
分享#region 权限检查
if (Session["UserInfo"] == null)
return;
LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"];
int userid = int.Parse(currentUser.UserID.ToString());
string strWheregateid = "charindex(ltrim(wsnc_gateway.gatewayid),accounts_users.departmentid)>0 and accounts_users.UserID='" + userid + "'";
DataSet dsid = new DataSet();
dsid = gatewayidbll.GetgatewayidList(strWheregateid);
DataTable tableid = dsid.Tables[0];
//不符合条件的计数器
//int jishu = 0;
if (tableid.Rows.Count > 0)
{
//这里循环符合条件的数据,会有几个符合条件的
//我现在这样做循环到最后只显示最后一个符合条件的数据,比如我符合条件的gatewayid有 1,2,3
//但是只显示gatewayid=3的数据,怎么才能显示gatewayid所有符合的数据呢
for (int gateid = tableid.Rows.Count - 1; gateid >= 0; gateid--)
{
//int.Parse(tableid.Rows[gateid][0].ToString())是符合条件的数据库字段的数据
strWhere = "WSNC_Gateway.gatewayid='" + int.Parse(tableid.Rows[gateid][0].ToString()) + "' ";
if (Session["strWhereNodegateid"] != null && Session["strWhereNodegateid"].ToString() != "")
{
strWhere += Session["strWhereNodegateid"].ToString();
}
}
}
#endregion
DataSet ds = new DataSet();
ds = bll.GetList(strWhere);
DataView dv = ds.Tables[0].DefaultView;
gridView.DataSource = dv;
gridView.DataBind();
select aid from a where aid='1' or aid='2' or aid='3'
if (tableid.Rows.Count > 0)
{
string Strid=string.Empty;
for (int i = 0;tableid.Rows.Count >= i; i++)
{
//int.Parse(tableid.Rows[gateid][0].ToString())
Strid +="'"+ int.Parse(tableid.Rows[i][0].ToString()+"',";
// strWhere = "WSNC_Gateway.gatewayid='" + int.Parse(tableid.Rows[gateid][0].ToString()) + "' ";
if (!String.IsNullOrEmpty(Session["strWhereNodegateid"]))
{
strWhere += Session["strWhereNodegateid"].ToString();
}
}
string strWhere = "WSNC_Gateway.gatewayid in("+Strid.Substring(0,Strid.Length-1)+")";
string[] gateSet = new string[tableid.Rows.Count - 1];
strWhere = "WSNC_Gateway.gatewayid in("
for (int gateid = tableid.Rows.Count - 1; gateid >= 0; gateid--)
{
gateSet[i]= tableid.Rows[gateid][0].ToString();
}
strWhere +=String.Join(",",gateSet)+")";