コード例 #1
0
        /// <summary>
        /// Main procedure to display ancestry of a person
        /// </summary>
        /// <param name="personID">Id of target person.</param>
        /// <returns>True if successful, false otherwise.</returns>
        private bool displayPersonsAncestry(string personID)
        {
            //Declare an Ancestry.
            AncestryResultsState myAncestry;
            //Declare a Person
            PersonState myPerson;
            //Number of generations to retrieve.
            const int countOfGenerations = 5;

            try
            {
                //Get Target Person.
                myPerson = FamilyTree.ReadPersonById(personID);

                //Read that person's ancestry.
                myAncestry = myPerson.ReadAncestry(QueryParameter.Generations(countOfGenerations));
            }
            catch (Exception myError)
            {
                //Display error.
                lblErrorMessage.Text = myError.Message.ToString();

                //Return false for failure.
                return(false);
            }

            //Do we have ancestry?
            if (myAncestry != null)
            {
                //Display Ancestry
                showAncestryOnForm(myAncestry, countOfGenerations);
            }

            //We are done: success.
            return(true);
        }