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 INPUTBY 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 SALE 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 CUSTSERVICE 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 = " (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 INPUTBY 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 SALE 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 CUSTSERVICE 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 in(OP, SALE,DOC ,CUSTSERVICE) and COMPANYID='{companyid}' and DEPTNAME='{deptname}')";
}
elseif(visiblerange=="1")
{
str=" (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR CUSTSERVICE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"')))";
//str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
// + " OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
//+ " OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
//+ " OR CUSTSERVICE 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 in(OP, SALE,DOC ,CUSTSERVICE) and COMPANYID='{companyid}' )";
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 INPUTBY 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 SALE 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 DOC 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 CUSTSERVICE 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 = " (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 INPUTBY 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 SALE 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 DOC 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 CUSTSERVICE 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 in(OP,INPUTBY, SALE,DOC ,CUSTSERVICE) and COMPANYID='{companyid}' and DEPTNAME='{deptname}')";
}
elseif(visiblerange=="1")
{
str=" (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR DOC in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR CUSTSERVICE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"')))";
//str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
// + " OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
//+ " OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
//+ " OR DOC in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
//+ " OR CUSTSERVICE 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 in(OP,INPUTBY, SALE,DOC ,CUSTSERVICE) and COMPANYID='{companyid}' )";
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 INPUTBY 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 SALE 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 CUSTSERVICE 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 = " (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 INPUTBY 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 SALE 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 CUSTSERVICE 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 in(OP,INPUTBY, SALE ,CUSTSERVICE) and COMPANYID='{companyid}' and DEPTNAME='{deptname}')";
str=" (b.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 b.SALE 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 b.DOC 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 b.CUSTSERVICE 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 = " (b.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 b.SALE 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 b.DOC 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 b.CUSTSERVICE 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 in(b.OP, b.SALE,b.DOC ,b.CUSTSERVICE) and COMPANYID='{companyid}' and DEPTNAME='{deptname}')";
}
elseif(visiblerange=="1")
{
str=" (b.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR b.SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR b.DOC in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" OR b.CUSTSERVICE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='"+companyid+"'))"
+" )";
//str = " (b.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
//+ " OR b.SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
//+ " OR b.DOC in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))"
//+ " OR b.CUSTSERVICE 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 in(b.OP, b.SALE,b.DOC ,b.CUSTSERVICE) and COMPANYID='{companyid}')";
str=" (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID=(select GID from [company] where codename='" + companyid + "')) and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')))";
//+ " OR INPUTBY 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 = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID=(select GID from [company] where codename='" + companyid + "')) and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')))";
////+ " OR INPUTBY 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 =OP and COMPANYID='{companyid}' and DEPTNAME='{deptname}')";
}
elseif(visiblerange=="1")
{
str=" (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID=(select GID from [company] where codename='"+companyid+"'))))";
//+ " OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "')))";
//str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID=(select GID from [company] where codename='" + companyid + "'))))";
// //+ " OR INPUTBY 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 =OP and COMPANYID='{companyid}')";