;** Rc_0010 *******************************************************************
;*  Relatorio de Estados e Aliquotas de ICMS                                   *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 05/12/95 por Anivel Augusto Rodrigues
;Ultima Alteracao: 09/09/2016 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes showdialog
;Ultima Alteracao: 23/12/2016 por Rafael Matos
;Motivo Alteracao: Ajustes showdialog
;Ultima Alteracao: 18/05/2020 por Bruno Carvalho
;Motivo Alteracao: Alterado CopyReport "...\\Vendas\\Estados" p/ "...\\Vendas\\RM_0043"                   

;*******************************************************************************
;* Rotina p/ Selecionar e Ordernar Registros                                   *
;*******************************************************************************
Proc SELECIONA()

{Ask} {Estados} Check
Do_It!
ClearAll
CopyReport "\\Base\\Sistemas\\Vendas\\RM_0043" "1" "Answer" "R"
EndProc

;*******************************************************************************
;* Rotina                                                                      *
;*******************************************************************************
Proc SD_Dialog(Disparo,Campo,Evento,Elemento)
Temp=True
If Disparo="OPEN"  
   Then 
        ;AoCriarShowDialog()
        TiraSombraShowDialog()
EndIf   
If Disparo="EVENT" And Evento["Type"]="KEY" Then
   Switch
     Case Evento["KeyCode"] = -59: Dialog_F1()
     Case Evento["KeyCode"] =  27:
          Temp=False
          Switch
            Case Campo="YES": Campo="NO"
            Case Campo="NO" : Campo="YES"
          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
          Checa_Tag()
          RefreshDialog
   EndSwitch
EndIf
TECLA=""
MSG_CAMPO=""
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

;*******************************************************************************
;* Rotina para verificar se existe mes ou ano em aberto                        *
;*******************************************************************************
Proc TiraSombraShowDialog()
private Win_showdialog1, winarray_showdialog1 

Dynarray winarray_showdialog1[]
Window handle Dialog To Win_showdialog1
Window GetAttributes Win_showdialog1 To winarray_showdialog1
winarray_showdialog1["HASFRAME" ] = False
winarray_showdialog1["HASSHADOW"] = False

TituloMyShowdialog=winarray_showdialog1["TITLE"]

Window SetAttributes Win_showdialog1 From winarray_showdialog1

Release vars Win_showdialog1, winarray_showdialog1 
EndProc

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

TituloMyShowdialog=""

While True
 ShowDialog "RelatĒrio de Estados e Aliquotas de ICMS" Proc "SD_Dialog"
   Trigger "OPEN","ARRIVE"
    Key "TAB","ReverseTab","ENTER","ESC",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140    
    @ 01,00 Height 06 Width 82

    @ 00,00 ?? Format("W80,AC",TituloMyShowdialog)
    PaintCanvas Attribute 224 00,01,00,78
    
    Pushbutton @ 02,56 width 11 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 02,68 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 o RelatĒrio")
  SELECIONA()

  If IsEmpty("Answer")
     Then MENSAGEM("No existem registros a processar")
          Loop
  EndIf

  IMPRIREL("Answer","R")

  Delete "Answer"

EndWhile
ClearAll
Release Vars All
Release Procs All
