Form Migration to V10

Asked

Viewed 313 times

0

Good,

I have a form at V9 that is called in Keypress in a Sales Editor line and fills in a textbox depending on the line article.

Artigo.Text = EditorVendas.DocumentoVenda.Linhas(EditorVendas.LinhaActual).Artigo

I’m trying to migrate this development to V10 and I’m having some difficulties. What references do I need? Do I have to inherit Customform? What’s the best way to do this? Thank you.

This is how I did in VBA, had this code in the initialize of my Form.

Private Sub UserForm_Initialize()

Artigo.Text = EditorVendas.DocumentoVenda.Linhas(EditorVendas.LinhaActual).Artigo
Descricao.Text = EditorVendas.DocumentoVenda.Linhas(EditorVendas.LinhaActual).Descricao
QuantidadeEncomenda.Text = Format(EditorVendas.DocumentoVenda.Linhas(EditorVendas.LinhaActual).Quantidade, "##,##0.00")

End Sub

2 answers

1

Bruno, first of all start by creating a PEX project using the extension for the VS available on Markettplace, and that can be accessed here on network developers. This will always ensure all necessary references to the project.

As for your code, just do this:

using Primavera.Extensibility.BusinessEntities.ExtensibilityService.EventArgs;
using Primavera.Extensibility.Sales.Editors;

namespace ExtensibilityProject7.Sales
{
    public class UiEditorVendas : EditorVendas
    {
        public override void TeclaPressionada(int KeyCode, int Shift, ExtensibilityEventArgs e)
        {
            string artigo = this.DocumentoVenda.Linhas.GetEdita(this.LinhaActual).Artigo; 
        }
    }
}
  • Good Sergio, but in this case I want to be able to interact directly with the Sales Editor from a form of mine, without having to open it, for example. How can I do that in this version?

  • In the editor understand itself interface is not possible. It is only possible to manipulate the object associated with the sales document. But this is not the question that posed.

  • I may not have correctly asked the question. But how do I manipulate the object associated with the sales document?

  • Is available in context this.DocumentoVenda. So if you inherit from EditorVendas you have access to the objects there.

  • I had already tried to do that, but I cannot inherit Editorvendas... https://imgur.com/aoTynTh

  • As I said on https://developers.primaverabss.com/_v10/#comunidade gives access to the extension to the visual studio that puts there all the necessary references. I recommend that you install it.

  • But I already have the extension installed, and I still can’t. In a class it works perfectly, in a form it is not...

  • But that doesn’t work, they are different objects, as you can see by the error that VS is making in the shared image.

  • But this was possible in V9. In V10 is no longer?

  • Bruno does not know then what he wants to do, but in V9 this did not exist, that is, there is no inheritance. It is better to ask another question more detailed and with code that helps.

  • I am not referring to inheritance, but to the possibility of, for example, in the Load of my form, loading information from a sales document.

  • Sergio, I added the code to the question.

Show 7 more comments

1


What you really want is something quite different. So to have access to the selected line in the user form the best is just to pass the object in question and not the whole class. In VBA all classes were global and were always accessible and initialized, which is not the best in terms of good practices. Same goes for the way I was trying to do it. I recommend that whenever you have to work with parts of the object just use what you really need, makes your code clearer and easier to maintain.

using Primavera.Extensibility.BusinessEntities.ExtensibilityService.EventArgs;
using Primavera.Extensibility.Sales.Editors;

namespace ExtensibilityProject7.Sales
{
    public class UiEditorVendas : EditorVendas
    {
        public override void TeclaPressionada(int KeyCode, int Shift, ExtensibilityEventArgs e)
        {

            PriCustomForm1 form = new PriCustomForm1();

            // Passa a linha actual
            form.LinhaDoc = this.DocumentoVenda.Linhas.GetEdita(this.LinhaActual);
        }
    }
}

Your form must have something like this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Primavera.Extensibility.BusinessEntities;
using Primavera.Extensibility.CustomForm;

namespace ExtensibilityProject7.Sales
{
    public partial class PriCustomForm1 : CustomForm
    {
        public VndBE100.VndBELinhaDocumentoVenda LinhaDoc { get; set; }

        public PriCustomForm1()
        {
            string artigo = LinhaDoc.Artigo;
            string descricao = LinhaDoc.Descricao;
            double quantidadeEncomenda = LinhaDoc.Quantidade;

            InitializeComponent();
        }
    }
}
  • I had also tried this hypothesis, but after opening the sales editor, when opening my form, gives me the error "It is not possible to execute the Runtime link in a null reference". Remembering that I have Assembly resolve in my application. Thank you

  • @Brunogomes has a more up-to-date response

  • That’s how it worked, thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.