;** Rc_0140 ********************************************************************
;*  Listagem da Lista Telef“nica                                               *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 22/10/1997 por Anivel Augusto Rodrigues
;Ultima Alteracao: 02/04/2004 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes

;*******************************************************************************
;* Rotina p/ Selecionar e Order Registros                                      *
;*******************************************************************************
Proc ORDEM()
{Ask} {Listfone} Check
Do_It!
ClearAll
EndProc ; (Ordem)

;*******************************************************************************
;* Rotina                                                                      *
;*******************************************************************************
Proc SD_Dialog1(Disparo,Campo,Evento,Elemento)
Temp=True
MSG_CAMPO=""
TECLA=""
If Disparo="OPEN"  Then AoCriarShowDialog() EndIf
If Disparo="EVENT" And Evento["Type"]="KEY" Then
   Switch
     Case Evento["KeyCode"] = 9: Temp=False
     Case Evento["KeyCode"] = -59: Dialog_F1()
     Case Evento["KeyCode"] =  27:
          Temp=False
          Switch
            Case Campo="TG_OPRELCODALF"    : Campo="NO"
            Case Campo="YES" Or Campo="NO" : Campo="TG_OPRELCODALF"
          EndSwitch
     Case (Evento["KeyCode"] <= -104 And Evento["KeyCode"] >= -113) Or 
           Evento["KeyCode"]  = -139 Or  Evento["KeyCode"]  = -140:
           SYS_TECLA_ACIONADA=Evento["KeyCode"]
           Seta_Tecla_Acionada()
           CancelDialog
     Case Evento["KeyCode"] = 13:
          Temp=False
          If Checa_TAG()
             Then Switch
                    Case Campo="TG_OPRELCODALF" :
                         If VSDGOPRELCODALF="1"
                            Then VSDGNOMOPRELCODALF="CODIGO"
                            Else VSDGNOMOPRELCODALF="CIDADE/BAIRRO"
                         EndIf
                         Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
  Case Campo="TG_OPRELCODALF":
       MSG_CAMPO="Op‡”es: 1=Codigo  2=Cidade/Bairro"
EndSwitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc
;*******************************************************************************
;* ROTINA PRINCIPAL                                                            *
;*******************************************************************************
AutoLib="\\Sistemas\\Cadastro\\Bib_Show,\\Sistemas\\Cadastro\\Bibliot"
LimpAguarde()

VSDGOPRELCODALF  =""

While True

  ShowDialog "Relat˘rio da Lista Telef“nica" Proc "SD_Dialog1"
  Trigger "OPEN","ARRIVE"
  Key "F1","ENTER","ESC","TAB",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140  
   @ 06,12   Height 07 Width 56

    Label  @ 01,00 "Ordem" For "TG_OPRELCODALF"
    Accept @ 01,07 Width 04 "A1"  Picture "1,2" Tag "TG_OPRELCODALF" To VSDGOPRELCODALF
    Accept @ 01,12 Width 25 "A20" Picture "!*!" Tag "TG_NOMOPRELCODALF" To VSDGNOMOPRELCODALF

    Pushbutton @ 03,14 width 11 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 03,28 width 11 "~C~ancela" CANCEL                    Tag "NO"  To BottonValue

  EndDialog
  If Not RetVal Then QuitLoop EndIf

  DISPOSITIVO()
  If OK="" Then Loop EndIf

  AGUARDE("Aguarde, gerando relat˘rio")
  ORDEM()
  If IsEmpty("Answer")
     Then MENSAGEM("N„o Existem Registros a Processar")
          Loop
  EndIf

  If VSDGOPRELCODALF = "1" Then CopyReport "\\Base\\Sistemas\\Cadastro\\Listfone" "R"  "Answer" "R" EndIf
  If VSDGOPRELCODALF = "2" Then CopyReport "\\Base\\Sistemas\\Cadastro\\Listfone" "1"  "Answer" "R" EndIf

  IMPRIREL("Answer","R")

  Delete "Answer"

EndWhile
ClearAll
Release Vars All
Release Procs All
