Example #1
0
        private void grdChildren_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (familyId == -1)
            {
                familyId = DBAccessStatic.InsertFamily(husbandId, wifeId, txtMarriedDate.Text, txtMariedPlace.Text);
            }

            if (grdChildren[0, e.RowIndex].Value == null)
            {
                int childID = DBAccessStatic.InsertIndividual("", "", "", "", "", "", familyId, "");
                grdChildren[0, e.RowIndex].Value = childID;
                DBAccessStatic.InsertFamilyChild(familyId, childID);
            }

            if (e.ColumnIndex == 1)
            {
                string surname   = GenValidation.GetSurname(grdChildren["ChildName", e.RowIndex].Value.ToString());
                string firstname = GenValidation.GetFirstname(grdChildren["ChildName", e.RowIndex].Value.ToString());

                DBAccessStatic.UpdateIndividualFirstname((int)grdChildren[0, e.RowIndex].Value, firstname);
                DBAccessStatic.UpdateIndividualSurname((int)grdChildren[0, e.RowIndex].Value, surname);
            }
            else if (e.ColumnIndex == 2)
            {
                DBAccessStatic.UpdateIndividualGender((int)grdChildren[0, e.RowIndex].Value, grdChildren[2, e.RowIndex].Value.ToString());
            }
            else if (e.ColumnIndex == 3)
            {
                DBAccessStatic.UpdateIndividualBornDate((int)grdChildren[0, e.RowIndex].Value, grdChildren[3, e.RowIndex].Value.ToString());
            }
            else if (e.ColumnIndex == 4)
            {
                DBAccessStatic.UpdateIndividualDiedDate((int)grdChildren[0, e.RowIndex].Value, grdChildren[4, e.RowIndex].Value.ToString());
            }
        }
        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();
        }
Example #3
0
 private void txtWifeName_Leave(object sender, EventArgs e)
 {
     if (txtWifeName.Text.Trim().Length > 0)
     {
         string surname   = GenValidation.GetSurname(txtWifeName.Text.Trim());
         string firstname = GenValidation.GetFirstname(txtWifeName.Text.Trim());
         if (wifeId == -1)
         {
             wifeId = DBAccessStatic.InsertIndividual(surname, firstname, "", "", "", "", -1, "F");
         }
         else
         {
             DBAccessStatic.UpdateIndividualSurname(wifeId, surname);
             DBAccessStatic.UpdateIndividualFirstname(wifeId, firstname);
         }
         if ((familyId == -1) && (husbandId != -1))
         {
             familyId = DBAccessStatic.InsertFamily(husbandId, wifeId, txtMarriedDate.Text, txtMariedPlace.Text);
         }
     }
     else
     {
         MessageBox.Show("Name field cannot be left empty.");
     }
 }
Example #4
0
        private void LoadIndividuals()
        {
            lstIndividuals.Items.Clear();

            DataSet individuals = DBAccessStatic.GetAllIndividuals();

            for (int i = 0; i < individuals.Tables[0].Rows.Count; i++)
            {
                lstIndividuals.Items.Add(GenValidation.GetNameWithDates(individuals.Tables[0].Rows[i]["Surname"].ToString(), individuals.Tables[0].Rows[i]["Firstname"].ToString(), individuals.Tables[0].Rows[i]["BornDate"].ToString(), individuals.Tables[0].Rows[i]["DiedDate"].ToString()));
                individualIds.Add((int)(individuals.Tables[0].Rows[i]["ID"]));
            }
        }
        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();
        }