begin
   if dm_base.qryDepartment.RecordCount<>0 then
   begin
     with dm_base.qryDepartment do
     begin
       close;
       sql.Clear;
       sql.Add('select * from syst_Department where state<2');
       open;
       if dm_base.qryDepartment.Locate('deptuid',dm_base.qryEmployee.Fieldbyname('deptid').AsInteger,[]) then
       begin
         application.MessageBox('此部门下有员工不能删除',gstrTitl,MB_ICONERROR+MB_OK);
         abort;
       end;
    end;
    if application.MessageBox('真的要删除吗?',gstrTitl,mb_iconquestion+mb_yesno)=idyes   then
    begin
      with dm_base.qrydepartment do
      begin
        edit;
        fieldbyname('state').AsInteger :=2;
        post;
      end;
      end;
   end
   else
  application.MessageBox('请选中部门',gstrTitl,mB_ICONERROR+MB_OK);end;