;** Rc_0022 *******************************************************************
;* Relacao de Clientes Obs                                                 *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 02/04/2008 por Nikolas
;Ultima Alteracao:   /  /2008 por
;Motivo Alteracao: Ajustes

;*******************************************************************************
;* Rotina p/ Selecionar e Order Registros                                      *
;*******************************************************************************
Proc Seleciona()

{Ask} {Destinat} Check
Moveto [Tipo  ] TypeIn "C"
Moveto [Codigo] TypeIn ">=~VSDGDESTINATINI, <=~VSDGDESTINATFIM"
Moveto [Inativo]
Switch
  Case VSDGSTATUS="1": TypeIn "N"
  Case VSDGSTATUS="2": TypeIn "S"
EndSwitch
Do_It!
ClearAll

EndProc ; (Seleciona)
;*******************************************************************************
;* 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_DESTINATINI"    : Campo="NO"
            Case Campo="TG_DESTINATFIM"    : Campo="TG_DESTINATINI"
            Case Campo="TG_STATUS"         : Campo="TG_DESTINATFIM"
            Case Campo="YES" Or Campo="NO" : Campo="TG_DESTINATINI"
          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_DESTINATINI" :Campo="TG_DESTINATFIM"
                    Case Campo="TG_DESTINATFIM" :
                         If VSDGDESTINATFIM < VSDGDESTINATINI
                            Then Mensagem("Codigo final menor que codigo inicial !")
                            Else Campo="TG_STATUS"
                         EndIf
                    Case Campo="TG_STATUS" :Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

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

VSDGDESTINATINI  =""
VSDGDESTINATFIM  =""
VSDGSTATUS       =""

While True

  ShowDialog "Relacao de Clientes Obs" 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 10 Width 56

    Label  @ 01,00 "Cliente"  For "TG_DESTINATINI"
    Label  @ 02,01 "de"  For "TG_DESTINATINI"
    Accept @ 02,05 Width 07 "A4"  Picture "[&,#][#*#]" Tag "TG_DESTINATINI" To VSDGDESTINATINI
    Label  @ 02,12 "at‚"  For "TG_DESTINATFIM"
    Accept @ 02,17 Width 07 "A4"  Picture "[&,#][#*#]" Tag "TG_DESTINATFIM" To VSDGDESTINATFIM

    Label  @ 03,00 "Status do Cliente" For "TG_STATUS"
    Accept @ 04,01 Width 04 "A1"  Picture "1,2,3" Tag "TG_STATUS" To VSDGSTATUS
    Accept @ 04,06 Width 23 "A12" Picture "!*!" Tag "TG_NOMSTATUS" To VSDGNOMSTATUS

    Pushbutton @ 06,14 width 11 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 06,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 Ficha Cadastral")
  Seleciona()

  If IsEmpty("Answer")
     Then MENSAGEM("N„o Existem Registros a Processar")
          Loop
  EndIf

  CopyReport "\\Base\\Sistemas\\Cadastro\\Rm_0022" "R" "Answer" "R"

  IMPRIREL("Answer","R")

  Delete "Answer"

EndWhile
ClearAll
Release Vars All
Release Procs All
