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"
//--------------------------------------------------------------------