str=" (OP='"+username+"' OR INPUTBY='"+username+"' OR CUSTSERVICE='"+username+"')";
str=" (OP='"+username+"' OR INPUTBY='"+username+"' OR CUSTSERVICE='"+username+"' OR SALE='" +username+"')";
}
elseif(visiblerange=="3")
{
str=" (OP='"+username+"' OR INPUTBY='"+username+"' OR CUSTSERVICE='"+username+"')";
str=" (OP='"+username+"' OR INPUTBY='"+username+"' OR CUSTSERVICE='"+username+"' OR SALE='" +username+"')";
}
elseif(visiblerange=="2")
{
varrangeDa=newRangeDA();
vardeptid=rangeDa.GetDEPTGID(userid);
str=" (OP in (select SHOWNAME from vw_user where deptgid='"+deptid+"') OR INPUTBY in (select SHOWNAME from vw_user where deptgid='"+deptid+"') OR CUSTSERVICE in (select SHOWNAME from vw_user where deptgid='"+deptid+"') ) ";
str=" (OP in (select SHOWNAME from vw_user where deptgid='"+deptid+"') OR INPUTBY in (select SHOWNAME from vw_user where deptgid='"+deptid+"') OR CUSTSERVICE in (select SHOWNAME from vw_user where deptgid='"+deptid+"') OR SALE in (select SHOWNAME from vw_user where deptgid='" +deptid+"')) ";
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");
str=" (OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"'";
}
else
{
str=str+" or OP='"+Convert.ToString(reader["SHOWNAME"])+"' OR INPUTBY='"+Convert.ToString(reader["SHOWNAME"])+"' OR CUSTSERVICE='"+Convert.ToString(reader["SHOWNAME"])+"'";
};
}
str=str+")";
reader.Close();
}
//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");
// str = str + " or OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR INPUTBY='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
// };
// }
// str = str + ")";
// reader.Close();
//}
str=" EXISTS (select 1 from user_authority_range_op P left join [user] u on (u.GID=P.OPID) where (OP_APPLY.OP=U.SHOWNAME OR OP_APPLY.SALE=U.SHOWNAME OR OP_APPLY.CUSTSERVICE=U.SHOWNAME OR OP_APPLY.INPUTBY=U.SHOWNAME ) AND P.userid='"+userid+"' and P.AUTHORITYID='"+AUTHORITYID+"' and P.VISIBLERANGE=1) ";