;** Limpa_OR *******************************************************************
;** Exclusao de Orcamentos                                                     *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 08/11/1996 por Anivel Augusto Rodrigues
;Ultima Alteracao: 22/01/2000 por Anivel Augusto Rodrigues
;Motivo Alteracao: ShowDialog e novas variaveis
;Ultima Alteracao: 30/01/2012 por Anivel Augusto Rodrigues
;Motivo Alteracao: InclusÆo ORCACPG              

;*******************************************************************************
;** Seleciona Registros                                                        *
;*******************************************************************************
Proc SELECIONA()
ClearAll

{Ask} {OrcaC}
Moveto [Numero do Orcamento ] Example "num"
Moveto [Codigo da Empresa   ] TypeIn "~VSDGEMPRESA.."
Moveto [Data de Validade    ] TypeIn ">=~VSDGDTINI, <=~VSDGDTFIM"
{Ask} {OrcaI} TypeIn "Fast Delete"
Moveto [Numero do Orcamento ] Example "num"
Do_It!
ClearAll

{Ask} {OrcaC}
Moveto [Numero do Orcamento ] Example "num"
Moveto [Codigo da Empresa   ] TypeIn "~VSDGEMPRESA.."
Moveto [Data de Validade    ] TypeIn ">=~VSDGDTINI, <=~VSDGDTFIM"
{Ask} {OrcaCPG} TypeIn "Fast Delete"
Moveto [Numero do Orcamento ] Example "num"
Do_It!
ClearAll

{Ask} {OrcaC} TypeIn "Fast Delete"
Moveto [Codigo da Empresa    ] TypeIn "~VSDGEMPRESA.."
Moveto [Situacao do Orcamento] TypeIn "~VSDGSITUACAO.."
Moveto [Data de Validade     ] TypeIn ">=~VSDGDTINI, <=~VSDGDTFIM"
Do_It!
ClearAll
EndProc

;*******************************************************************************
;* 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")
                         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="C=Cancelado F=Faturado 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=""
VSDGDTINI   =BlankDate()
VSDGDTFIM   =BlankDate()

While True

  ShowDialog "Exclus„o de Or‡amentos" 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 56

    Label  @ 00,00 "Empresa"  For "TG_EMPRESA"
    Accept @ 01,01 Width 07 "A4"  Picture "[&,#][#*#]" Tag "TG_EMPRESA"    To VSDGEMPRESA
    Accept @ 01,09 Width 23 "A20" Picture "!*!" Tag "TG_NOMEMPRESA" To VSDGNOMEMP
    Label  @ 02,00 "Situa‡„o" For "TG_SITUACAO"
    Accept @ 03,01 Width 12 "A9"  Picture "FATURADO,CANCELADO" Tag "TG_SITUACAO"   To VSDGSITUACAO

    Label  @ 04,00 "Per¡odo Referente" For "TG_DTINI"
    Label  @ 05,00 "de" For "TG_DTINI"
    Accept @ 05,04 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTINI" To VSDGDTINI
    Label  @ 05,17 "at‚" For "TG_DTFIM"
    Accept @ 05,22 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTFIM" To VSDGDTFIM
    @ 04,19 ?? "(Data de Validade)"

    Pushbutton @ 07,14 width 11 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 07,28 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

  If Not Verifica_Usuario() Then Loop EndIf

  AGUARDE("Aguarde, Excluindo Dados")
  SELECIONA()
  MENSAGEM("Opera‡„o Finalizada !")

EndWhile
ClearAll
Release Vars All
Release Procs All

