PC SOFT
DEPOT EN LIGNE
POUR WINDEVWEBDEV ET WINDEV MOBILE

Novo Exemplo Caderno Agricola OOP MVC - WEBDEV 28
Publié par Boller
dans la catégorie Outils
Nouveautés



Description
Novo Exemplo Caderno Agricola OOP MVC - WEBDEV 28

VIDEO EXPLICANDO O PROJETO

https://youtu.be/5rpXbfDnqtI

CODIGOS

IN GLOBAL INIT DO PROJETO
//----------------------------------------


HModifyStructure("*")

HCreationIfNotFound("*")

HOpenConnection(MyConnectionHfsqlCS)

HChangeConnection("*",MyConnectionHfsqlCS)

GLOBAL
gn_ID is 8-byte int
gs_tabela, gs_chave, gs_campo, gs_nomeJanela, gs_plane, gs_tableGrid, gs_col, gs_campo_buscar, gs_Parametros, gs_acao, gs_mensagem is string
//gs_acao = incluir, alterar, excluir, excluir tudo, selecionar, buscar

//minhaconexao is connection
//minhaconexao..Provider = hNativeAccessPostgreSQL
//minhaconexao..User = "adriano"
//minhaconexao..Password = "123456"
//minhaconexao..Server = "184.200.3.5"
//minhaconexao..Database = "clientes"
//
//HOpenConnection(minhaconexao)
//
//HChangeConnection("*",minhaconexao)

//-------------------------------------------------------



GLOBAL DAS JANELAS - INIT
//------------------------------------------------

PROCEDURE MyPage()

gs_tabela = "t001_clientes"
gs_chave = "t001_cliente_id"
gs_nomeJanela = "PAGE_Clientes"
gs_tableGrid = "TABLE_T001_clientes"
gs_col = "COL_T001_cliente_id"
gs_mensagem = "Bom dia!!!!!"
gs_plane = 1

//--------------------------------------------------------



NO CLICK DO TABLE
//---------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
// Evento_Click_Registro ()
//
// Parameters:
// None
// Return value:
// None
//
// Example:
// <Specify a usage example>
//
PROCEDURE Evento_Click_Registro()

IF gs_acao = "alterar" AND gn_ID > 0

ExecuteProcess(FLEX_Main.LAYOUT_Main.CTPL_Alterar.BTN_ALTERAR,trtClick)

END

//------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//Evento_SelectRow_gn_ID ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE Evento_SelectRow_gn_ID()

IF TABLE_T001_clientes <> -1 THEN

gn_ID = TABLE_T001_clientes[TABLE_T001_clientes].COL_T001_cliente_id

IF gn_ID > 0 THEN

gs_acao = "alterar"

ELSE

gs_acao = ""

gn_ID = 0

END

ELSE

gs_acao = ""

gn_ID = 0

END

//-----------------------------------------------------------------------------------------------------


//CLASSE OOP

// Summary: <specify the procedure action>
// Syntax:
//evento_alterar (<tabela>, <chave>, <nomeJanela>, <tableGrid>, <ID>)
//
// Parameters:
// tabela: <specify the role of tabela>
// chave: <specify the role of chave>
// nomeJanela: <specify the role of nomeJanela>
// tableGrid: <specify the role of tableGrid>
// ID: <specify the role of ID>
// Example:
// <Specify a usage example>
//
// Return value:
// acao: <specify the role of acao>
PROCEDURE PUBLIC GLOBAL evento_alterar(tabela, chave, nomeJanela, tableGrid, ID)

//Info("alterar",tabela, nomeJanela, tableGrid, acao, ID)

// Verificar se uma linha foi selecionada
// no controle de tela
IF TableSelect(tableGrid) = -1 OR ID = 0

RETURN

ELSE

gs_acao = "alterar"

HReset(tabela)

IF HReadSeek(tabela,chave,ID,hIdentical) = True THEN

FileToPage()

evento_vai_para_plane(nomeJanela,2)

END

END

//------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_buscar (<tabela>)
//
// Parameters:
// tabela: <specify the role of tabela>
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_buscar(tabela, campo_buscar)

Info("buscar",tabela,campo_buscar)

//--------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_excluir (<tabela>, <nomeJanela>, <tableGrid>, <acao>)
//
// Parameters:
// tabela: <specify the role of tabela>
// nomeJanela: <specify the role of nomeJanela>
// tableGrid: <specify the role of tableGrid>
// acao: <specify the role of acao>
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_excluir(tabela, nomeJanela, tableGrid, acao)

Info("excluir",tabela, nomeJanela, tableGrid, acao)

// Verificamos se uma linha foi selecionada
IF TableSelect(tableGrid) = -1 THEN
RETURN
ELSE
//1 : Sim
//2 : Não
SWITCH Dialog("Deseja excluir o registro?")
// Sim
CASE 1
TableDelete(tableGrid)
// Posiciona o controle de tela no registro atual
TableDisplay(tableGrid, taInit)
TableDisplay(tableGrid, taReExecuteQuery)
// Não
CASE 2

END
END

//--------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_gravar (<tabela>, <nomeJanela>, <tableGrid>)
//
// Parameters:
// tabela: <specify the role of tabela>
// nomeJanela: <specify the role of nomeJanela>
// tableGrid: <specify the role of tableGrid>
// Example:
// <Specify a usage example>
//
// Return value:
// acao: <specify the role of acao>
PROCEDURE PUBLIC GLOBAL evento_gravar(tabela, nomeJanela, tableGrid)

// Lê o conteúdo dos controles de tela //pagina
PageToFile()

IF {tabela,indFile}..NewRecord = True THEN
IF gs_acao = "incluir"
IF HAdd(tabela) = True THEN
Info("Gravou com sucesso")
ELSE
Info(HErrorInfo()+ErrorInfo())
END
END
// aqui voce faz os tratamentos
ELSE
// Modifica o registro seleciona
IF gs_acao = "alterar"
IF HModify(tabela) = True THEN
Info("Gravou com sucesso")
ELSE
Info(HErrorInfo()+ErrorInfo())
END
END
END

TableDisplay({tableGrid},taInit)

// Retornar um valor da janela
MyPage.ReturnedValue = True

evento_vai_para_plane(nomeJanela,1)

//-------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_incluir (<tabela>, <nomeJanela>, <tableGrid>)
//
// Parameters:
// tabela: <specify the role of tabela>
// nomeJanela: <specify the role of nomeJanela>
// tableGrid: <specify the role of tableGrid>
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_incluir(tabela, nomeJanela, tableGrid, acao, ID)

Info("incluir",tabela, nomeJanela, tableGrid, acao, ID)

// Ao criar um novo registro
acao = "incluir"
gs_acao = "incluir"
// Limpa o buffer do arquivo e carregamos os valores default
HReset(tabela)
//plane
evento_vai_para_plane(nomeJanela,2)
//numero do registro
gn_ID = 0
ID = 0

//-------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_procedure (<tabela>, <nomeJanela>, <tableGrid>, <Parametros>)
//
// Parameters:
// tabela: <specify the role of tabela>
// nomeJanela: <specify the role of nomeJanela>
// tableGrid: <specify the role of tableGrid>
// Parametros: <specify the role of Parametros>
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_procedure(tabela, nomeJanela, tableGrid, Parametros)

Info(tabela, nomeJanela, tableGrid, Parametros)

//-----------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_selecionar ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_selecionar()

IF gs_acao = "alterar" AND gn_ID > 0 THEN

BotaoAlterar is string = gs_nomeJanela+".FLEX_Main.LAYOUT_Main.CTPL_Alterar.BTN_ALTERAR"

ExecuteProcess({BotaoAlterar},trtClick)

END

//-----------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_vai_para_plane ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_vai_para_plane(nomePagina, plane)

{nomePagina,indPage}..Plane = plane // saiba que {} alter value in runtime

//--------------------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_voltar ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_voltar(nomePagina, plane)

{nomePagina,indPage}..Plane = plane

//--------------------------------------------------------------------------------------------------------

NOS BOTOES EXEMPLO DO INCLUIR

CODE

Classe_OOP.evento_incluir(gs_tabela, gs_nomeJanela, gs_tableGrid, gs_acao, gn_ID)


Illustrations, copies d'écran
none
none
Avis des utilisateurs
(Pour noter la ressource, cliquez sur Ecrire un avis)
Boller
Classe_OOP is Class

END



// Summary: <specify the procedure action>
// Syntax:
//evento_alterar (<tabela>, <chave>, <tableGrid>)
//
// Parameters:
// tabela: <specify the role of tabela>
// chave: <specify the role of chave>
// tableGrid: <specify the role of tableGrid>
// Example:
// <Specify a usage example>
//
// Return value:
// acao: <specify the role of acao>
// nomeJanela: <specify the role of nomeJanela>
// ID: <specify the role of ID>
PROCEDURE PUBLIC GLOBAL evento_alterar(tabela, chave, tableGrid)

//Info("alterar",tabela, nomeJanela, tableGrid, acao, ID)

// Verificar se uma linha foi selecionada

IF tabela = "" THEN
RETURN
END

IF chave = "" THEN
RETURN
END

IF tableGrid = "" THEN
RETURN
END

// no controle de tela
IF TableSelect(tableGrid) = -1 OR gn_ID = 0

gn_ID = 0

gs_acao = ""

gb_Status = False

RETURN

ELSE

gb_Status = True

gs_acao = "alterar"

IF evento_lock_record(tabela,gn_ID) = True THEN

HReset(tabela)

IF HReadSeek(tabela,chave,gn_ID,hIdentical) = True THEN

FileToScreen()

evento_go_plane(gs_nomeJanela,2)

gb_Status = True

ELSE

gn_ID = 0

gs_acao = ""

gb_Status = False

IF glo_debug = True THEN

StatusRecord is string = ""

SWITCH HState(tabela,gn_ID)

CASE 1
StatusRecord = "Registro Ativo"
CASE 2
StatusRecord = "Registro excluido logicamente"
CASE 3
StatusRecord = "Registro excluido fisicamente"
CASE 4
StatusRecord = "Status invalido"
OTHER CASE
StatusRecord = "Situação inesperada do HState"
END

Info( StatusRecord )

END

RETURN

END

ELSE
Info("O registro esta em uso por outra estação")
END

END



//-------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//[ <Result> = ] evento_alterar_imagem ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Janela_ImgLateral:
PROCEDURE PUBLIC GLOBAL evento_alterar_imagem()

Status is boolean

Indirection_Janela_ImagemLateral is string = gs_nomeJanela +"."+ gs_imagem_lateral

PathImagemLateral is string = fSelect("", "", "Selecione uma imagem com 200x640", "JPG (JPG.*)" + TAB + "*.JPG" + CR + "PNG" + TAB + "*.PNG", "*.PNG")

IF PathImagemLateral <> "" THEN

Status = True

INIWrite("CONFIG","Imagem_Lateral",PathImagemLateral,fCurrentDir()+fSep()+"CONFIG.INI")

{Indirection_Janela_ImagemLateral} = PathImagemLateral

ELSE

Status = False

END

RESULT Status

//-------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_excluir ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
// nomeJanela: <specify the role of nomeJanela>
// acao: <specify the role of acao>
// tabela: <specify the role of tabela>
// campo: <specify the role of campo>
// tableGrid: <specify the role of tableGrid>
PROCEDURE PUBLIC GLOBAL evento_excluir()

//Info("excluir",tabela, nomeJanela, tableGrid, acao)

tabela is string = gs_TableFile
campo is string = gs_CampoChave
tableGrid is string = gs_TableGrid

// Verificamos se uma linha foi selecionada
IF TableSelect(tableGrid) = -1 THEN
gn_ID = 0
RETURN
ELSE
//1 : Sim
//2 : Não
SWITCH Dialog("Deseja excluir o registro?")
// Sim
CASE 1
// Posiciona o controle de tela no registro atual
HReset(tabela)
IF HReadSeek(tabela,campo,gn_ID,hIdentical) = True
IF HDelete(tabela) = True THEN

IF glo_debug = True THEN

StatusRecord is string = ""

SWITCH HState(tabela,gn_ID)

CASE 1
StatusRecord = "Registro Ativo"
CASE 2
StatusRecord = "Registro excluido logicamente"
CASE 3
StatusRecord = "Registro excluido fisicamente"
CASE 4
StatusRecord = "Status invalido"
OTHER CASE
StatusRecord = "Situação inesperada do HState"
END

Info( StatusRecord )

END

TableDisplay(tableGrid, taInit)
TableDisplay(tableGrid, taReExecuteQuery)
END
END
// Não
CASE 2
gn_ID = 0
END
END


//-------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_excluir_HCross ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_excluir_HCross()

//Info("excluir",tabela, nomeJanela, tableGrid, acao)

tabela is string = gs_TableFile
campo is string = gs_CampoChave
tableGrid is string = gs_TableGrid

// Verificamos se uma linha foi selecionada
IF TableSelect(tableGrid) = -1 THEN
gn_ID = 0
RETURN
ELSE
//1 : Sim
//2 : Não
SWITCH Dialog("Deseja excluir o registro?")
// Sim
CASE 1
// Posiciona o controle de tela no registro atual
HReset(tabela)
IF HReadSeek(tabela,campo,gn_ID,hIdentical) = True
IF HCross(tabela) = True THEN

IF glo_debug = True THEN

StatusRecord is string = ""

SWITCH HState(tabela,gn_ID)

CASE 1
StatusRecord = "Registro Ativo"
CASE 2
StatusRecord = "Registro excluido logicamente"
CASE 3
StatusRecord = "Registro excluido fisicamente"
CASE 4
StatusRecord = "Status invalido"
OTHER CASE
StatusRecord = "Situação inesperada do HState"
END

Info( StatusRecord )

END

TableDisplay(tableGrid, taInit)
TableDisplay(tableGrid, taReExecuteQuery)

END
END
// Não
CASE 2
gn_ID = 0
END
END


//-------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
// evento_exibir_imagem_lateral ()
//
// Parameters:
// None
// Return value:
// None
//
// Example:
// <Specify a usage example>
//
PROCEDURE PUBLIC GLOBAL evento_exibir_imagem_lateral()

Status is boolean = False

IndirectionNomeJanelaImagemLateral is string = gs_nomeJanela +"."+ gs_imagem_lateral

PathImagemLateral is string = INIRead("CONFIG","Imagem_Lateral","",fCurrentDir()+fSep()+"CONFIG.INI")

IF PathImagemLateral <> "" THEN

//{IndirectionNomeJanelaImagemLateral} = PathImagemLateral

Status = True

ELSE

Status = False

END

RESULT Status


//-------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//Evento_Filtrar ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL Evento_Filtrar()

CampoFiltro is string = gs_nomeJanela + ".EDT_JANUSGRID"

gs_JanusGrid = {CampoFiltro}..Value

IF gs_TipoBusca = 0 THEN
RETURN
END

IF gs_JanusGrid = "" THEN
RETURN
END

gs_JanusGrid = Replace(gs_JanusGrid,CRLF," ")

gs_JanusGrid = Replace(gs_JanusGrid,CR," ")

IF gs_Debug = True
Info(gs_JanusGrid)
END

IF gs_TipoBusca = 1
//gs_JanusGrid Order by
Evento_Filtrar_OrderBy()
ELSE IF gs_TipoBusca = 2
//gs_JanusGrid SQL
Evento_Filtrar_SQL()
ELSE
Info("Selecione um Tipo de Busca")
END


//-------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//Evento_Filtrar_OrderBy ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL Evento_Filtrar_OrderBy()

IF gs_JanusGrid = "" THEN
RETURN
END

sqlcodigo is string = [
select
*
from
@tabela@
order by
@orderby@
]

sqlcodigo = Replace(sqlcodigo,"@tabela@",gs_TableFile,IgnoreCase)
sqlcodigo = Replace(sqlcodigo,"@orderby@",gs_JanusGrid,IgnoreCase)

dsQuery is Data Source

IF HExecuteSQLQuery(dsQuery,hQueryDefault,sqlcodigo) = True THEN

FOR EACH dsQuery
//....
END

END

//-------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
// Evento_Filtrar_SQL ()
//
// Parameters:
// None
// Return value:
// None
//
// Example:
// <Specify a usage example>
//
PROCEDURE PUBLIC GLOBAL Evento_Filtrar_SQL()

IF gs_JanusGrid = "" THEN
RETURN
END

sqlcodigo is string = [
select
*
from
@tabela@
where
@filtros@
]

sqlcodigo = Replace(sqlcodigo,"@tabela@",gs_TableFile,IgnoreCase)
sqlcodigo = Replace(sqlcodigo,"@filtros@",gs_JanusGrid,IgnoreCase)

dsQuery is Data Source

IF HExecuteSQLQuery(dsQuery,hQueryDefault,sqlcodigo) = True THEN

FOR EACH dsQuery
//....
END

END


//-------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_go_plane (<nomePagina>, <plane>)
//
// Parameters:
// nomePagina: <specify the role of nomePagina>
// plane: <specify the role of plane>
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_go_plane(nomePagina, plane)

IF nomePagina = "" THEN
RETURN
END

IF plane = 0 THEN
RETURN
END

{nomePagina,indWindow}..Plane = plane // saiba que {} alter value in runtime

//-------------------------------------------------------------------------------------------------

// Summary: <specify the procedure action>
// Syntax:
//evento_gravar (<tabela>, <nomeJanela>, <tableGrid>, <plano>)
//
// Parameters:
// tabela: <specify the role of tabela>
// nomeJanela: <specify the role of nomeJanela>
// tableGrid: <specify the role of tableGrid>
// plano: <specify the role of plano>
// Example:
// <Specify a usage example>
//
// Return value:
// acao: <specify the role of acao>
PROCEDURE PUBLIC GLOBAL evento_gravar(tabela, nomeJanela, tableGrid, plano)

IF tabela = ""
RETURN
END

IF nomeJanela = ""
RETURN
END

IF tableGrid = ""
RETURN
END

IF plano = 0
RETURN
END

gb_Status = False

// Lê o conteúdo dos controles de tela //pagina
ScreenToFile()

IF {tabela,indFile}..NewRecord = True THEN
IF gs_acao = "incluir"
IF HAdd(tabela) = True
gb_Status = True
Info("Gravou com sucesso")
ELSE
gb_Status = False
Info(HErrorInfo()+ErrorInfo())
END
END
// aqui voce faz os tratamentos
ELSE
// Modifica o registro seleciona
IF gs_acao = "alterar"
IF HModify(tabela) = True THEN
evento_lock_not_record(tabela,gn_ID)
gb_Status = True
Info("Gravou com sucesso")
ELSE
gb_Status = False
Info(HErrorInfo()+ErrorInfo())
END
END
END

TableDisplay({tableGrid},taInit)

TableDisplay({tableGrid},taReExecuteQuery)

// Retornar um valor da janela
MyWindow.ReturnedValue = True

evento_go_plane(nomeJanela,plano)



//-------------------------------------------------------------------------------------------------


// Summary: <specify the procedure action>
// Syntax:
//evento_gravar_UUID (<tabela>, <nomeJanela>, <tableGrid>, <plano>)
//
// Parameters:
// tabela:
// nomeJanela: <specify the role of nomeJanela>
// tableGrid: <specify the role of tableGrid>
// plano: <specify the role of plano>
// Example:
// <Specify a usage example>
//
PROCEDURE PUBLIC GLOBAL evento_gravar_UUID(tabela, campoUUID, nomeJanela, tableGrid, plano)

IF tabela = ""
RETURN
END

IF nomeJanela = ""
RETURN
END

IF tableGrid = ""
RETURN
END

IF plano = 0
RETURN
END

gb_Status = False

// Lê o conteúdo dos controles de tela //pagina
ScreenToFile()

IF {tabela,indFile}..NewRecord = True THEN
IF gs_acao = "incluir" THEN
Indirection is string = tabela +"."+ campoUUID
{Indirection,indItem} = GetUUID()
IF HAdd(tabela) = True
gb_Status = True
Info("Gravou com sucesso")
ELSE
gb_Status = False
Info(HErrorInfo()+ErrorInfo())
END
END
// aqui voce faz os tratamentos
ELSE
// Modifica o registro seleciona
IF gs_acao = "alterar"
IF HModify(tabela) = True THEN
gb_Status = True
evento_lock_not_record(tabela,gn_ID)
Info("Gravou com sucesso")
ELSE
gb_Status = False
Info(HErrorInfo()+ErrorInfo())
END
END
END

TableDisplay({tableGrid},taInit)

TableDisplay({tableGrid},taReExecuteQuery)

// Retornar um valor da janela
MyWindow.ReturnedValue = True

evento_go_plane(nomeJanela,plano)


//-------------------------------------------------------------------------------------------------


// Summary: <specify the procedure action>
// Syntax:
//evento_incluir (<tabela>, <GrupoCampos>)
//
// Parameters:
// tabela: <specify the role of tabela>
// GrupoCampos: <specify the role of GrupoCampos>
// Example:
// <Specify a usage example>
//
// Return value:
// ID: <specify the role of tableGrid>
// nomeJanela: <specify the role of nomeJanela>
PROCEDURE PUBLIC GLOBAL evento_incluir(tabela, GrupoCampos)

//Info("incluir",tabela, nomeJanela, tableGrid, acao, ID)

IF tabela = "" THEN
RETURN
END

IF GrupoCampos = "" THEN
RETURN
END

IF gs_nomeJanela = "" THEN
RETURN
END

// Ao criar um novo registro
gs_acao = "incluir"

//Limpar variaveis
gn_ID = 0

{GrupoCampos} = ""

// Limpa o buffer do arquivo e carregamos os valores default
HReset(tabela)
//plane
evento_go_plane(gs_nomeJanela,2)


//-------------------------------------------------------------------------------------------------


// Summary: <specify the procedure action>
// Syntax:
//[ <Result> = ] evento_lock_not_record (<tabela>, <idunico>)
//
// Parameters:
// tabela:
// idunico: <specify the role of idunico>
// Example:
// <Specify a usage example>
//
PROCEDURE PUBLIC GLOBAL evento_lock_not_record(tabela,idunico)

IF tabela = "" OR idunico = ""
RESULT False
ELSE

HReset(tabela)

IF HUnlockRecNum(tabela,idunico) = True THEN
glo_unlock_record_time = DateSys()+TimeSys()
RESULT True
ELSE
RESULT False
END

END


//-------------------------------------------------------------------------------------------------


// Summary: <specify the procedure action>
// Syntax:
//[ <Result> = ] evento_lock_record (<tabela>, <idunico>)
//
// Parameters:
// tabela:
// idunico: <specify the role of idunico>
// Example:
// <Specify a usage example>
//
PROCEDURE PUBLIC GLOBAL evento_lock_record(tabela,idunico)

IF tabela = "" OR idunico = ""
RESULT False
ELSE

HReset(tabela)

IF HLockRecNum(tabela,idunico,hLockReadWrite) = True THEN
glo_lock_record_time = DateSys()+TimeSys()
RESULT True
ELSE
RESULT False
END

END


//-------------------------------------------------------------------------------------------------


// Summary: <specify the procedure action>
// Syntax:
//evento_procedure (<tabela>, <nomeJanela>, <tableGrid>, <Parametros>)
//
// Parameters:
// tabela: <specify the role of tabela>
// nomeJanela: <specify the role of nomeJanela>
// tableGrid: <specify the role of tableGrid>
// Parametros: <specify the role of Parametros>
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_procedure(tabela, nomeJanela, tableGrid, Parametros)

Info(tabela, nomeJanela, tableGrid, Parametros)




//-------------------------------------------------------------------------------------------------



// Summary: <specify the procedure action>
// Syntax:
//[ <Result> = ] evento_selecionar ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
// TableGrid: <specify the role of TableGrid>
// Col_ID: <specify the role of Col_ID>
PROCEDURE PUBLIC GLOBAL evento_selecionar()

IF gs_TableGrid = ""
RETURN
END

IF gs_TableGrid_ColunaID = 0 OR gs_TableGrid_ColunaID = ""
RETURN
END

gn_ID = 0

TableGrid is string = gs_TableGrid

Col_ID is string = gs_TableGrid_ColunaID

nx is 8-byte int = TableInfoXY({TableGrid},tiLineNumber,MouseXPos(),MouseYPos())

IF nx > 0 AND Col_ID <> ""

Indirection is string = TableGrid+"["+nx+"]."+Col_ID

IF nx > 0 AND TableGrid <> "" AND Col_ID <> ""
gn_ID = {Indirection}
ELSE
gn_ID = 0
END

ELSE

gn_ID = 0

END



//-------------------------------------------------------------------------------------------------



// Summary: <specify the procedure action>
// Syntax:
//[ <Result> = ] evento_selecionar_abrir ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
// TableGrid: <specify the role of TableGrid>
// Col_ID: <specify the role of Col_ID>
// BotaoAlterar: <specify the role of BotaoAlterar>
PROCEDURE PUBLIC GLOBAL evento_selecionar_abrir()

IF gs_TableGrid = ""
RETURN
END

IF gs_BotaoAlterar = "" THEN
RETURN
END

IF gs_TableGrid_ColunaID = 0 THEN
RETURN
END

gn_ID = 0

TableGrid is string = gs_TableGrid

Col_ID is string = gs_TableGrid_ColunaID

nx is 8-byte int = TableInfoXY({TableGrid},tiLineNumber,MouseXPos(),MouseYPos())

IF nx > 0 AND Col_ID <> ""

Indirection is string = TableGrid+"["+nx+"]."+Col_ID

IF nx > 0 AND TableGrid <> "" AND Col_ID <> ""

gn_ID = {Indirection}

IF gn_ID > 0 AND nx > 0

ExecuteProcess({gs_BotaoAlterar},trtClick)

ELSE

gn_ID = 0

END


ELSE
gn_ID = 0
END

ELSE

gn_ID = 0

END


//-------------------------------------------------------------------------------------------------



// Summary: <specify the procedure action>
// Syntax:
//evento_voltar ()
//
// Parameters:
// None
// Example:
// <Specify a usage example>
//
// Return value:
PROCEDURE PUBLIC GLOBAL evento_voltar(nomePagina, tabela, plane)

evento_lock_not_record(tabela,gn_ID)

IF nomePagina = "" THEN
RETURN
END

IF plane = 0 THEN
RETURN
END

{nomePagina,indWindow}..Plane = plane


///--------------------------/// var globais ///---------------------------------------------------

GLOBAL
HModifyStructure("*")
HCreationIfNotFound("*")
HOpenConnection(myHfsql)
HChangeConnection("*",myHfsql)

gs_acao, gs_nomeJanela, gs_imagem_lateral, gs_BotaoAlterar, gs_CampoDestino, gs_TableFile, gs_CampoChave, gs_GrupoCampos, gs_TableGrid, gs_TableGrid_ColunaID, gs_TableGrid_Coluna_Name, gs_TipoBusca, gs_JanusGrid, gs_Debug is string
gn_ID, gn_NomeJanela_ControleDestino is 8-byte int
gb_Status, glo_debug is boolean
glo_lock_record_time, glo_unlock_record_time is DateTime

//--------------------------------------------------------------------
EXTERN "Except.wl"
EXTERN "Limites.wl"
EXTERN "WinConst.wl"
EXTERN "KeyConst.wl"
EXTERN "ListeDefinitionHF.wl"
//--------------------------------------------------------------------