;** Rm_0127 ********************************************************************
;*  Cheques Pre-Datados e nao apresentados/Vencimento                          *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 31/05/2001 por Anivel Augusto Rodrigues
;Ultima Alteracao: 20/07/2006 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes
;Ultima Alteracao: 21/11/2011 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes Cheque p/ deposito e otimiza‡äes                

;*******************************************************************************
;* Rotina p/ Selecionar e Ordernar Registros                                   *
;*******************************************************************************
Proc Seleciona()
ClearAll
{Ask} {MovCont} Check
Moveto [Codigo da Conta       ] TypeIn "~VSDGCONTA.."
Moveto [Tipo da Conta         ] TypeIn "C"
Moveto [Tipo Movimento        ] TypeIn "S"
Moveto [Tipo de Operacao      ] TypeIn "01 or 05 or 08 or 14"
Moveto [Data Cheque Descontado] TypeIn "Blank"
Moveto [Cheque Pre-Datado     ] TypeIn "S"
Moveto [Data Cheque Pre-Datado] TypeIn ">=~VSDGDTINI, <=~VSDGDTFIM"
Moveto [Numero do Cheque      ] TypeIn "Not Blank"
Do_It!
ClearAll

{Ask} {Answer} TypeIn "Fast Delete"
Moveto [Tipo de Operacao  ] TypeIn "08"
Moveto [Tipo do Lancamento] TypeIn "O or P"
Do_It!
ClearAll

Add "Answer" Tabela

EndProc   ; (Seleciona)

;*******************************************************************************
;* Rotina                                                                      *
;*******************************************************************************
Proc SD_Dialog(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_CONTA"         : Campo="NO"
            Case Campo="TG_DTINI"         : Campo="TG_CONTA"
            Case Campo="TG_DTFIM"         : Campo="TG_DTINI"
            Case Campo="YES" Or Campo="NO": Campo="TG_CONTA"
          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_CONTA" :
                         If Not IsBlank(VSDGCONTA)
                            Then If VSDGTPCONTA<>"C"
                                    Then Mensagem("Conta Invalida !")
                                         VSDGNOMCONTA=""
                                    Else Campo="TG_DTINI"
                                 EndIf
                            Else VSDGTPCONTA =""
                                 VSDGNOMCONTA=""
                                 Campo="TG_DTINI"
                         EndIf
                    Case Campo="TG_DTINI" :  Campo="TG_DTFIM"
                    Case Campo="TG_DTFIM" : Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
  Case Campo="TG_CONTA":
       MSG_CAMPO="Informe somente Conta 'C'orrente"
  Case Campo="":
     MSG_CAMPO=""
Endswitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

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

VSDGCONTA   =""
VSDGDTINI   =BlankDate()
VSDGDTFIM   =BlankDate()

While True
  ShowDialog "Cheques Pre-Datados e n„o Apresentados/Vencimentos" Proc "SD_Dialog"
  Trigger "OPEN","ARRIVE"
  Key "F1","ENTER","ESC","TAB",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140  
   @ 05,08   Height 09 Width 61

    Label  @ 00,00 "Conta"  For "TG_CONTA"
    Accept @ 01,01 Width 07 "A4"  Picture "#*#" Tag "TG_CONTA"    To VSDGCONTA
    Accept @ 01,09 Width 23 "A20" Picture "!*!" Tag "TG_NOMCONTA" To VSDGNOMCONTA

    Label  @ 02,00 "Per¡odo Referente" For "TG_DTINI"
    Label  @ 03,00 "de" For "TG_DTINI"
    Accept @ 03,04 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTINI" To VSDGDTINI
    Label  @ 03,17 "at‚" For "TG_DTFIM"
    Accept @ 03,22 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTFIM" To VSDGDTFIM

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

  EndDialog
  If Not RetVal Then QuitLoop EndIf

  If VSDGDTFIM=BlankDate()
     Then Mensagem("Data Final Invalida !")
          Loop
  EndIf

  DISPOSITIVO()
  If OK="" Then Loop EndIf

  AGUARDE("Aguarde, Gerando Relatorio")
  Tabela=Cria_Temp(PrivDir())
  Copy "\\Base\\Sistemas\\Ctacor\\Rm_0120" Tabela

  Seleciona()

  If IsEmpty(Tabela)
     Then MENSAGEM("N„o existem registros a processar")
          Delete Tabela
          Loop
  EndIf

  IMPRIREL(Tabela,"3")

  Delete Tabela

EndWhile
ClearAll
Release Vars All
Release Procs All

