private void AncestryReportForm_Activated(object sender, EventArgs e) { ancestorCalculation = new AncestorCalc(MaxDepth); ancestorCalculation.CalculateAncestors(IndividualId, UniqueAncestors); report.Clear(); Individualg individual = new Individualg(); StringBuilder reportText = new StringBuilder(); for (int i = 0; i <= ancestorCalculation.GenerationCount; i++) { reportText.AppendLine("Generation " + (i + 1).ToString()); reportText.AppendLine("----------------"); for (int j = 0; j < ancestorCalculation.ancestryList[i].Count; j++) { individual = (Individualg)(ancestorCalculation.ancestryList[i][j]); reportText.AppendLine(GenValidation.GetNameWithDates(individual.Surname, individual.Firstname, individual.BirthDate, individual.DiedDate)); } reportText.AppendLine(""); } reportText.AppendLine("Number of ancestors: " + ancestorCalculation.IndividualCount.ToString()); report.Text = reportText.ToString(); }
public void GenerateDescendantsFamilyList(int individualId, int depth) { if ((descendantIds.ContainsKey(individualId)) && (UniqueDescendants == true)) { //do nothing since we can ignore it } else { DataSet individualDS = dbAccess.GetIndividual(individualId); if (!descendantIds.ContainsKey(individualId)) { descendantIds.Add(individualId, individualId); } IndividualCount++; if (GenerationCount < depth) { GenerationCount = depth; } if (individualDS.Tables[0].Rows.Count > 0) { int parentFamilyId = (int)(individualDS.Tables[0].Rows[0]["ParentFamilyId"]); Individualg individual = new Individualg(individualId, individualDS.Tables[0].Rows[0]["Firstname"].ToString(), individualDS.Tables[0].Rows[0]["Surname"].ToString(), individualDS.Tables[0].Rows[0]["Gender"].ToString(), individualDS.Tables[0].Rows[0]["BornDate"].ToString(), individualDS.Tables[0].Rows[0]["BornPlace"].ToString(), individualDS.Tables[0].Rows[0]["DiedDate"].ToString(), individualDS.Tables[0].Rows[0]["DiedPlace"].ToString(), parentFamilyId); descendantList[depth].Add(individual); if (depth < MaxDepth) { DataSet familyDS = dbAccess.GetFamilyByPerson(individualId); for (int i = 0; i < familyDS.Tables[0].Rows.Count; i++) { int familyId = (int)(familyDS.Tables[0].Rows[i]["ID"]); int husbandId = (int)(familyDS.Tables[0].Rows[i]["HusbandId"]); int wifeId = (int)(familyDS.Tables[0].Rows[i]["WifeId"]); Familyg family = new Familyg(familyId, husbandId, wifeId, familyDS.Tables[0].Rows[i]["MarriageDate"].ToString(), familyDS.Tables[0].Rows[i]["MarriagePlace"].ToString()); descendantFamilyList[depth].Add(family); DataSet familyChildrenDS = dbAccess.GetFamilyChildren(familyId); for (int j = 0; j < familyChildrenDS.Tables[0].Rows.Count; j++) { GenerateDescendantsFamilyList((int)(familyChildrenDS.Tables[0].Rows[j]["ChildId"]), depth + 1); } } } } } }
private void GenerateAncestryFamilyList(int individualId, int depth) { if ((ancestryIds.ContainsKey(individualId)) && (UniqueAncestors == true)) { //do nothing since we can ignore it } else { DataSet individualDS = dbAccess.GetIndividual(individualId); if (!ancestryIds.ContainsKey(individualId)) { ancestryIds.Add(individualId, individualId); } IndividualCount++; if (GenerationCount < depth) { GenerationCount = depth; } if (individualDS.Tables[0].Rows.Count > 0) { int parentFamilyId = (int)(individualDS.Tables[0].Rows[0]["ParentFamilyId"]); Individualg individual = new Individualg(individualId, individualDS.Tables[0].Rows[0]["Firstname"].ToString(), individualDS.Tables[0].Rows[0]["Surname"].ToString(), individualDS.Tables[0].Rows[0]["Gender"].ToString(), individualDS.Tables[0].Rows[0]["BornDate"].ToString(), individualDS.Tables[0].Rows[0]["BornPlace"].ToString(), individualDS.Tables[0].Rows[0]["DiedDate"].ToString(), individualDS.Tables[0].Rows[0]["DiedPlace"].ToString(), parentFamilyId); ancestryList[depth].Add(individual); if (depth < MaxDepth) { DataSet familyDS = dbAccess.GetFamily(parentFamilyId); if (familyDS.Tables[0].Rows.Count > 0) { int husbandId = (int)(familyDS.Tables[0].Rows[0]["HusbandId"]); int wifeId = (int)(familyDS.Tables[0].Rows[0]["WifeId"]); Familyg family = new Familyg(parentFamilyId, husbandId, wifeId, familyDS.Tables[0].Rows[0]["MarriageDate"].ToString(), familyDS.Tables[0].Rows[0]["MarriagePlace"].ToString()); ancestryFamilyList[depth].Add(family); if (husbandId != -1) { GenerateAncestryFamilyList(husbandId, depth + 1); } if (wifeId != -1) { GenerateAncestryFamilyList(wifeId, depth + 1); } } } } } }
private void DescendantReportForm_Activated(object sender, EventArgs e) { descendantCalc = new DescendantCalc(MaxDepth); descendantCalc.CalculateDescendants(IndividualId, UniqueDescendants); report.Clear(); Individualg individual = new Individualg(); StringBuilder reportText = new StringBuilder(); string birthDate, diedDate; for (int i = 0; i <= descendantCalc.GenerationCount; i++) { reportText.AppendLine("Generation " + (i + 1).ToString()); reportText.AppendLine("----------------"); for (int j = 0; j < descendantCalc.descendantList[i].Count; j++) { individual = (Individualg)(descendantCalc.descendantList[i][j]); if (individual.BirthDate == "") { birthDate = "?"; } else { birthDate = individual.BirthDate; } if (individual.DiedDate == "") { diedDate = "?"; } else { diedDate = individual.DiedDate; } reportText.AppendLine(GenValidation.GetNameWithDates(individual.Surname, individual.Firstname, individual.BirthDate, individual.DiedDate)); } reportText.AppendLine(""); } reportText.AppendLine("Number of descendants: " + descendantCalc.IndividualCount.ToString()); report.Text = reportText.ToString(); }