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);
}