;** RE_0008  *******************************************************************
;*  Digitacao de Etiquetas GW                                                  *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 13/02/2006 por Nikolas M. Mateus
;Ultima Alteracao: 13/02/2006 por Nikolas M. Mateus
;Motivo Alteracao: Ajustes

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

{Ask} {\\Sistemas\\Estoque\\Itens} Check
Moveto [Codigo do Item   ] TypeIn "~VSDGITEM.."
Moveto [Descricao do Item]
Moveto [Inativo          ] TypeIn "Not S"
Do_It!
ClearAll
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_ITEM"           : Campo="NO"
            Case Campo="TG_COD"            : Campo="TG_ITEM"
            Case Campo="TG_NOME"           : Campo="TG_COD"
            Case Campo="TG_COD"            : Campo="TG_QUAN"
            Case Campo="TG_QUAN"           : Campo="TG_NOME"
            Case Campo="YES" Or Campo="NO" : Campo="TG_ITEM"
          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_ITEM"           :
                         If IsBlank(VSDGITEM)
                            Then Mensagem("Escolha um codigo !")
                                 Campo="TG_ITEM"
                            Else Campo="TG_COD"
                         EndIf
                    Case Campo="TG_COD"            :
                         VSDGCOD=ControlValue("TG_COD")
                         Campo="TG_NOME"
                    Case Campo="TG_NOME"           :
                       VSDGNOME=ControlValue("TG_NOME")
                         Campo="TG_QUAN"
                    Case Campo="TG_QUAN"           :
                         VSDGQUAN=ControlValue("TG_QUAN")
                         Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
  Case Campo="TG_COD":
       MSG_CAMPO="Codigo do Item"
  Case Campo="TG_NOME":
       MSG_CAMPO="Nome do Tecido"
  Case Campo="TG_QUAN":
       MSG_CAMPO="Quantidade de Etiquetas a ser impressa"
EndSwitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

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

VSDGCOD    = ""
VSDGREPR   = ""
VSDGLARG   = ""
VSDGNOME   = ""
VSDGQUAN   = ""
VSDGNOMITEM= ""

While True

  ShowDialog "Digitacao de Itens para Etiqueta - GW" 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 12 Width 53

    Label  @ 00,00 "Item"  For "TG_ITEM"
    Accept @ 01,01 Width 12 "A10"  Picture "#*#" Tag "TG_ITEM"    To VSDGITEM
    Accept @ 01,15 Width 32 "A30" Picture "!*!" Tag "TG_NOMITEM" To VSDGNOMITEM

    Label  @ 02,00 "Quant. Prod." For "TG_COD"
    Accept @ 03,01 Width 12 "A7"  Picture "!*!" Tag "TG_COD" To VSDGCOD

    Label  @ 04,00 "Classificacao"  For "TG_NOME"
    Accept @ 05,01 Width 32 "A28"  Picture "!*!" Tag "TG_NOME" To VSDGNOME

    Label  @ 06,00 "Quant. Etiq." For "TG_QUAN"
    Accept @ 07,01 Width 12 "A10"  Picture "!*!"  Tag "TG_QUAN"     To VSDGQUAN

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

  Seleciona()

  If IsEmpty("Answer")
     Then MENSAGEM("N„o existem registros a processar")
          Delete "Answer"
          Loop
  EndIf
  CONT=1
  Coedit "Answer"
  CopyToArray REG
  While (CONT < NumVal(VSDGQUAN))
     End
     Down
     CopyFromArray Reg
     CONT=CONT+1
  EndWhile
  Do_It!
  ClearAll

  CopyReport "\\Base\\Sistemas\\Estoque\\Re_0010C" "2" "Answer" "R"


  IMPRIREL("Answer","R")
  Delete "Answer"

EndWhile
ClearAll
Release Vars All
Release Procs All
