;*** ACCLIE ********************************************************************
;* Rotina p/ Inativar Clientes Duplicados                                      *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 20/11/2012 por Bruno Carvalho
;Ultima Alteracao:   /  /     por 
;Motivo Alteracao: 

;*******************************************************************************
;* ROTINA PARA LOCALIZAR CLIENTE                                               *
;*******************************************************************************
Proc Localiza_Cliente()

SetDir "\\Sistemas\\Cadastro"

NR=NRecords("Destinat")

Tabela=Cria_Temp(PrivDir())
Copy "Destinat" Tabela

Debug
View "Destinat"
Coedit Tabela
Scan
  Barra(NR, RecNo())
  Aguarde("Inativando Clientes Duplicados "+BARRA_STRING) 
  
  CPF = [CGC]
  If CPF = "000.000.000-00"     Or
     CPF = "00.000.000/0000-00" Or
     IsBlank(CPF)               Or
     CPF = "" 
     Then Loop
  EndIf   
  
  Moveto "Destinat"
  Moveto [CGC]
  Locate CPF
  If RetVal
     Then While CPF=[CGC]
            Skip
            If Eot() Then QuitLoop EndIf
                                             
            Locate Next CPF                                                   
            If RetVal
               Then [Inativo]="S"
            EndIf 
          EndWhile
  EndIf        
  
  Moveto Tabela
EndScan  
Do_It!
ClearAll

EndProc ; Localiza_Cliente()

;*******************************************************************************
;* ROTINA PRINCIPAL                                                            *
;*******************************************************************************
AutoLib="\\Sistemas\\Cadastro\\Bib_Show,\\Sistemas\\Cadastro\\Bibliot"
LimpAguarde()

Localiza_Cliente()

Mensagem("Procedimento executado com Sucesso !")
ClearAll

Release Vars All
Release Procs All