Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
titleExemplo 2 - LookUp Key-Label
collapsetrue
#include "msobject.ch"
#include "protheus.ch"
#include "totvs.framework.treports.integratedprovider.th"

namespace custom.financeiro.naturezas.integratedprovider

// Parece que ao fazer o uso da namespace dessa forma, está gerando alguams exceções aleatório quanto as propriedades das classes
// using namespace totvs.framework.treports.integratedprovider

@totvsFrameworkTReportsIntegratedProvider(active=.T.)
class SEDTReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider
    public method new() as object
    public method getDisplayName() as character
    public method getAreas() as array
    public method getData() as object
    public method getSchema() as object
endclass

method new() as object class SEDTReportsBusinessObject
_Super:new()
self:setDescription("Naturezas financeiras do Protheus")
self:setIsCBoxLookup(.T., .F.)
return self

method getDisplayName() as character class SEDTReportsBusinessObject
return "Naturezas"

method getAreas() as array class SEDTReportsBusinessObject
return {"Financeiro"}

method getData(nPage as numeric, oFilter as object) as object class SEDTReportsBusinessObject
self:oData:aliasToData("SED", oFilter)
return self:oData

method getSchema() as object class SEDTReportsBusinessObject
self:oSchema:aliasToSchema("SED")

self:oSchema:setComboValues("ED_FILIAL", "D MG 01=Filial BH; D MG 02=Filial Uberaba", .F.)
self:oSchema:setComboValues("ED_CALCIRF", "Sim=Sim; Não=Não")
return self:oSchema

Exemplo do Key-Label na interface:

Image Added

Padrão LookUp

ID - Chave do LookUp (Valor que será procurado na tabela do schema)

...

Bloco de código
titleExemplo 3 - padrão LookUp - Query
collapsetrue
#include "msobject.ch" 
#include "totvs.framework.treports.integratedprovider.th"

namespace custom.financeiro.naturezas.integratedprovider.lookup

@totvsFrameworkTReportsIntegratedProvider(active=.T.)
class SEDTReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider
    public method new() as object
    public method getDisplayName() as character
    public method getAreas() as array
    public method getData() as object
    public method getSchema() as object
endclass

method new() as object class SEDTReportsBusinessObject
_Super:new()
self:setDescription("Naturezas financeiras do Protheus")
self:setIsLookUp(.T.)
return self

method getDisplayName() as character class SEDTReportsBusinessObject
return "Naturezas"

method getAreas() as array class SEDTReportsBusinessObject
return {"Financeiro"}

method getData(nPage as numeric, oFilter as object) as object class SEDTReportsBusinessObject
self:oData:aliasToData("SED", oFilter)
return self:oData

method getSchema() as object class SEDTReportsBusinessObject
local cQuery as character
local aFields as array

self:oSchema:aliasToSchema("SED")

cQuery := "SELECT * FROM "+ RetSQLName("SED") +" WHERE D_E_L_E_T_ = ' '"
//cQuery := "SELECT ED_CODIGO, ED_DESCRIC FROM "+ RetSQLName("SED") +" WHERE D_E_L_E_T_ = ' '"
aFields := {"ED_CODIGO", "ED_DESCRIC"}
//Seta o lookup a partir da query
self:oSchema:setLookUpQuery(aFields, cQuery, .F.)

return self:oSchema

Exemplo do padrão LookUp na interface:

Image Added