Last active
March 12, 2025 22:26
-
-
Save Dadinel/fe0aaa4a113d0de168a0e3ced98a790e to your computer and use it in GitHub Desktop.
TLPP no Protheus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "protheus.ch" | |
#include "fwmvcdef.ch" | |
namespace custom.naturezas | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} addSedSchedule | |
Adiciona uma natureza genérica na SED, utilizando MVC feito em TLPP | |
Função criada para utilização via Schedule | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
user function addSedSchedule() | |
local oModel as object | |
local cCod as character | |
local oStatement as object | |
local cQuery as character | |
local lOk as logical | |
cQuery := "SELECT MAX(ED_CODIGO) LASTCOD FROM " + RetSqlName("SED") + " WHERE D_E_L_E_T_ = ?" | |
oStatement := FWExecStatement():New( ChangeQuery(cQuery) ) | |
oStatement:SetString(1, " ") | |
cCod := oStatement:ExecScalar("LASTCOD") | |
cCod := Iif( Empty(cCod), "000001", Soma1(cCod) ) | |
oStatement:Destroy() | |
oModel := FwLoadModel("custom.naturezas.crudSED") | |
oModel:SetOperation(MODEL_OPERATION_INSERT) | |
oModel:Activate() | |
oModel:SetValue("FIELDS_SED", "ED_CODIGO", cCod) | |
oModel:SetValue("FIELDS_SED", "ED_DESCRIC", "Xisto-User") | |
oModel:SetValue("FIELDS_SED", "ED_COND", "D") | |
lOk := oModel:VldData() .and. oModel:CommitData() | |
if !lOk | |
UserException(oModel:GetErrorMsgText()) | |
endif | |
oModel:DeActivate() | |
oModel:Destroy() | |
FreeObj(oModel) | |
FreeObj(oStatement) | |
oModel := nil | |
oStatement := nil | |
return | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} schedDef | |
Retorna dados para execução de schedule | |
@return aParam Array contendo as informações de agendamento | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
user function schedDef() as array | |
local aParam as array | |
local aOrd as array | |
aOrd := {} | |
aParam := {"P",; //Tipo R para relatorio P para processo | |
"",;// Pergunte do relatorio, caso nao use passar ParamDef | |
"SED",; // Alias | |
aOrd,; //Array de ordens | |
"addSedSchedule"} | |
return aParam |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "protheus.ch" | |
#include "fwmvcdef.ch" | |
namespace custom.naturezas | |
PUBLISH USER MODEL REST NAME customNaturezasCrudSED SOURCE "custom.naturezas.crudSED" | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} crudSED | |
Função de cadastro de naturezas, alias SED | |
@sample custom.naturezas.u_crudSED() | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
user function crudSED() | |
local oBrowse as object | |
oBrowse := FWLoadBrw("custom.naturezas.crudSED") | |
oBrowse:Activate() | |
oBrowse:DeActivate() | |
oBrowse:Destroy() | |
FreeObj(oBrowse) | |
oBrowse := nil | |
return nil | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} BrowseDef | |
Retorna o browse da rotina | |
@return oBrowse Objeto do tipo FWMBrowse(FWBrowse) | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
user function BrowseDef() as object | |
local oBrowse as object | |
oBrowse := FWMBrowse():New() | |
oBrowse:SetAlias("SED") | |
oBrowse:SetDescription("MVC TLPP - Tabela SED | User Function") | |
return oBrowse | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} ModelDef | |
Retorna o modelo de dados para o cadastro de naturezas, alias SED | |
Todo o modelo é baseado nos dicionários, em principal SX2, SX3 e SIX | |
@return oModel Objeto do tipo MPFormModel(FWFormModel) | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
user function ModelDef() as object | |
local oModel as object | |
local oStruct as object | |
oModel := MPFormModel():New( "MODEL_SED", /*bPre*/ , /*bPos*/, /*bCommit*/, /*bCancel*/ ) | |
oStruct := FwFormStruct( 1, "SED", /*bFiltro*/ ) | |
oModel:AddFields( "FIELDS_SED", /*Owner*/ , oStruct, /*bPre*/ , /*bPos*/ , /*bLoad*/ ) | |
return oModel | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} ViewDef | |
Retorna a view para o cadastro de naturezas, alias SED | |
@return oView Objeto do tipo FwFormView | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
user function ViewDef() as object | |
local oView as object | |
local oStruct as object | |
local oModel as object | |
oView := FwFormView():New() | |
oModel := FwLoadModel("custom.naturezas.crudSED") | |
oStruct := FwFormStruct( 2, "SED", /*bFiltro*/ ) | |
oView:SetModel(oModel) | |
oView:AddField( "VIEW_SED", oStruct, "FIELDS_SED" ) | |
return oView | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} MenuDef | |
Retorna o array com a opções presentes na rotina | |
@return aRotina Array contendo as opções da rotina, algumas opções | |
não são apresentadas diretamente como botões, é necessário ir nas | |
outras ações | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
user function MenuDef() as array | |
local aRotina := {} as array | |
Add Option aRotina Title "Pesquisar" Action "PesqBrw" Operation OP_PESQUISAR Access 0 | |
Add Option aRotina Title "Visualizar" Action "ViewDef.custom.naturezas.crudSED" Operation OP_VISUALIZAR Access 0 | |
Add Option aRotina Title "Incluir" Action "ViewDef.custom.naturezas.crudSED" Operation OP_INCLUIR Access 0 | |
Add Option aRotina Title "Alterar" Action "ViewDef.custom.naturezas.crudSED" Operation OP_ALTERAR Access 0 | |
Add Option aRotina Title "Excluir" Action "ViewDef.custom.naturezas.crudSED" Operation OP_EXCLUIR Access 0 | |
Add Option aRotina Title "Imprimir" Action "ViewDef.custom.naturezas.crudSED" Operation OP_IMPRIMIR Access 0 | |
Add Option aRotina Title "Copiar" Action "ViewDef.custom.naturezas.crudSED" Operation OP_COPIA Access 0 | |
return aRotina |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "protheus.ch" | |
#include "fwmvcdef.ch" | |
namespace financeiro.naturezas | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} addSedSchedule | |
Adiciona uma natureza genérica na SED, utilizando MVC feito em TLPP | |
Função criada para utilização via Schedule | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
function addSedSchedule() | |
local oModel as object | |
local cCod as character | |
local oStatement as object | |
local cQuery as character | |
local lOk as logical | |
cQuery := "SELECT MAX(ED_CODIGO) LASTCOD FROM " + RetSqlName("SED") + " WHERE D_E_L_E_T_ = ?" | |
oStatement := FWExecStatement():New( ChangeQuery(cQuery) ) | |
oStatement:SetString(1, " ") | |
cCod := oStatement:ExecScalar("LASTCOD") | |
cCod := Iif( Empty(cCod), "000001", Soma1(cCod) ) | |
oStatement:Destroy() | |
oModel := FwLoadModel("financeiro.naturezas.crudSED") | |
oModel:SetOperation(MODEL_OPERATION_INSERT) | |
oModel:Activate() | |
oModel:SetValue("FIELDS_SED", "ED_CODIGO", cCod) | |
oModel:SetValue("FIELDS_SED", "ED_DESCRIC", "Xisto") | |
oModel:SetValue("FIELDS_SED", "ED_COND", "R") | |
lOk := oModel:VldData() .and. oModel:CommitData() | |
if !lOk | |
UserException(oModel:GetErrorMsgText()) | |
endif | |
oModel:DeActivate() | |
oModel:Destroy() | |
FreeObj(oModel) | |
FreeObj(oStatement) | |
oModel := nil | |
oStatement := nil | |
return | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} schedDef | |
Retorna dados para execução de schedule | |
@return aParam Array contendo as informações de agendamento | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
function schedDef() as array | |
local aParam as array | |
local aOrd as array | |
aOrd := {} | |
aParam := {"P",; //Tipo R para relatorio P para processo | |
"",;// Pergunte do relatorio, caso nao use passar ParamDef | |
"SED",; // Alias | |
aOrd,; //Array de ordens | |
"addSedSchedule"} | |
return aParam |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "protheus.ch" | |
#include "fwmvcdef.ch" | |
namespace financeiro.naturezas | |
PUBLISH MODEL REST NAME financeiroNaturezasCrudSED SOURCE "financeiro.naturezas.crudSED" | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} crudSED | |
Função de cadastro de naturezas, alias SED | |
@sample financeiro.naturezas.u_crudSED() | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
function crudSED() | |
local oBrowse as object | |
oBrowse := FWLoadBrw("financeiro.naturezas.crudSED") | |
oBrowse:Activate() | |
oBrowse:DeActivate() | |
oBrowse:Destroy() | |
FreeObj(oBrowse) | |
oBrowse := nil | |
return nil | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} BrowseDef | |
Retorna o browse da rotina | |
@return oBrowse Objeto do tipo FWMBrowse(FWBrowse) | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
function BrowseDef() as object | |
local oBrowse as object | |
oBrowse := FWMBrowse():New() | |
oBrowse:SetAlias("SED") | |
oBrowse:SetDescription("MVC TLPP - Tabela SED") | |
return oBrowse | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} ModelDef | |
Retorna o modelo de dados para o cadastro de naturezas, alias SED | |
Todo o modelo é baseado nos dicionários, em principal SX2, SX3 e SIX | |
@return oModel Objeto do tipo MPFormModel(FWFormModel) | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
function ModelDef() as object | |
local oModel as object | |
local oStruct as object | |
oModel := MPFormModel():New( "MODEL_SED", /*bPre*/ , /*bPos*/, /*bCommit*/, /*bCancel*/ ) | |
oStruct := FwFormStruct( 1, "SED", /*bFiltro*/ ) | |
oModel:AddFields( "FIELDS_SED", /*Owner*/ , oStruct, /*bPre*/ , /*bPos*/ , /*bLoad*/ ) | |
return oModel | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} ViewDef | |
Retorna a view para o cadastro de naturezas, alias SED | |
@return oView Objeto do tipo FwFormView | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
function ViewDef() as object | |
local oView as object | |
local oStruct as object | |
local oModel as object | |
oView := FwFormView():New() | |
oModel := FwLoadModel("financeiro.naturezas.crudSED") | |
oStruct := FwFormStruct( 2, "SED", /*bFiltro*/ ) | |
oView:SetModel(oModel) | |
oView:AddField( "VIEW_SED", oStruct, "FIELDS_SED" ) | |
return oView | |
//------------------------------------------------------------------- | |
/*/{Protheus.doc} MenuDef | |
Retorna o array com a opções presentes na rotina | |
@return aRotina Array contendo as opções da rotina, algumas opções | |
não são apresentadas diretamente como botões, é necessário ir nas | |
outras ações | |
@author Dan M | |
@since 12/03/2025 | |
@version 1.0 | |
/*/ | |
//------------------------------------------------------------------- | |
function MenuDef() as array | |
local aRotina := {} as array | |
Add Option aRotina Title "Pesquisar" Action "PesqBrw" Operation OP_PESQUISAR Access 0 | |
Add Option aRotina Title "Visualizar" Action "ViewDef.financeiro.naturezas.crudSED" Operation OP_VISUALIZAR Access 0 | |
Add Option aRotina Title "Incluir" Action "ViewDef.financeiro.naturezas.crudSED" Operation OP_INCLUIR Access 0 | |
Add Option aRotina Title "Alterar" Action "ViewDef.financeiro.naturezas.crudSED" Operation OP_ALTERAR Access 0 | |
Add Option aRotina Title "Excluir" Action "ViewDef.financeiro.naturezas.crudSED" Operation OP_EXCLUIR Access 0 | |
Add Option aRotina Title "Imprimir" Action "ViewDef.financeiro.naturezas.crudSED" Operation OP_IMPRIMIR Access 0 | |
Add Option aRotina Title "Copiar" Action "ViewDef.financeiro.naturezas.crudSED" Operation OP_COPIA Access 0 | |
return aRotina |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment