显示部门下的所有员工


  Procedure ShowDeptUsers;
   
var s,aDept:String;
   aSqlQuery:TSqlQuery;
  
begin
    s:
='';
    aDept:
=DBComboBoxEh_Dept.value;
    aSQLQuery:
=TSQLQuery.Create(nil);
    
with aSQLQuery do try
      Close;SQL.Clear;
      SQLConnection:
=SQLConn;
      SQL.Add(
'Select USERID,UserName from users');
      SQL.Add(
'where SysID=:SysID ');
      ParamByName(
'SysID').AsInteger:=GetSysID;
      Open;
      First;
      
while not Eof do begin
        
if  UserHaveGroupByNo(FSysID, FieldbyName('UserID').AsInteger, gkDept, aDept) then begin
            s:
=s+FieldbyName('UserName').AsString;
            
if not Eof then  s:=s+',';
        
end;
        Next;
      
end;
       
if RightStr(s,1)=',' then s:=copy(s,1,length(s)-1)
       showmessage(
'这个部门下有以下登陆用户:'+s)
    
finally
      Free;
    
end;
  
end
原文地址:https://www.cnblogs.com/CNQCJ/p/1358474.html