;** Consulta Duplicatas ********************************************************
;*  Consulta de Duplicatas                                                     *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 16/06/2006 por Jose Luis Ameno da Silva
;Ultima Alteracao:
;Motivo Alteracao:

;*******************************************************************************
;* Rotina para Controlar Chave da Nota Fiscal                                  *
;*******************************************************************************
Proc CHAVEC()

While True
  Moveto "Dupc"
  Moveto [Codigo da Empresa]

  While True

        MSGCAMPO=Field()
        TECLA=" Esc=Sair  "
        If OPCAO_FORM="F"
           Then TECLA=TECLA+"Enter=Visualizar  Ctrl+Z=Pesquisar  Alt+Z=Pr˘ximo "
           Else If Table()="Dupc"
                   Then TECLA=TECLA+"Enter=Rela‡„o  Ctrl+Z=Pesquisar  Alt+Z=Pr˘ximo"
                   Else If Table()="Dupnf" Or Table()="Dupi"
                           Then TECLA=TECLA+"Ctrl+Z=Pesquisar  Alt+Z=Pr˘ximo"
                        Endif
                Endif
        EndIf

        Prompt TECLA

        Wait Field
          Message MSGCAMPO
          Until "ESC","ENTER","F2","F7","HOME","UP","PGDN","FIELDVIEW","PGUP",
                "DOWN","ZOOM","ZOOMNEXT","END","LEFT","RIGHT"

        If SubStr(RetVal,1,2)="-1"
           Then SYS_TECLA_ACIONADA=RetVal
                Seta_Tecla_Acionada()
                RetVal="ESC"
        EndIf

        Switch

;          Case RetVal = "F3" Or RetVal = "F4":
;               KeyPress RetVal
          Case RetVal="LEFT":
               LEFT
          Case RetVal="RIGHT":
               RIGHT
          Case RetVal = "ZOOM":
               PESQUISA()
               Loop
          Case RetVal = "ZOOMNEXT":
               PESQUISACON()
               Loop
          Case RetVal="HOME":
               HOME
          Case RetVal="END":
               END
          Case RetVal="PGUP":
               PGUP
;               If OPCAO_FORM="2"
;                  Then If Table()="Dupc"
;                          Then Moveto [Codigo da Empresa]
;                       Endif
;               Endif
          Case RetVal="PGDN":
               PGDN
          Case RetVal="UP":
               If OPCAO_FORM="F" And Not Bot() Or Table()="Dupi" And Not Bot()
                  Then UP
               Endif
          Case RetVal="DOWN":
               If OPCAO_FORM="F" Or Table()="Dupi"
                  Then DOWN
               Endif
          Case RetVal="ENTER":
               If OPCAO_FORM="F"
                  Then OPCAO_FORM="2"
                  Else OPCAO_FORM="F"
               EndIf
               CHAVEC=5
               Return
          Case Retval="ESC":
               CHAVEC=9
               If OPCAO_FORM="F"
                  Then Return
               Endif
               OPCAO_FORM="F"
               CHAVEC=5
               Return
        EndSwitch
  EndWhile
EndWhile
EndProc   ; (ChaveC)

;*******************************************************************************
;* Rotina Principal Consulta Requisicoes                                       *
;*******************************************************************************
AutoLib="\\Sistemas\\Cadastro\\Bibliot,\\Sistemas\\Cadastro\\Bib_Show"

If Not IsAssigned(SYS_EMPRESA_DEFAULT) Then SYS_EMPRESA_DEFAULT="" EndIf
If Not IsAssigned(SYS_CODIGO_CLIENTE)  Then SYS_CODIGO_CLIENTE=""  EndIf
If Not IsAssigned(SYS_CONTROLE_DIA)    Then SYS_CONTROLE_DIA=""    EndIf

PARAM_EMPRESA=SYS_EMPRESA_DEFAULT

View "Dupc"
;************** Rotina para tratar o erro de tabela locada ********************
If ErrorCode()=4
   Then Do_It!
        ClearAll
        Release Vars All
        Release Procs All
        return
EndIf

PickForm "F"
OPCAO_FORM="F"

While True
  CHAVEC()
  If CHAVEC=9 Then QuitLoop EndIf
  If CHAVEC=5
     Then Moveto "Dupc"
          If OPCAO_FORM="F"
             Then PickForm "F"
             Else PickForm "2"
          EndIf
          Loop
  EndIf
EndWhile
Do_It!
ClearAll
Release Procs CHAVEC
