V10 - Sales Editor - BeforeRemoveLine

1

I have this little code to hit a sum in a CDU when a line is removed from the editor. However, when I have several rows and for example I remove the second line, the variable i always takes the value of the last line and hits the sum with the values of the last line and not of the line that I removed.

Can you help me figure out what I'm doing wrong?

public override void AntesDeRemoverLinha(ref bool Cancel, ExtensibilityEventArgs e)
{
    int i = this.DocumentoVenda.Linhas.NumItens;

    if (this.DocumentoVenda.Linhas.GetEdita(i).CamposUtil["CDU_PesoNet"].Valor > 0)
    {
        this.DocumentoVenda.CamposUtil["CDU_TotPesoNet"].Valor = PSO.Utils.FSng(this.DocumentoVenda.CamposUtil["CDU_TotPesoNet"].Valor) - (PSO.Utils.FSng(this.DocumentoVenda.Linhas.GetEdita(i).CamposUtil["CDU_PesoNet"].Valor) * this.DocumentoVenda.Linhas.GetEdita(i).Quantidade);
    }

    base.AntesDeRemoverLinha(ref Cancel, e);
}
    
asked by anonymous 19.10.2018 / 19:18

1 answer

3

Well this happens because the property numItens always has the total number of rows, if you have three rows and remove the first rows this property will get 2.

    
19.10.2018 / 21:12