;*******************************************************************************
;* Desenvolvido: 04/03/2021 por Bruno Carvalho                                 *
;*******************************************************************************
Autolib="\\Sistemas\\Cadastro\\Bibliot,\\Sistemas\\Cadastro\\Bib_Show"

DATAM_DATA   = DateVal("31.03.2021")
DATAM_VERSAO = "2021.C"
 
DATAM_EXECUTA = "SYS_DATAM"
Play "\\Sistemas\\Cadastro\\EXEC_DAT"

If Not DATAM_EXECUTA 
   Then Exit
   Else DATAM_ROTINA  = "Vendas"
        DATAM_EXECUTA = "SYS_DATAM_MENSAGEM"
        Play "\\Sistemas\\Cadastro\\EXEC_DAT"
        If Not DATAM_EXECUTA
           Then Exit
        EndIf
EndIf 

;*******************************************************************************
;Rotina Corre‡Æo de Tabelas                                                    *
;*******************************************************************************
Proc Correcao_Tabelas_Vendas()

If Not IsTable("Ven_RegD")
   Then Copy "\\Base\\Sistemas\\Vendas\\Ven_RegD" "\\Sistemas\\Vendas\\Ven_RegD"
   Else {Tools} {Copy} {JustFamily} TypeIn "\\Base\\Sistemas\\Vendas\\Ven_RegD" Enter TypeIn "Ven_RegD" Enter {Replace}  
EndIf

If Not IsTable("Ven_RegC")
   Then Copy "\\Base\\Sistemas\\Vendas\\Ven_RegC" "\\Sistemas\\Vendas\\Ven_RegC"
   Else {Modify} {Restructure} {Ven_regc}
        Moveto [Field Name]
        Locate "MES1"
        if not retval
           Then End Down
                "MES1"   Enter  "A1"   Enter
                "MES2"   Enter  "A1"   Enter
                "MES3"   Enter  "A1"   Enter
                "MES4"   Enter  "A1"   Enter
                "MES5"   Enter  "A1"   Enter
                "MES6"   Enter  "A1"   Enter
                "MES7"   Enter  "A1"   Enter
                "MES8"   Enter  "A1"   Enter
                "MES9"   Enter  "A1"   Enter
                "MES10"  Enter  "A1"   Enter
                "MES11"  Enter  "A1"   Enter
                "MES12"  Enter  "A1"   Enter
        EndIf
        Do_It!
        ClearAll
        
        {Tools} {Copy} {JustFamily} TypeIn "\\Base\\Sistemas\\Vendas\\Ven_regc" Enter TypeIn "Ven_regc" Enter {Replace} 
EndIf   

EndProc ;Correcao_Tabelas_Vendas()

;*******************************************************************************
;Rotina Principal                                                              *
;*******************************************************************************
Aguarde("Atualizando Sistema")
Password("t01avivcl")
Password("FechaSys")

View "SysTable"
SYS_CODIGO_CLIENTE = [Codigo do Cliente]
ClearAll

;-------------------------------------------------------------------------------

DATAM_ROTINA   = "VENDAS"
DATAM_FECHAMES = ""
DATAM_EXECUTA  = "DATAM_SETDIR"
Play "\\Sistemas\\Cadastro\\EXEC_DAT" 

{Tools} {More} {Directory} {\\Sistemas\\Cadastro\\}

DATAM_EXECUTA  = "DATAM_SYSTABLE"
Play "\\Sistemas\\Cadastro\\EXEC_DAT" 

UnPassword("t01avivcl")
UnPassword("FechaSys")
LimpAguarde()
FastMsg("Fim da atualiza‡Æo !")

DATAM_EXECUTA  = "DATAM_RELEASE"
Play "\\Sistemas\\Cadastro\\EXEC_DAT"

Release Vars DATAM_EXECUTA