[RESOLVIDO] UPC - Esconder Botões Incluir, Modificar e Alterar

Discussão em 'EMS , HCM e Totvs 11' iniciado por rhemati, Fevereiro 29, 2016.

Status do Tópico:
Não esta aberto para novas mensagens.
  1. rhemati

    rhemati Membro Participativo

    Pessoal, boa tarde.

    Estou fazendo esta UPC para esconder os botões incluir, modificar e alterar quando o usuário estiver cadastrado na usuar-mater, e estiver marcado o flag altera requisição.

    Antes disto estou testando primeiro a UPC para esconder ou desabilitar os botões, mas não está funcionando.


    Código:
    /*******************************************************************************    
    **  Programa .....: cd1406                                                             
    **  Objetivo .....: Gerador Automático de UPC                                       
    **  Data     .....: 29/02/16                                                       
    **  Autor    .....: Cristiano Rodrigues do Amaral - RHEMA Fábrica de Software       
    **  Versão   .....: 1.00.00.001                                                     
    *******************************************************************************/
    
    /* Definicao de Parametros ---*/
    def input parameter p-ind-event  as char          no-undo.
    def input parameter p-ind-object as char          no-undo.
    def input parameter p-wgh-object as handle        no-undo.
    def input parameter p-wgh-frame  as widget-handle no-undo.
    def input parameter p-cod-table  as char          no-undo.
    def input parameter p-row-table  as rowid         no-undo.
    
    /* Definicao de Variaveis Globais ---*/
    def new global shared var h-objeto                      as widget-handle no-undo.
    def new global shared var h-object                      as widget-handle no-undo.
    def new global shared var adm-broker-hdl                as handle        no-undo.
    def new global shared var h-cadsim                      as widget-handle no-undo.
    def new global shared var h-window                      as widget-handle no-undo.
    def new global shared var v_cod_grp_usuar_lst           as character     no-undo.
    def new global shared var h-cd1406-bt-eliminar          as widget-handle no-undo.
    def new global shared var h-cd1406-bt-incluir           as widget-handle no-undo.
    def new global shared var h-cd1406-bt-modificar         as widget-handle no-undo.
    def new global shared var h-cd1406-c-estado             as widget-handle no-undo.
    def new global shared var h-cd1406-txt-c-estado         as widget-handle no-undo.
    def new global shared var h-cd1406-c-situacao           as widget-handle no-undo.
    def new global shared var h-cd1406-txt-c-situacao       as widget-handle no-undo.
    def new global shared var gr-it-requisicao              as rowid         no-undo.
    def new global shared var gr-requisicao                 as rowid         no-undo.
    
    /* Variaveis Locais ---*/
    define variable i-objects   as integer    no-undo.
    define variable c-objects   as character  no-undo.
    define variable c-objeto    as character  no-undo.
    
    assign c-objeto = entry(num-entries(p-wgh-object:file-name, '/') ,
                      p-wgh-object:file-name, '/')
                      h-window       = p-wgh-frame:window
                      h-window:title = if r-index(h-window:title,"SYSMAKE") = 0 then 'SYSMAKE - ' + h-window:title else h-window:title no-error.
    
    /*inicio ---*/
    
        Message
            "Evento............: "  +   string( p-ind-event )   Skip
            "Objeto............: "  +   string( p-ind-object )  Skip
            "Handel do Obejto..: "  +   string( p-wgh-object )  Skip
            "Frame.............: "  +   string( p-wgh-frame )   Skip
            "Nome da tabela....: "  +   string( p-cod-table )   Skip
            "Rowid da tabela...: "  +   string( p-row-table )
        View-as Alert-box.
    
        /*
       if p-ind-event = 'before-initialize' and
          p-ind-object = 'container' then do:
    
           run get-link-handle in adm-broker-hdl (input p-wgh-object,
                                                  input 'container-target':u,
                                                  output c-objects).
    
         /* ------------------- smart links ----------------------- */
          do i-objects = 1 to num-entries(c-objects):
    
             assign h-object = widget-handle(entry(i-objects, c-objects)).
    
             if index(h-object:file-name, 'panel/p-cad') <> 0  then
                 assign h-cadsim  =   h-object:handle .
    
          end.
       end.
       */
    
    
        /*
       if p-ind-event  = "display" and p-ind-object = "viewer"
           /* and c-objeto     = 'cd1406-b01.w'  */
           then do:
    
           assign h-objeto =  p-wgh-frame:first-child.
    
           do while valid-handle(h-objeto):
    
              case h-objeto:name:
                  when 'bt-eliminar'then assign h-cd1406-bt-eliminar = h-objeto
    
                        h-cd1406-bt-eliminar:visible =  no
    
                      /*
                        h-cd1406-bt-eliminar:row     =  7.46
                        h-cd1406-bt-eliminar:col = 43.57
                      */
                      .
    
                  when 'bt-incluir'then assign h-cd1406-bt-incluir = h-objeto
    
                      h-cd1406-bt-incluir:visible =  no
    
                        /*
                        h-cd1406-bt-incluir:row     =  7.5
                        h-cd1406-bt-incluir:col = 1
                      */
                      .
                  when 'bt-modificar'then assign h-cd1406-bt-modificar = h-objeto
                        h-cd1406-bt-modificar:visible =  no
    
                      /*
                        h-cd1406-bt-modificar:row     =  7.46
                        h-cd1406-bt-modificar:col = 21.86
                      */
                     
                      .
              end case.
              if h-objeto:type = 'field-group' then do:
                  assign h-objeto = h-objeto:first-child.
              end.
              else do:
                  assign h-objeto = h-objeto:next-sibling.
              end.
           end.
    
       end.
       */
    
    /*
       if p-ind-event  = "initialize" and
          (p-ind-object = "viewer"     or
           p-ind-object = "browser")   and
          c-objeto     = 'cd1406-b01.w' then do:
    
           assign h-objeto =  p-wgh-frame:first-child.
    
           do while valid-handle(h-objeto):
    
              case h-objeto:name:
                  when 'bt-eliminar'then assign h-cd1406-bt-eliminar = h-objeto
                        h-cd1406-bt-eliminar:visible =  no
                        h-cd1406-bt-eliminar:row     =  7.46
                        h-cd1406-bt-eliminar:col = 43.57 .
                  when 'bt-incluir'then assign h-cd1406-bt-incluir = h-objeto
                        h-cd1406-bt-incluir:visible =  no
                        h-cd1406-bt-incluir:row     =  7.5
                        h-cd1406-bt-incluir:col = 1 .
                  when 'bt-modificar'then assign h-cd1406-bt-modificar = h-objeto
                        h-cd1406-bt-modificar:visible =  no
                        h-cd1406-bt-modificar:row     =  7.46
                        h-cd1406-bt-modificar:col = 21.86 .
              end case.
              if h-objeto:type = 'field-group' then do:
                  assign h-objeto = h-objeto:first-child.
              end.
              else do:
                  assign h-objeto = h-objeto:next-sibling.
              end.
           end.
    
       end.
       */
    
    
       if p-ind-event  = "initialize" and
          (p-ind-object = "viewer"     or
           p-ind-object = "browser")   and
          c-objeto     = 'cd1406-v01.w' then do:
    
           assign h-objeto =  p-wgh-frame:first-child.
    
           do while valid-handle(h-objeto):
    
              case h-objeto:name:
                  when 'c-estado'then assign h-cd1406-c-estado = h-objeto
                        h-cd1406-c-estado:visible =  no
                        h-cd1406-c-estado:row     =  1.21
                        h-cd1406-c-estado:col = 42.14
                        h-cd1406-txt-c-estado = h-cd1406-c-estado:side-label-handle
                        h-cd1406-txt-c-estado:col = (h-cd1406-c-estado:col - h-cd1406-txt-c-estado:width).
                  when 'c-situacao'then assign h-cd1406-c-situacao = h-objeto
                        h-cd1406-c-situacao:visible =  no
                        h-cd1406-c-situacao:row     =  1.21
                        h-cd1406-c-situacao:col = 66.86
                        h-cd1406-txt-c-situacao = h-cd1406-c-situacao:side-label-handle
                        h-cd1406-txt-c-situacao:col = (h-cd1406-c-situacao:col - h-cd1406-txt-c-situacao:width).
              end case.
              if h-objeto:type = 'field-group' then do:
                  assign h-objeto = h-objeto:first-child.
              end.
              else do:
                  assign h-objeto = h-objeto:next-sibling.
              end.
           end.
    
       end.
     
    
        if
            /*
                p-ind-event  = "AFTER-OPEN-QUERY"   and                    
            */
            p-ind-object = "BROWSER"  
            /* and                            
            c-objeto     = "cd1406-b01.w"  
            */
            then do:    
    
           assign h-objeto =  p-wgh-frame:first-child.
    
           do while valid-handle(h-objeto):
    
              case h-objeto:name:
                  when 'bt-eliminar'then assign h-cd1406-bt-eliminar = h-objeto
    
                        h-cd1406-bt-eliminar:visible    =   no
                        h-cd1406-bt-eliminar:sensitive  =   yes
    
                    
                        h-cd1406-bt-eliminar:row     =  7.46 /* funciona */
                        h-cd1406-bt-eliminar:col = 43.57 /* funciona */
                    
                      .
    
                  when 'bt-incluir'then assign h-cd1406-bt-incluir = h-objeto
    
                        h-cd1406-bt-incluir:visible     =  no
                        h-cd1406-bt-incluir:sensitive   =  yes
                       
                        h-cd1406-bt-incluir:row     =  7.5 /* funciona */
                        h-cd1406-bt-incluir:col = 1 /* funciona */
                     
                      .
                  when 'bt-modificar'then assign h-cd1406-bt-modificar = h-objeto
                        h-cd1406-bt-modificar:visible   =  no
                        h-cd1406-bt-modificar:sensitive =  yes
    
                     
                        h-cd1406-bt-modificar:row     =  7.46 /* funciona */
                        h-cd1406-bt-modificar:col = 21.86 /* funciona */
                     
                     
                      .
              end case.
              if h-objeto:type = 'field-group' then do:
                  assign h-objeto = h-objeto:first-child.
              end.
              else do:
                  assign h-objeto = h-objeto:next-sibling.
              end.
           end.
    
    
        end.    
    
        /* Pontos de Chamada ---*/
    
    /*    if p-ind-event  = "BEFORE-INITIALIZE"   and                    */
    /*       p-ind-object = "VIEWER"   and                               */
    /*       c-objeto     = "cd1406-v01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "BEFORE-DISPLAY"   and                       */
    /*       p-ind-object = "VIEWER"   and                               */
    /*       c-objeto     = "cd1406-v01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "DISPLAY"   and                              */
    /*       p-ind-object = "VIEWER"   and                               */
    /*       c-objeto     = "cd1406-v01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "INITIALIZE"   and                           */
    /*       p-ind-object = "VIEWER"   and                               */
    /*       c-objeto     = "cd1406-v01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "BEFORE-INITIALIZE"   and                    */
    /*       p-ind-object = "BROWSER"   and                              */
    /*       c-objeto     = "cd1406-b01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "VALUE-CHANGED"   and                        */
    /*       p-ind-object = "BROWSER"   and                              */
    /*       c-objeto     = "cd1406-b01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "AFTER-VALUE-CHANGED"   and                  */
    /*       p-ind-object = "BROWSER"   and                              */
    /*       c-objeto     = "cd1406-b01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "BEFORE-OPEN-QUERY"   and                    */
    /*       p-ind-object = "BROWSER"   and                              */
    /*       c-objeto     = "cd1406-b01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "AFTER-OPEN-QUERY"   and                     */
    /*       p-ind-object = "BROWSER"   and                              */
    /*       c-objeto     = "cd1406-b01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "INITIALIZE"   and                           */
    /*       p-ind-object = "BROWSER"   and                              */
    /*       c-objeto     = "cd1406-b01.w"   then do:                    */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "BEFORE-ENABLE"   and                        */
    /*       p-ind-object = "CONTAINER"   and                            */
    /*       c-objeto     = "cd1406.w"   then do:                        */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "ENABLE"   and                               */
    /*       p-ind-object = "CONTAINER"   and                            */
    /*       c-objeto     = "cd1406.w"   then do:                        */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "INITIALIZE"   and                           */
    /*       p-ind-object = "CONTAINER"   and                            */
    /*       c-objeto     = "cd1406.w"   then do:                        */
    /*    end.                                                           */
    
    /*    if p-ind-event  = "DESTROY"   and                              */
    /*       p-ind-object = "CONTAINER"   and                            */
    /*       c-objeto     = "cd1406.w"   then do:                        */
    /*    end.                                                           */
    
    /* fim ---*/
    
  2. lhp.s

    lhp.s Membro Participativo

    acho q dá para usar uma rotina internas da template...
    Vou dar uma olhada e já te falo.
  3. rhemati

    rhemati Membro Participativo

    Se o Estado estiver como Aprovada, os itens abaixo (Incluir, Modificar,Eliminar) ficam desativado, exceto para o usuário com permissão de Alterar Requisição definido no CD1700 – usuários materiais.
  4. lhp.s

    lhp.s Membro Participativo

    aqui,
    tenta localiza o objeto p-cadsim

    e depois: RUN enable-modifica IN h_p-cadsim ( INPUT p-log-enable /* LOGICAL */).
  5. lhp.s

    lhp.s Membro Participativo

    No pior dos mundos, alguns programas tratam os botões fora do ponto de UPC.
    Neste caso, você terá que criar um novo botão, sobre o botão padrão.
    O novo botão chamará outro programa persistente, passando como parametros, a frame atual e o handle do botão antigo.
    Neste programa, vc poderá fazer suas tratativas. E dar um apply choose sobre o botão antigo.
  6. lhp.s

    lhp.s Membro Participativo

    tenta esse:

    Código:
    if p-ind-event = "display"
    then do:
    
         run myWidget.p('bt-incluir', 'button', p-wgh-frame, ouput wh-new-bt-incluir).
    
        if valid-handle(wh-new-bt-incluir) then assign wh-new-bt-incluir:sensitive = no.
    
    end.
    





    myWidget.p
    Código:
    define input  parameter c-widget-name  as char  no-undo.
    define input  parameter c-widget-type  as char  no-undo.
    define input  parameter h-start-widget as handle no-undo.
    define output parameter h-widget  as handle no-undo.
    
    do while valid-handle(h-start-widget):
    
      if h-start-widget:name = c-widget-name and
      h-start-widget:type = c-widget-type then
      do:
      assign h-widget = h-start-widget:handle.
      leave.
      end.
    
      if h-start-widget:type = "field-group":u or
      h-start-widget:type = "frame":u or
      h-start-widget:type = "dialog-box":u then
      do:
      run utils/findWidget.p (input  c-widget-name,
      input  c-widget-type,
      input  h-start-widget:first-child,
      output h-widget).
    
      if valid-handle(h-widget) then
      leave.
      end.
    
      assign h-start-widget = h-start-widget:next-sibling.
    end.
    
Status do Tópico:
Não esta aberto para novas mensagens.

Compartilhe esta Página