;** Rm_0010 ********************************************************************
;* Ficha de Formulas                                                           *
;*******************************************************************************
;Autor: Visao/Vise
;Desenvolvido    : 16/08/2002 por Anivel Augusto Rodrigues
;Ultima Alteracao: 04/04/2019 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes report base e showdialog 
;Ultima Alteracao: 03/08/2020 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes substitui‡Æo tpitem por tipoest

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

{Ask} {\\Sistemas\\Estoque\\Itens}
Moveto [Codigo do Item   ] Example "ITEM"
Ask_EstoqueTpItem("")
Moveto [Codigo da Familia] TypeIn "~VSDGFAMI.."
Moveto [Codigo do Grupo  ] TypeIn "~VSDGGRP.."
Moveto [Referencia       ] TypeIn "~VSDGREFERENCIA.."
{Ask} {FormulaC}
Moveto [Codigo do Produto] Example "ITEM"
Moveto [Codigo Cor_Tecido] Example "COR"
Moveto [Quantidade Produzida   ] Check
Moveto [Quantidade_Produz_Meios] Check
Moveto [Quantidade_Produz_Kg   ] Check
{Ask} {FormulaI} Check
Moveto [Codigo do Produto] Example "ITEM" TypeIn ", ~VSDGITEM.."
Moveto [Codigo Cor_Tecido] Example "COR"  TypeIn ", ~VSDGCORTECIDO.."
Moveto [Codigo da Etapa  ] TypeIn "~VSDGETAPA.."
Do_It!
ClearAll

If Not IsEmpty("Answer")
   Then
        Edit "Answer"
        Scan
          If [Codigo da Etapa]<>"005"
             Then [Quantidade]=BlankNum()
          EndIf
        EndScan
        Do_It!
        ClearAll

        CopyReport "\\base\\sistemas\\curtume\\Rm_0010" "R" "Answer" "R"
EndIf

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_TIPOEST"        : Campo="NO"
            Case Campo="TG_FAMI"           : Campo="TG_TIPOEST"
            Case Campo="TG_GRP"            : Campo="TG_FAMI"
            Case Campo="TG_COR_TECIDO"     : Campo="TG_GRP"
            Case Campo="TG_ETAPA"          : Campo="TG_COR_TECIDO"
            Case Campo="TG_ITEM"           : Campo="TG_ETAPA"
            Case Campo="TG_REFERENCIA"     : Campo="TG_ITEM"
            Case Campo="YES" Or Campo="NO" : Campo="TG_TIPOEST"
          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_TIPOEST"    : Campo="TG_FAMI"
                    Case Campo="TG_FAMI"       : Campo="TG_GRP"
                    Case Campo="TG_GRP"        : Campo="TG_COR_TECIDO"
                    Case Campo="TG_COR_TECIDO" : Campo="TG_ETAPA"
                    Case Campo="TG_ETAPA"      : Campo="TG_ITEM"
                    Case Campo="TG_ITEM"       : Campo="TG_REFERENCIA"
                    Case Campo="TG_REFERENCIA" : Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
  Case Campo="":
       MSG_CAMPO=""
EndSwitch

Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc
;*******************************************************************************
;* ROTINA PRINCIPAL                                                            *
;*******************************************************************************
AutoLib="\\Sistemas\\Cadastro\\Bib_Show,\\Sistemas\\Cadastro\\Bibliot"
LimpAguarde()

VSDGTIPOEST  = ""
VSDGFAMI     = ""
VSDGGRP      = ""
VSDGPRODUTO  = ""
VSDGCORTECIDO= ""
VSDGREFERENCIA= ""

While True

  ShowDialog "Ficha de F¢rmulas" Proc "SD_Dialog"
  Trigger "OPEN","ARRIVE"
  Key "F1","ENTER","ESC","TAB",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140  
  @ 05,05   Height 20 Width 72

    Label  @ 00,00 "Tipo do Estoque"  For "TG_TIPOEST"
    Accept @ 01,04 Width 04 "A1"  Picture "!" Tag "TG_TIPOEST" To VSDGTIPOEST
    Accept @ 01,09 Width 25 "A30"  Picture "!*!" Tag "TG_DESCTIPOEST" To VSDGDESCTIPOEST

    Label  @ 02,00 "Familia"  For "TG_FAMI"
    Accept @ 03,02 Width 06 "A3"  Picture "#*#" Tag "TG_FAMI" To VSDGFAMI
    Accept @ 03,09 Width 25 "A25" Picture "!*!" Tag "TG_NOMFAMI" To VSDGNOMFAMI

    Label  @ 04,00 "Grupo"  For "TG_GRP"
    Accept @ 05,02 Width 06 "A3"  Picture "#*#" Tag "TG_GRP" To VSDGGRP
    Accept @ 05,09 Width 25 "A25" Picture "!*!" Tag "TG_NOMGRP" To VSDGNOMGRP

    Label  @ 06,00 "Cor" For "TG_COR_TECIDO"
    Accept @ 07,01 Width 07 "A4"  Picture "#*#" Tag "TG_COR_TECIDO"    To VSDGCORTECIDO
    Accept @ 07,09 Width 25 "A25" Picture "!*!" Tag "TG_NOMCOR_TECIDO" To VSDGNOMCORTECIDO

    Label  @ 08,00 "Etapa" For "TG_ETAPA"
    Accept @ 09,01 Width 07 "A4"  Picture "#*#" Tag "TG_ETAPA"    To VSDGETAPA
    Accept @ 09,09 Width 25 "A25" Picture "!*!" Tag "TG_NOMETAPA" To VSDGNOMETAPA

    Label  @ 10,00 "Item"  For "TG_ITEM"
    Accept @ 11,01 Width 33 "A10" Picture "#*#" Tag "TG_ITEM"     To VSDGITEM
    Accept @ 12,01 Width 33 "A35" Picture "!*!" Tag "TG_NOMITEM" To VSDGNOMITEM

    Label  @ 13,00 "Referˆncia"  For "TG_REFERENCIA"
    Accept @ 14,01 Width 33 "A20" Picture "!*!" Tag "TG_REFERENCIA"     To VSDGREFERENCIA

    Pushbutton @ 16,22 width 11 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 16,36 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("N„o existem registros a processar")
          Loop
  EndIf

  IMPRIREL("Answer","R")

  Delete "Answer"
EndWhile
ClearAll
Release Vars All
Release Procs All

