Example #1
0
 private void ResetParents()
 {
     ParentsEntry.Items.Clear();
     ParentsEntry.Items.Add("-Parents not listed");
     ParentsEntry.SelectedIndex = 0;
     for (int i = 1; i < MainW.GetNumParents(); i++)
     {
         Couples Current = MainW.GetParentsFromParentList(i);
         string  Entry   = "";
         if (LastNameEntry.Text != "")
         {
             if ((MainW.GetLastName(Current.GetFatherNumber()) == LastNameEntry.Text) || (MainW.GetMaidenName(Current.GetMotherNumber()) == LastNameEntry.Text) ||
                 (MainW.GetLastName(Current.GetMotherNumber()) == LastNameEntry.Text))
             {
                 if (Current.GetFatherNumber() == 0)
                 {
                     Entry += "[" + Current.GetMotherNumber().ToString("00000") + "] - " + MainW.GetLastName(Current.GetMotherNumber()) + ", " + MainW.GetFirstName(Current.GetMotherNumber());
                 }
                 else if (Current.GetMotherNumber() == 0)
                 {
                     Entry += "[" + Current.GetFatherNumber().ToString("00000") + "] - " + MainW.GetLastName(Current.GetFatherNumber()) + ", " + MainW.GetFirstName(Current.GetFatherNumber());
                 }
                 else
                 {
                     Entry += "[" + Current.GetFatherNumber().ToString("00000") + ", " + Current.GetMotherNumber().ToString("00000") + "] - " + MainW.GetLastName(Current.GetFatherNumber()) + ", " + MainW.GetFirstName(Current.GetFatherNumber()) + " and "
                              + MainW.GetFirstName(Current.GetMotherNumber());
                 }
                 ParentsEntry.Items.Add(Entry);
             }
         }
     }
 }
Example #2
0
        /// <summary>
        /// Adds a new record to the record list.
        /// </summary>
        /// <remarks>
        /// Called upon successful completion of a <c>NewRecord</c> form.
        /// </remarks>
        /// <param name="R">The current record number.</param>
        /// <param name="Fn">String containing first name.</param>
        /// <param name="Mn">String containing middle name.</param>
        /// <param name="Ln">String containing last name.</param>
        /// <param name="Mdn">String containing maiden name.</param>
        /// <param name="Prev">List of strings containing any previous last names used.</param>
        /// <param name="Bir">Datetimne containing the date of birth.</param>
        /// <param name="Dea">Datetime containing the date of death.</param>
        /// <param name="Mal">Bool representing gender (true for male).</param>
        /// <param name="Sp">The listed spouse's record number.</param>
        /// <param name="C">A <c>Couples</c> containing the listed parents.</param>
        /// <param name="K">A list of the record numbers of the listed children.</param>
        public void AddNewRecord(int R, string Fn, string Mn, string Ln, string Mdn, List <string> Prev, DateTime Bir, DateTime Dea, bool Mal, int Sp, Couples C, List <int> K)
        {
            // Add the results from the NewRecord form to the list of records.
            CurrentFamNode = new TreeNode(R, Fn, Mn, Ln, Mdn, Prev, Bir, Dea, Mal, Sp, C);
            FamTree.Add(CurrentFamNode);

            // Add this record to the list of couples.
            LogParent(R, Sp, Mal);

            // Add this record as a kid to the parent's kid list if parents are listed.
            if ((C.GetFatherNumber() != 0) || (C.GetMotherNumber() != 0))
            {
                // Add to father.
                if (C.GetFatherNumber() != 0)
                {
                    List <int> TempChildren = FamTree[C.GetFatherNumber()].GetChildren();
                    bool       found        = false;
                    for (int i = 0; i < TempChildren.Count; i++)
                    {
                        if (TempChildren[i] == R)
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        TempChildren.Add(R);
                    }
                }

                // Add to mother.
                if (C.GetMotherNumber() != 0)
                {
                    List <int> TempChildren = FamTree[C.GetMotherNumber()].GetChildren();
                    bool       found        = false;
                    for (int i = 0; i < TempChildren.Count; i++)
                    {
                        if (TempChildren[i] == R)
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        TempChildren.Add(R);
                    }
                }
            }

            // If kids were listed add them to this record then set this record as a parent for each kid.
            if (K.Count != 0)
            {
                SetChildren(K, R);
                Couples TempPar = new Couples();
                for (int j = 1; j < ParentsList.Count; j++)
                {
                    if (Mal)
                    {
                        if (ParentsList[j].GetFatherNumber() == R)
                        {
                            TempPar = ParentsList[j];
                        }
                    }
                    else
                    {
                        if (ParentsList[j].GetMotherNumber() == R)
                        {
                            TempPar = ParentsList[j];
                        }
                    }
                }
                for (int i = 0; i < K.Count; i++)
                {
                    FamTree[K[i]].SetParents(TempPar);
                }
            }

            // If spouse was listed set this record as the spouse's spouse then share both spouse's listed kids.
            // (May need to verify that both spouses end up with the same kids list).
            if (Sp != 0)
            {
                FamTree[Sp].SetSpouse(R);
                if (K.Count != 0)
                {
                    List <int> TempChildren = FamTree[Sp].GetChildren();
                    foreach (int i in K)
                    {
                        bool found = false;
                        foreach (int j in FamTree[Sp].GetChildren())
                        {
                            if (j == i)
                            {
                                found = true;
                            }
                        }
                        if (found == false)
                        {
                            TempChildren.Add(i);
                        }
                    }
                    FamTree[Sp].SetChildren(TempChildren);
                }
            }
        }