public bool Generar(string data, out int totalPA, out int registradosPA, out int registradosPersonas) { string[] arrChecked = data.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); totalPA = arrChecked.Length; registradosPA = 0; registradosPersonas = 0; bool all_result = true; bool TMP = true; int NOT_FOUND = -1; List <string> listIDSIU = new List <string>(); foreach (string itemChecked in arrChecked) { long.TryParse(itemChecked, out PK_PA); bool ok; bool personaActualizada; IPersona persona = this as IPersona; IPA PA = this as IPA; if (PA.editPA(TMP)) { personaActualizada = listIDSIU.Contains(IDSIU); if (personaActualizada || persona.editPersona(TMP)) { if (personaActualizada) { ok = true; } else { if (persona.findPersona() == NOT_FOUND) { ok = persona.addPersona(); } else { ok = persona.savePersona(); } registradosPersonas++; } if (ok) { if (PA.findPA() == NOT_FOUND) { ok = PA.addPA(); } else { ok = PA.savePA(); } if (ok) { markPersona(); markPA(); registradosPA++; if (personaActualizada == false) { listIDSIU.Add(IDSIU); } continue; } } } } all_result = false; break; } return(all_result); }