From 2e2c44c7cd4e995794d516074ff7f70f92882b29 Mon Sep 17 00:00:00 2001 From: Bruno Regis Date: Fri, 30 Apr 2021 17:38:23 +0100 Subject: [PATCH] Update frmDemoGridEdit.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O evento "F4RowFields" é utilizado apenas internamente no produto, não sendo possível a sua utilização em "CustomForms". Uma solução será "procurar" no StackTrace pelo método que devolve valores por F4: "AtribuiValoresF4" combinando com o evento "LeaveCell" da grelha. --- src/User Interface/frmDemoGridEdit.cs | 38 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/User Interface/frmDemoGridEdit.cs b/src/User Interface/frmDemoGridEdit.cs index 036d402..ae7fef0 100644 --- a/src/User Interface/frmDemoGridEdit.cs +++ b/src/User Interface/frmDemoGridEdit.cs @@ -306,40 +306,46 @@ private string DaValoresComboTipoAnomalia() "Quebra\t" + "Defeito"; } - - public void F4RowFields(string Categoria, string NomeCampo, dynamic Valor) + + + private void priGrelha1_LeaveCell(object Sender, PriGrelha.LeaveCellEventArgs e) { - try + if (e.Col == e.NewCol) + return; + + //Tratar o F4 na priGrelha1 + if (F4FromPLT() == true) { - if (Categoria == ConstantesPrimavera100.Categorias.Artigo) + if (e.Col == priGrelha1.Cols.GetEdita(colArtigo).Number) { - TrataColuna_Artigo(priGrelha1.Grelha.ActiveRow); + TrataColuna_Artigo(e.Row); } - else if (Categoria == ConstantesPrimavera100.Categorias.Unidade) + else if (e.Col == priGrelha1.Cols.GetEdita(colEntidade).Number) { - TrataColuna_Unidade(priGrelha1.Grelha.ActiveRow); + TrataColuna_Entidade(e.Row); } - else if ((Categoria == ConstantesPrimavera100.Categorias.Cliente) || (Categoria == ConstantesPrimavera100.Categorias.Fornecedor) || (Categoria == ConstantesPrimavera100.Categorias.OutroTerceiro)) + else if (e.Col == priGrelha1.Cols.GetEdita(colUnidade).Number) { - TrataColuna_Entidade(priGrelha1.Grelha.ActiveRow); + TrataColuna_Unidade(priGrelha1.Grelha.ActiveRow); } - else if (Categoria == ConstantesPrimavera100.Categorias.Armazem) + else if (e.Col == priGrelha1.Cols.GetEdita(colArmazem).Number) { TrataColuna_Armazem(priGrelha1.Grelha.ActiveRow); } - else if (Categoria == ConstantesPrimavera100.Categorias.ArmazemLocalizacoes) + else if (e.Col == priGrelha1.Cols.GetEdita(colLocalizacao).Number) { TrataColuna_Localizacao(priGrelha1.Grelha.ActiveRow); } - else if (Categoria == ConstantesPrimavera100.Categorias.EstadosInventario) + else if (e.Col == priGrelha1.Cols.GetEdita(colEstado).Number) { TrataColuna_Estado(priGrelha1.Grelha.ActiveRow); } } - catch (Exception ex) - { - PSO.Dialogos.MostraErro("Erro ao carregar o registo.", StdPlatBS100.StdBSTipos.IconId.PRI_Exclama, ex.Message, ex); - } + } + + private bool F4FromPLT() + { + return new StackTrace().GetFrames().Any(r => r.GetMethod().Name.Contains("AtribuiValoresF4")); } private void ExecuteDrillDown()