str=" S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))";
//str = " S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))";
str=$" exists(select 1 from vw_user where SHOWNAME =S.OP and COMPANYID='{companyid}' and DEPTNAME='{deptname}')";
}
elseif(visiblerange=="1")
{
str=" S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"')) ";
//str = " S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "')) ";
str=$" exists(select 1 from vw_user where SHOWNAME =S.OP and COMPANYID='{companyid}' )";
str=" S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))";
//str = " S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))";
str=$" exists(select 1 from vw_user where SHOWNAME =S.OP and COMPANYID='{companyid}' and DEPTNAME='{deptname}')";
}
elseif(visiblerange=="1")
{
str=" S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"')) ";
//str = " S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "')) ";
str=$" exists(select 1 from vw_user where SHOWNAME =S.OP and COMPANYID='{companyid}' )";
str=" S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))";
//str = " S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))";
str=$" exists(select 1 from vw_user where SHOWNAME =S.OP and COMPANYID='{companyid}' and DEPTNAME='{deptname}')";
}
elseif(visiblerange=="1")
{
str=" S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"')) ";
//str = " S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "')) ";
str=$" exists(select 1 from vw_user where SHOWNAME =S.OP and COMPANYID='{companyid}' )";
str=" (B.OP in (select showname from vw_user where deptgid='"+deptid+"') OR B.SALE in (select showname from vw_user where deptgid='"+deptid+"') OR B.CUSTSERVICE in (select showname from vw_user where deptgid='"+deptid+"') "
+" OR B.DOC in (select showname from vw_user where deptgid='"+deptid+"') OR B.FRCUSTSERVICE in (select showname from vw_user where deptgid='"+deptid+"') OR B.INPUTBY in (select showname from vw_user where deptgid='"+deptid+"'))";
//str = " (B.OP in (select showname from vw_user where deptgid='" + deptid + "') OR B.SALE in (select showname from vw_user where deptgid='" + deptid + "') OR B.CUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') "
//+ " OR B.DOC in (select showname from vw_user where deptgid='" + deptid + "') OR B.FRCUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') OR B.INPUTBY in (select showname from vw_user where deptgid='" + deptid + "'))";
str=$" exists(select 1 from vw_user where SHOWNAME in (B.OP,B.SALE,B.CUSTSERVICE,B.FRCUSTSERVICE,B.INPUTBY) and COMPANYID='{companyid}' and deptgid='{deptid}')";
str=" (OP in (select showname from vw_user where deptgid='"+deptid+"') OR SALE in (select showname from vw_user where deptgid='"+deptid+"') OR CUSTSERVICE in (select showname from vw_user where deptgid='"+deptid+"') "
+" OR DOC in (select showname from vw_user where deptgid='"+deptid+"') OR FRCUSTSERVICE in (select showname from vw_user where deptgid='"+deptid+"') OR INPUTBY in (select showname from vw_user where deptgid='"+deptid+"'))";
//str = " (OP in (select showname from vw_user where deptgid='" + deptid + "') OR SALE in (select showname from vw_user where deptgid='" + deptid + "') OR CUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') "
//+ " OR DOC in (select showname from vw_user where deptgid='" + deptid + "') OR FRCUSTSERVICE in (select showname from vw_user where deptgid='" + deptid + "') OR INPUTBY in (select showname from vw_user where deptgid='" + deptid + "'))";
str=$" exists(select 1 from vw_user where SHOWNAME in(OP,SALE,DOC,INPUTBY,CUSTSERVICE,FRCUSTSERVICE) and deptgid='{deptid}') ";
str=" (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"') and GID in (select userid from user_baseinfo where DEPTNAME='"+deptname+"'))"
+" OR CREATEUSER in (select GID from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"') and GID in (select userid from user_baseinfo where DEPTNAME='"+deptname+"')))";
//str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))"
//+ " OR CREATEUSER in (select GID from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')))";
str=$" exists(select 1 from vw_user where SHOWNAME in(OP,CREATEUSER) and COMPANYID='{companyid}'and DEPTNAME='{deptname}') ";