Friends I have a Billing system still in CFDI 3.3, I am in Payments 2.0 so I am putting the Related Documents in a Grid, then I do the following foreach
List<PagosPagoDoctoRelacionado> lstDocRel = new List<PagosPagoDoctoRelacionado>();
PagosPagoDoctoRelacionado docRelacionado = new PagosPagoDoctoRelacionado();
foreach (DataGridViewRow row in dgDocRel.Rows)
{
docRelacionado.IdDocumento = Convert.ToString(row.Cells["uuid_"].Value);
docRelacionado.Folio = Convert.ToString(row.Cells["folio_"].Value);
docRelacionado.MonedaDR = Convert.ToString(row.Cells["moneda_"].Value);
docRelacionado.MetodoDePagoDR = Convert.ToString(row.Cells["metodo_"].Value);
docRelacionado.NumParcialidad = Convert.ToString(row.Cells["parcialidad_"].Value);
docRelacionado.ImpPagadoSpecified = true;
docRelacionado.ImpPagado = Convert.ToDecimal(row.Cells["pagado_"].Value);
docRelacionado.ImpSaldoAntSpecified = true;
docRelacionado.ImpSaldoAnt = Convert.ToDecimal(row.Cells["anterior_"].Value);
docRelacionado.ImpSaldoInsolutoSpecified = true;
docRelacionado.ImpSaldoInsoluto = Convert.ToDecimal(row.Cells["insoluto_"].Value);
lstDocRel.Add(docRelacionado);
oPago.DoctoRelacionado = lstDocRel.ToArray();
}
When the XML is created and even when I put an interruption point for debug, I find that if it goes through the number of times of the rows and with the values well, only if for example there are 3 RelatedDocuments, the 3 are the last one, that is, the last route replaces the previous one and for this reason I have the same 3, does anyone know if I have an error in my code?