VBA Migration to C # - V10 (KeyPressed)

0

In VBA in the KeyPress event would be this way. Thanks to v / help for converts to C #.

Private Sub EditorVendas_TeclaPressionada(KeyCode As Integer, Shift As Integer)
Dim i As Long
Dim CaractsArtigoPT As StdBECampos
Dim objLinha As GcpBELinhaDocumentoVenda

i = Me.DocumentoVenda.Linhas.NumItens

If KeyCode = KeyCodeConstants.vbKeyY And Shift = 2 Then

Set CaractsArtigoPT = BSO.Comercial.ArtigosIdiomas.DaValorAtributos(Me.DocumentoVenda.Linhas(i).Artigo, "PT", "Caracteristicas")

    If Not CaractsArtigoPT Is Nothing Then

        If CaractsArtigoPT.NumItens > 0 Then

            Set objLinha = New GcpBELinhaDocumentoVenda
                objLinha.TipoLinha = 60
                    objLinha.Descricao = "" & CaractsArtigoPT("Caracteristicas")
                        Me.DocumentoVenda.Linhas.Insere objLinha

        End If

    End If

Set CaractsArtigoPT = Nothing

End If

End Sub
    
asked by anonymous 13.07.2018 / 13:23

1 answer

3

The code will look something like this:

public override void TeclaPressionada(int KeyCode, int Shift, ExtensibilityEventArgs e)
{
    base.TeclaPressionada(KeyCode, Shift, e);

    int i = this.DocumentoVenda.Linhas.NumItens;
    StdBE100.StdBECampos CaractsArtigoPT = null;
    VndBE100.VndBELinhaDocumentoVenda objLinha = null;

    try
    {
        if (KeyCode == (int)Keys.Y && Shift == 2)
        {
            CaractsArtigoPT = BSO.Base.ArtigosIdiomas.DaValorAtributos(this.DocumentoVenda.Linhas.GetEdita(i).Artigo, "PT", "Caracteristicas");

            if (CaractsArtigoPT?.NumItens > 0)
            {
                this.DocumentoVenda.Linhas.Insere
                (
                    objLinha = new VndBE100.VndBELinhaDocumentoVenda()
                    {
                        TipoLinha = "60",
                        Descricao = PSO.Utils.FStr(CaractsArtigoPT["Caracteristicas"].Valor)
                    }
                );
            }

            CaractsArtigoPT = null;
        }
    }
    catch (System.Exception ex)
    {
        PSO.Dialogos.MostraErro(ex.Message, StdPlatBS100.StdBSTipos.IconId.PRI_Exclama);
    }
}

You still need to add the references IBasBS100.dll and System.Windows.Forms.dll .

    
13.07.2018 / 15:22