strSql.Append(",(select showname from [user] where gid=info_client.MODIFIEDUSER) MODIFIEDUSERREF,ESHORTNAME,WMSFEERATETYPE ");
strSql.Append(",(select top 1 name from company where gid=CORPID)[CORPNAME] ");
strSql.Append(",ISNULL((select COUNT(1) CT from Receipt_Doc d left join info_client_contract c on (c.GID=D.BSNO) where C.LINKID=info_client.GID),0) as CONTRACTCT ");
strSql.Append(",case WHEN BLSTATUS=0 THEN '合作客户' else '潜在客户' end CUSTPROP");
strSql.Append(",(select showname from [user] where gid=info_client.MODIFIEDUSER) MODIFIEDUSERREF,ESHORTNAME,WMSFEERATETYPE ");
strSql.Append(",(select top 1 name from company where gid=CORPID)[CORPNAME] ");
strSql.Append(",ISNULL((select COUNT(1) CT from Receipt_Doc d left join info_client_contract c on (c.GID=D.BSNO) where C.LINKID=info_client.GID),0) as CONTRACTCT ");
strSql.Append(",case WHEN BLSTATUS=0 THEN '合作客户' else '潜在客户' end CUSTPROP");
strSql.Append(",(select showname from [user] where gid=info_client.MODIFIEDUSER) MODIFIEDUSERREF,ESHORTNAME,WMSFEERATETYPE ");
strSql.Append(",(select top 1 name from company where gid=CORPID)[CORPNAME] ");
strSql.Append(",ISNULL((select COUNT(1) CT from Receipt_Doc d left join info_client_contract c on (c.GID=D.BSNO) where C.LINKID=info_client.GID),0) as CONTRACTCT ");
strSql.Append(",case WHEN BLSTATUS=0 THEN '合作客户' else '潜在客户' end CUSTPROP");
strSql.Append(",(select showname from [user] where gid=info_client.MODIFIEDUSER) MODIFIEDUSERREF,ESHORTNAME,WMSFEERATETYPE ");
strSql.Append(",(select top 1 name from company where gid=CORPID)[CORPNAME] ");
strSql.Append(",ISNULL((select COUNT(1) CT from Receipt_Doc d left join info_client_contract c on (c.GID=D.BSNO) where C.LINKID=info_client.GID),0) as CONTRACTCT ");
str=" (CREATEUSER='"+userid+"' or GID IN (SELECT LINKID FROM info_client_contract_range WHERE USERID='"+userid+"'))";
}
elseif(visiblerange=="3")
{
str=" (CREATEUSER='"+userid+"')";
str=" (CREATEUSER='"+userid+"' or GID IN (SELECT LINKID FROM info_client_contract_range WHERE USERID='" +userid+"'))";
}
elseif(visiblerange=="2")
{
varrangeDa=newRangeDA();
vardeptid=rangeDa.GetDEPTGID(userid);
str=" DEPTGID='" +deptid+"' ";
str=" (DEPTGID='" +deptid+"' or GID IN (SELECT LINKID FROM info_client_contract_range WHERE USERID='" +userid+"'))";
}
elseif(visiblerange=="1")
{
str=" CREATEUSER in (select USERID from vw_user where COMPANYID='" +companyid+"') ";
str=" (CREATEUSER in (select USERID from vw_user where COMPANYID='" +companyid+"') or GID IN (SELECT LINKID FROM info_client_contract_range WHERE USERID='" +userid+"'))";
}
elseif(visiblerange=="5")
{
str=" CREATEUSER in (select USERID from vw_user where COMPANYID IN (select COMPANYID from user_authority_range_company where userid='" +userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1)) ";
str=" (CREATEUSER in (select USERID from vw_user where COMPANYID IN (select COMPANYID from user_authority_range_company where userid='" +userid+"' and AUTHORITYID='"+AUTHORITYID+"' and VISIBLERANGE=1)) or GID IN (SELECT LINKID FROM info_client_contract_range WHERE USERID='" +userid+"'))";
}
elseif(visiblerange=="6")
{
str=" EXISTS (select 1 from user_authority_range_op P left join [user] u on (u.GID=P.OPID) where (info_client_contract.CREATEUSER=U.GID) AND P.userid='" +userid+"' and P.AUTHORITYID='"+AUTHORITYID+"' and P.VISIBLERANGE=1) ";
str=" (EXISTS (select 1 from user_authority_range_op P left join [user] u on (u.GID=P.OPID) where (info_client_contract.CREATEUSER=U.GID) AND P.userid='" +userid+"' and P.AUTHORITYID='"+AUTHORITYID+"' and P.VISIBLERANGE=1) or GID IN (SELECT LINKID FROM info_client_contract_range WHERE USERID='" +userid+"')) ";
//var userstr = new StringBuilder();
//userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");