;** Limpa_OC *******************************************************************
;** Exclusao do Pedidos de Compras                                             *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 26/09/2001 por Douglas Rodrigeus
;Ultima Alteracao: 03/02/2005 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes SITUACAO CANCELADA
;Ultima Alteracao: 19/09/2016 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes showdialog                   
;Ultima Alteracao: 19/11/2009 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes logica

;*******************************************************************************
;** Seleciona Registros                                                        *
;*******************************************************************************
Proc SELECIONA()
private tabelaref

ClearAll

{Ask} {Occ}
Moveto [Numero da OC      ] check
Moveto [Codigo da Empresa ] TypeIn "~VSDGEMPRESA.."
Moveto [Data de Emissao   ] TypeIn ">=~VSDGDTINI, <=~VSDGDTFIM"
Moveto [Situacao da OC    ] TypeIn "~SITUACAO.."
Do_It!
ClearAll
if isempty("Answer")
   then return
endif   
tabelaref=adiciona_indice_temp("Numero da OC")

{ask} typein tabelaref Enter
Moveto [Numero da OC ] Example "num"
{Ask} {OcI} TypeIn "Fast Delete"
Moveto [Numero da OC ] Example "num"
Do_It!
ClearAll

{ask} typein tabelaref Enter
Moveto [Numero da OC ] Example "num"
{Ask} {OcV} TypeIn "Fast Delete"
Moveto [Numero da OC ] Example "num"
Do_It!
ClearAll

{ask} typein tabelaref Enter
Moveto [Numero da OC ] Example "num"
{Ask} {Occ} TypeIn "Fast Delete"
Moveto [Numero da OC ] Example "num"
Do_It!
ClearAll

delete tabelaref

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_EMPRESA"       : Campo="NO"
            Case Campo="TG_SITUACAO"      : Campo="TG_EMPRESA"
            Case Campo="TG_DTINI"         : Campo="TG_SITUACAO"
            Case Campo="TG_DTFIM"         : Campo="TG_DTINI"
            Case Campo="YES" Or Campo="NO": Campo="TG_EMPRESA"
          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_EMPRESA" :Campo="TG_SITUACAO"
                    Case Campo="TG_SITUACAO":
                         VSDGSITUACAO=ControlValue("TG_SITUACAO")
                         If IsBlank(VSDGSITUACAO)
                            Then VSDGSITUACAO="TODOS"
                                 SITUACAO=""
                            Else SITUACAO=VSDGSITUACAO
                         EndIf
                         Campo="TG_DTINI"
                    Case Campo="TG_DTINI"   :Campo="TG_DTFIM"
                    Case Campo="TG_DTFIM"   :Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
  Case Campo="TG_DTFIM":
     MSG_CAMPO="Informe a Data Final"
  Case Campo="TG_SITUACAO":
    MSG_CAMPO="E=Entregue  C=Cancelada  Em Branco = Todos"
Endswitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

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

VSDGEMPRESA =""
VSDGSITUACAO=""
SITUACAO    =""
VSDGDTINI   =BlankDate()
VSDGDTFIM   =BlankDate()

While True

  ShowDialog "Exclus„o de Ordens de Compra" Proc "SD_Dialog"
  Trigger "OPEN","ARRIVE"
  Key "F1","ENTER","ESC","TAB",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140  
   @ 05,12   Height 11 Width 72

    Label  @ 00,00 "Empresa"  For "TG_EMPRESA"
    Accept @ 01,01 Width 07 "A4"  Picture "[&,#][#*#]" Tag "TG_EMPRESA"    To VSDGEMPRESA
    Accept @ 01,09 Width 25 "A20" Picture "!*!" Tag "TG_NOMEMPRESA" To VSDGNOMEMP

    Label  @ 02,00 "Situacao"  For "TG_SITUACAO"
    Accept @ 03,01 Width 33 "A9"  Picture "ENTREGUE,CANCELADA" Tag "TG_SITUACAO"  To VSDGSITUACAO

    Label  @ 04,00 "Per¡odo de EmissÆo de" For "TG_DTINI"
    Accept @ 05,03 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTINI" To VSDGDTINI
    Label  @ 05,16 "at‚" For "TG_DTFIM"
    Accept @ 05,21 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTFIM" To VSDGDTFIM

    Pushbutton @ 07,22 width 11 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 07,36 width 11 "~C~ancela" CANCEL                    Tag "NO"  To BottonValue

  EndDialog
  If Not RetVal Then QuitLoop EndIf

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

  AGUARDE("Aguarde, Excluindo Dados")

  SELECIONA()

  MENSAGEM("Opera‡„o Finalizada !")

EndWhile
ClearAll
Release Vars All
Release Procs All

