Exemplo n.º 1
0
        public static bool HasCurrentCommitmentRecord(Int64 APartnerKey)
        {
            PmStaffDataTable StaffDataDT;
            bool             Result = false;

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction,
                                                           delegate
            {
                StaffDataDT = PmStaffDataAccess.LoadByPrimaryKey(0, APartnerKey, Transaction);

                foreach (PmStaffDataRow row in StaffDataDT.Rows)
                {
                    if ((row.IsEndOfCommitmentNull() ||
                         (row.EndOfCommitment >= DateTime.Today)) &&
                        (row.IsStartOfCommitmentNull() ||
                         (row.StartOfCommitment <= DateTime.Today)))
                    {
                        Result = true;
                    }
                }
            });

            return(Result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load all the data of a partner into a TDS
        /// </summary>
        public static PartnerImportExportTDS ExportPartner(Int64 APartnerKey)
        {
            PartnerImportExportTDS MainDS      = new PartnerImportExportTDS();
            TDBTransaction         Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PVenueAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

            PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

            PPartnerCommentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PPartnerInterestAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PPartnerGiftDestinationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

            PInterestAccess.LoadAll(MainDS, Transaction);

            PmPersonalDataAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
            PmPassportDetailsAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmDocumentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PmDocumentTypeAccess.LoadAll(MainDS, Transaction);
            PmPersonQualificationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmSpecialNeedAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmPastExperienceAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmPersonLanguageAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmPersonAbilityAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmJobAssignmentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            PmPersonEvaluationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);

            PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(MainDS, APartnerKey, Transaction);
            PtApplicationTypeAccess.LoadAll(MainDS, Transaction);
            PmShortTermApplicationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            PmYearProgramApplicationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);

            UmUnitStructureAccess.LoadViaPUnitChildUnitKey(MainDS, APartnerKey, Transaction);
            UmUnitAbilityAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmUnitLanguageAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmUnitCostAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmJobAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmJobRequirementAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmJobLanguageAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
            UmJobQualificationAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);

            PcBuildingAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction);
            PcRoomAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction);

            DBAccess.GDBAccessObj.RollbackTransaction();
            return(MainDS);
        }
Exemplo n.º 3
0
        public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey)
        {
            PersonnelTDS   MainDS      = new PersonnelTDS();
            TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

            PmCommitmentStatusAccess.LoadAll(MainDS, Transaction);
            PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);

            DBAccess.GDBAccessObj.RollbackTransaction();
            return(MainDS);
        }
Exemplo n.º 4
0
        public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey)
        {
            PersonnelTDS   MainDS      = new PersonnelTDS();
            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction,
                                                           delegate
            {
                PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                PmCommitmentStatusAccess.LoadAll(MainDS, Transaction);
                PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            });

            return(MainDS);
        }
Exemplo n.º 5
0
        public static PersonnelTDS LoadPersonellStaffData(Int64 APartnerKey)
        {
            PersonnelTDS   MainDS      = new PersonnelTDS();
            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(ref Transaction,
                                     delegate
            {
                PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                PmCommitmentStatusAccess.LoadAll(MainDS, Transaction);
                PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
            });

            return(MainDS);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Determines the number of DataRows for the Individual Data Items that work on multiple DataRows.
        /// </summary>
        /// <param name="AMiscellaneousDataDR">Instance of <see cref="IndividualDataTDSMiscellaneousDataRow" />.</param>
        /// <param name="AReadTransaction">Open Database transaction.</param>
        /// <returns>void</returns>
        private static void DetermineItemCounts(IndividualDataTDSMiscellaneousDataRow AMiscellaneousDataDR, TDBTransaction AReadTransaction)
        {
            Int64 PartnerKey = AMiscellaneousDataDR.PartnerKey;

            // Note: Commitment Records are counted already in BuildSummaryData and therefore don't need to be done here.

            AMiscellaneousDataDR.ItemsCountPassportDetails    = PmPassportDetailsAccess.CountViaPPerson(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountPersonalDocuments  = PmDocumentAccess.CountViaPPerson(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountProfessionalAreas  = PmPersonQualificationAccess.CountViaPPerson(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountPersonalLanguages  = PmPersonLanguageAccess.CountViaPPerson(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountPersonalAbilities  = PmPersonAbilityAccess.CountViaPPerson(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountPreviousExperience = PmPastExperienceAccess.CountViaPPerson(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountCommitmentPeriods  = PmStaffDataAccess.CountViaPPerson(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountJobAssignments     = PmJobAssignmentAccess.CountViaPPartner(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountProgressReports    = PmPersonEvaluationAccess.CountViaPPerson(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountPersonSkills       = PmPersonSkillAccess.CountViaPPerson(PartnerKey, AReadTransaction);
            AMiscellaneousDataDR.ItemsCountApplications       = PmGeneralApplicationAccess.CountViaPPersonPartnerKey(PartnerKey, AReadTransaction);
        }
Exemplo n.º 7
0
        // check if a person has on going commitments
        private static bool PersonHasCommitments(PPersonTable ATable, TDBTransaction ATransaction)
        {
            foreach (PPersonRow Row in ATable.Rows)
            {
                PmStaffDataTable StaffDataTable = PmStaffDataAccess.LoadViaPPerson(Row.PartnerKey, ATransaction);

                foreach (PmStaffDataRow StaffRow in StaffDataTable.Rows)
                {
                    if (((StaffRow.EndOfCommitment >= DateTime.Now) || (StaffRow.EndOfCommitment == null)) &&
                        (StaffRow.StartOfCommitment <= DateTime.Now))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Load all the data of a partner into a TDS
        /// </summary>
        public static PartnerImportExportTDS ExportPartner(Int64 APartnerKey, TPartnerClass?APartnerClass = null)
        {
            PartnerImportExportTDS MainDS = new PartnerImportExportTDS();

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(
                ref Transaction,
                delegate
            {
                PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                // APartnerClass is optional but if it was not provided we need to assign to it now
                if (APartnerClass == null)
                {
                    APartnerClass = SharedTypes.PartnerClassStringToEnum(MainDS.PPartner[0].PartnerClass);
                }

                if (APartnerClass == TPartnerClass.CHURCH)
                {
                    PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.FAMILY)
                {
                    PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                    PPartnerGiftDestinationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.PERSON)
                {
                    PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                    PmPersonalDataAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                    PmPassportDetailsAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmDocumentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                    PmDocumentTypeAccess.LoadAll(MainDS, Transaction);
                    PmPersonQualificationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmSpecialNeedAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmPastExperienceAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmPersonLanguageAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmPersonAbilityAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmStaffDataAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmJobAssignmentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                    PmPersonEvaluationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmPersonSkillAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);

                    PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(MainDS, APartnerKey, Transaction);
                    PtApplicationTypeAccess.LoadAll(MainDS, Transaction);
                    PmShortTermApplicationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                    PmYearProgramApplicationAccess.LoadViaPPerson(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.ORGANISATION)
                {
                    POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.UNIT)
                {
                    PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                    UmUnitStructureAccess.LoadViaPUnitChildUnitKey(MainDS, APartnerKey, Transaction);
                    UmUnitAbilityAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmUnitLanguageAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmUnitCostAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmJobAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmJobRequirementAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmJobLanguageAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                    UmJobQualificationAccess.LoadViaPUnit(MainDS, APartnerKey, Transaction);
                }
                else if (APartnerClass == TPartnerClass.VENUE)
                {
                    PVenueAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

                    PcBuildingAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction);
                    PcRoomAccess.LoadViaPVenue(MainDS, APartnerKey, Transaction);
                }

                PPartnerAttributeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                PPartnerCommentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PPartnerInterestAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PInterestAccess.LoadAll(MainDS, Transaction);
            });

            return(MainDS);
        }
Exemplo n.º 9
0
        public void TestDeletePerson()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          FamilyPartnerRow;
            PPartnerRow          UnitPartnerRow;
            PPersonRow           PersonRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            // create new family, location and person
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            PersonRow = TCreateTestPartnerData.CreateNewPerson(MainDS,
                                                               FamilyPartnerRow.PartnerKey,
                                                               MainDS.PLocation[0].LocationKey,
                                                               "Mike",
                                                               "Mr",
                                                               0);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family and person record");

            // check if Family partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(PersonRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // add a commitment for the person which means the person is not allowed to be deleted any longer
            UnitPartnerRow = TCreateTestPartnerData.CreateNewUnitPartner(MainDS);
            PmStaffDataTable CommitmentTable = new PmStaffDataTable();
            PmStaffDataRow   CommitmentRow   = CommitmentTable.NewRowTyped();

            CommitmentRow.Key               = Convert.ToInt32(TSequenceWebConnector.GetNextSequence(TSequenceNames.seq_staff_data));
            CommitmentRow.PartnerKey        = PersonRow.PartnerKey;
            CommitmentRow.StartOfCommitment = DateTime.Today.Date;
            CommitmentRow.EndOfCommitment   = DateTime.Today.AddDays(90).Date;
            CommitmentRow.OfficeRecruitedBy = UnitPartnerRow.PartnerKey;
            CommitmentRow.HomeOffice        = UnitPartnerRow.PartnerKey;
            CommitmentRow.ReceivingField    = UnitPartnerRow.PartnerKey;
            CommitmentTable.Rows.Add(CommitmentRow);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create unit to be used in commitment");
            PmStaffDataAccess.SubmitChanges(CommitmentTable, DBAccess.GDBAccessObj.Transaction);

            // this should now not be allowed since person record has a commitment linked to it
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(PersonRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of Person partner
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            PersonRow = TCreateTestPartnerData.CreateNewPerson(MainDS,
                                                               FamilyPartnerRow.PartnerKey,
                                                               MainDS.PLocation[0].LocationKey,
                                                               "Mary",
                                                               "Mrs",
                                                               0);
            PartnerKey = PersonRow.PartnerKey;

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family and person record to be deleted");

            // check if Family record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Family record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Exemplo n.º 10
0
        public static void FillFormDataFromPersonnel(Int64 APartnerKey,
                                                     TFormDataPerson AFormDataPerson,
                                                     TFormLetterInfo AFormLetterInfo,
                                                     TDBTransaction AReadTransaction,
                                                     Int64 ASiteKey     = 0,
                                                     Int32 ALocationKey = 0)
        {
            TPartnerClass         PartnerClass;
            String                ShortName;
            TStdPartnerStatusCode PartnerStatusCode;

            if (AFormDataPerson == null)
            {
                return;
            }

            if (MCommonMain.RetrievePartnerShortName(APartnerKey, out ShortName, out PartnerClass, out PartnerStatusCode, AReadTransaction))
            {
                // first retrieve all partner information
// we cannot reference MPartner connect because of SimplePartnerEdit, cyclic dependencies
#if DISABLED_TP_20180623
                TFormLettersWebConnector.FillFormDataFromPerson(APartnerKey,
                                                                AFormDataPerson,
                                                                AFormLetterInfo,
                                                                AReadTransaction,
                                                                ASiteKey,
                                                                ALocationKey);
#endif

                // retrieve Special Needs information
                if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eSpecialNeeds))
                {
                    PmSpecialNeedTable SpecialNeedTable;
                    PmSpecialNeedRow   SpecialNeedRow;
                    SpecialNeedTable = PmSpecialNeedAccess.LoadViaPPerson(APartnerKey, AReadTransaction);

                    if (SpecialNeedTable.Count > 0)
                    {
                        SpecialNeedRow = (PmSpecialNeedRow)SpecialNeedTable.Rows[0];
                        AFormDataPerson.DietaryNeeds = SpecialNeedRow.DietaryComment;
                        AFormDataPerson.MedicalNeeds = SpecialNeedRow.MedicalComment;
                        AFormDataPerson.OtherNeeds   = SpecialNeedRow.OtherSpecialNeed;
                        AFormDataPerson.Vegetarian   = SpecialNeedRow.VegetarianFlag;
                    }
                }

                // retrieve Personal Data information
                if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePersonalData))
                {
                    PmPersonalDataTable PersonalDataTable;
                    PmPersonalDataRow   PersonalDataRow;
                    PersonalDataTable = PmPersonalDataAccess.LoadViaPPerson(APartnerKey, AReadTransaction);

                    if (PersonalDataTable.Count > 0)
                    {
                        PersonalDataRow = (PmPersonalDataRow)PersonalDataTable.Rows[0];

                        if (!PersonalDataRow.IsBelieverSinceYearNull() &&
                            (PersonalDataRow.BelieverSinceYear != 0))
                        {
                            AFormDataPerson.YearsBeliever = (DateTime.Today.Year - PersonalDataRow.BelieverSinceYear).ToString();
                        }

                        AFormDataPerson.CommentBeliever = PersonalDataRow.BelieverSinceComment;
                    }
                }

                // retrieve Passport information
                if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.ePassport))
                {
                    PmPassportDetailsTable PassportTable;
                    TFormDataPassport      PassportRecord;
                    PassportTable = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey, AReadTransaction);
                    Boolean MainPassportFound = false;

                    foreach (PmPassportDetailsRow PassportRow in PassportTable.Rows)
                    {
                        // only list "full" passports that have not expired yet
                        if ((PassportRow.IsDateOfExpirationNull() ||
                             (PassportRow.DateOfExpiration >= DateTime.Today)) &&
                            (PassportRow.PassportDetailsType == "P"))
                        {
                            PassportRecord = new TFormDataPassport();

                            PassportRecord.IsMainPassport  = PassportRow.MainPassport;
                            PassportRecord.Number          = PassportRow.PassportNumber;
                            PassportRecord.PassportName    = PassportRow.FullPassportName;
                            PassportRecord.NationalityCode = PassportRow.PassportNationalityCode;

                            // retrieve country name from country table
                            TCacheable    CachePopulator = new TCacheable();
                            PCountryTable CountryTable   =
                                (PCountryTable)CachePopulator.GetCacheableTable(TCacheableCommonTablesEnum.CountryList);
                            PCountryRow CountryRow =
                                (PCountryRow)CountryTable.Rows.Find(new object[] { PassportRow.PassportNationalityCode });

                            if (CountryRow != null)
                            {
                                PassportRecord.NationalityName = CountryRow.CountryName;
                            }

                            PassportRecord.TypeCode = PassportRow.PassportDetailsType;
                            // retrieve passport type name from type table
                            TPersonnelCacheable PersonnelCachePopulator = new TPersonnelCacheable();
                            PtPassportTypeTable TypeTable =
                                (PtPassportTypeTable)PersonnelCachePopulator.GetCacheableTable(TCacheablePersonTablesEnum.
                                                                                               PassportTypeList);
                            PtPassportTypeRow TypeRow =
                                (PtPassportTypeRow)TypeTable.Rows.Find(new object[] { PassportRow.PassportDetailsType });

                            if (TypeRow != null)
                            {
                                PassportRecord.TypeDescription = TypeRow.Description;
                            }

                            PassportRecord.DateOfIssue  = PassportRow.DateOfIssue;
                            PassportRecord.PlaceOfIssue = PassportRow.PlaceOfIssue;
                            PassportRecord.DateOfExpiry = PassportRow.DateOfExpiration;
                            PassportRecord.PlaceOfBirth = PassportRow.PlaceOfBirth;

                            // set number and nationality in main record (only for main passport or if there is just one)
                            if (PassportRow.MainPassport || (PassportTable.Count == 1))
                            {
                                AFormDataPerson.PassportNumber          = PassportRecord.Number;
                                AFormDataPerson.PassportNationality     = PassportRecord.NationalityName;
                                AFormDataPerson.PassportNationalityCode = PassportRecord.NationalityCode;
                                AFormDataPerson.PassportName            = PassportRecord.PassportName;
                                AFormDataPerson.PassportDateOfIssue     = PassportRecord.DateOfIssue;
                                AFormDataPerson.PassportPlaceOfIssue    = PassportRecord.PlaceOfIssue;
                                AFormDataPerson.PassportDateOfExpiry    = PassportRecord.DateOfExpiry;
                                AFormDataPerson.PassportPlaceOfBirth    = PassportRecord.PlaceOfBirth;

                                MainPassportFound = true;
                            }

                            // If the PassportName has not been set yet then make sure it is set on Person level from at least one passport
                            // (this will not be necessary any longer once the tick box for "Main Passport" is implemented)
                            if (!MainPassportFound)
                            {
                                AFormDataPerson.PassportName = PassportRecord.PassportName;
                            }

                            AFormDataPerson.AddPassport(PassportRecord);
                        }
                    }
                }

                // retrieve Language information
                if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eLanguage))
                {
                    PmPersonLanguageTable PersonLanguageTable;
                    TFormDataLanguage     PersonLanguageRecord;
                    PersonLanguageTable = PmPersonLanguageAccess.LoadViaPPerson(APartnerKey, AReadTransaction);

                    foreach (PmPersonLanguageRow PersonLanguageRow in PersonLanguageTable.Rows)
                    {
                        PersonLanguageRecord = new TFormDataLanguage();

                        PersonLanguageRecord.Code = PersonLanguageRow.LanguageCode;

                        // retrieve language name from language table
                        TCacheable     CachePopulator = new TCacheable();
                        PLanguageTable LanguageTable  =
                            (PLanguageTable)CachePopulator.GetCacheableTable(TCacheableCommonTablesEnum.LanguageCodeList);
                        PLanguageRow LanguageRow = (PLanguageRow)LanguageTable.Rows.Find(new object[] { PersonLanguageRow.LanguageCode });

                        if (LanguageRow != null)
                        {
                            PersonLanguageRecord.Name = LanguageRow.LanguageDescription;
                        }

                        PersonLanguageRecord.Level = PersonLanguageRow.LanguageLevel.ToString();

                        // retrieve language level name from language level table
                        TPersonnelCacheable  CachePopulatorPersonnel = new TPersonnelCacheable();
                        PtLanguageLevelTable LanguageLevelTable      =
                            (PtLanguageLevelTable)CachePopulatorPersonnel.GetCacheableTable(TCacheablePersonTablesEnum.LanguageLevelList);
                        PtLanguageLevelRow LanguageLevelRow =
                            (PtLanguageLevelRow)LanguageLevelTable.Rows.Find(new object[] { PersonLanguageRow.LanguageLevel });

                        if (LanguageLevelRow != null)
                        {
                            PersonLanguageRecord.LevelDesc = LanguageLevelRow.LanguageLevelDescr;
                        }

                        PersonLanguageRecord.Comment = PersonLanguageRow.Comment;

                        AFormDataPerson.AddLanguage(PersonLanguageRecord);
                    }
                }

                // retrieve Skill information
                if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eSkill))
                {
                    PmPersonSkillTable PersonSkillTable;
                    TFormDataSkill     PersonSkillRecord;
                    TFormDataDegree    PersonDegreeRecord;
                    PersonSkillTable = PmPersonSkillAccess.LoadViaPPerson(APartnerKey, AReadTransaction);

                    foreach (PmPersonSkillRow PersonSkillRow in PersonSkillTable.Rows)
                    {
                        PersonSkillRecord = new TFormDataSkill();

                        PersonSkillRecord.Category    = PersonSkillRow.SkillCategoryCode;
                        PersonSkillRecord.Description = PersonSkillRow.DescriptionEnglish;

                        // if no description in local language then use english
                        PersonSkillRecord.DescriptionLocalOrDefault = PersonSkillRow.DescriptionLocal;

                        if (PersonSkillRow.DescriptionLocal != "")
                        {
                            PersonSkillRecord.DescriptionLocalOrDefault = PersonSkillRow.DescriptionEnglish;
                        }

                        PersonSkillRecord.Level = PersonSkillRow.SkillLevel;

                        // retrieve skill level name from skill level table
                        TPersonnelCacheable CachePopulatorPersonnel = new TPersonnelCacheable();
                        PtSkillLevelTable   SkillLevelTable         =
                            (PtSkillLevelTable)CachePopulatorPersonnel.GetCacheableTable(TCacheablePersonTablesEnum.SkillLevelList);
                        PtSkillLevelRow SkillLevelRow =
                            (PtSkillLevelRow)SkillLevelTable.Rows.Find(new object[] { PersonSkillRow.SkillLevel });

                        if (SkillLevelRow != null)
                        {
                            PersonSkillRecord.LevelDesc = SkillLevelRow.Description;
                        }

                        PersonSkillRecord.YearsExp     = PersonSkillRow.YearsOfExperience;
                        PersonSkillRecord.Professional = PersonSkillRow.ProfessionalSkill;
                        PersonSkillRecord.Degree       = PersonSkillRow.Degree;
                        PersonSkillRecord.Comment      = PersonSkillRow.Comment;

                        AFormDataPerson.AddSkill(PersonSkillRecord);

                        // now add a degree record if a degree is mentioned
                        if (!PersonSkillRow.IsDegreeNull() &&
                            (PersonSkillRow.Degree.Length > 0))
                        {
                            PersonDegreeRecord      = new TFormDataDegree();
                            PersonDegreeRecord.Name = PersonSkillRow.Degree;
                            PersonDegreeRecord.Year = PersonSkillRow.YearOfDegree.ToString();

                            AFormDataPerson.AddDegree(PersonDegreeRecord);
                        }
                    }
                }

                // retrieve past work experience information
                if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eWorkExperience))
                {
                    TFormDataWorkExperience PersonExpRecord;

                    /*
                     * currently we don't include application records in the work experience data
                     *
                     * String UnitShortName;
                     * TPartnerClass UnitClass;
                     *
                     * // retrieve applications for short term events
                     * String SqlStmt = TDataBase.ReadSqlFile("Personnel.FormLetters.GetAppTravelDates.sql");
                     *
                     * OdbcParameter[] parameters = new OdbcParameter[1];
                     * parameters[0] = new OdbcParameter("PartnerKey", OdbcType.BigInt);
                     * parameters[0].Value = APartnerKey;
                     *
                     * DataTable travelData = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "TravelDates", ReadTransaction, parameters);
                     *
                     * for (int i = 0; i < travelData.Rows.Count; i++)
                     * {
                     *  PersonExpRecord = new TFormDataWorkExperience();
                     *
                     *  if ((travelData.Rows[i][0]).GetType() == typeof(DateTime))
                     *  {
                     *      PersonExpRecord.StartDate = (DateTime?)travelData.Rows[i][0];
                     *  }
                     *
                     *  if ((travelData.Rows[i][1]).GetType() == typeof(DateTime))
                     *  {
                     *      PersonExpRecord.EndDate = (DateTime?)travelData.Rows[i][1];
                     *  }
                     *
                     *  PersonExpRecord.Organisation = "";
                     *  PersonExpRecord.Role = "";
                     *  PersonExpRecord.Category = "";
                     *  PersonExpRecord.SameOrg = true;
                     *  PersonExpRecord.SimilarOrg = true;
                     *  PersonExpRecord.Comment = "";
                     *
                     *  // check if unit exists and use unit name as location
                     *  if (TPartnerServerLookups.GetPartnerShortName((Int64)travelData.Rows[i][2], out UnitShortName, out UnitClass))
                     *  {
                     *      PersonExpRecord.Location = UnitShortName;
                     *  }
                     *  else
                     *  {
                     *      PersonExpRecord.Location = travelData.Rows[i][3].ToString();
                     *  }
                     *
                     *  AFormDataPerson.AddWorkExperience(PersonExpRecord);
                     * }
                     */

                    // retrieve actual past experience records
                    PmPastExperienceTable PersonExpTable;
                    PersonExpTable = PmPastExperienceAccess.LoadViaPPerson(APartnerKey, AReadTransaction);
                    PUnitTable UnitTable;
                    PUnitRow   UnitRow;

                    foreach (PmPastExperienceRow PersonExpRow in PersonExpTable.Rows)
                    {
                        PersonExpRecord = new TFormDataWorkExperience();

                        PersonExpRecord.StartDate    = PersonExpRow.StartDate;
                        PersonExpRecord.EndDate      = PersonExpRow.EndDate;
                        PersonExpRecord.Location     = PersonExpRow.PrevLocation;
                        PersonExpRecord.Organisation = PersonExpRow.OtherOrganisation;
                        PersonExpRecord.Role         = PersonExpRow.PrevRole;
                        PersonExpRecord.Category     = PersonExpRow.Category;
                        PersonExpRecord.SameOrg      = PersonExpRow.PrevWorkHere;
                        PersonExpRecord.SimilarOrg   = PersonExpRow.PrevWork;
                        PersonExpRecord.Comment      = PersonExpRow.PastExpComments;

                        // check if previous experience came from an event with location set to event code
                        // -> in this case don't set event code as location but rather the event name
                        PUnitRow template = new PUnitTable().NewRowTyped(false);

                        template.OutreachCode = PersonExpRow.PrevLocation;

                        UnitTable = PUnitAccess.LoadUsingTemplate(template, AReadTransaction);

                        if (UnitTable.Rows.Count > 0)
                        {
                            UnitRow = (PUnitRow)UnitTable.Rows[0];
                            PersonExpRecord.Location = UnitRow.UnitName;
                        }

                        AFormDataPerson.AddWorkExperience(PersonExpRecord);
                    }
                }

                // retrieve Commitment information
                if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eCommitment) ||
                    AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eFutureCommitment))
                {
                    String              FieldName;
                    TPartnerClass       FieldPartnerClass;
                    PmStaffDataTable    PersonCommitmentTable;
                    PmStaffDataRow      PersonCommitmentRow;
                    TFormDataCommitment PersonCommitmentRecord;
                    PersonCommitmentTable = PmStaffDataAccess.LoadViaPPerson(APartnerKey, AReadTransaction);
                    PersonCommitmentTable.DefaultView.Sort = PmStaffDataTable.GetStartOfCommitmentDBName() + " DESC";

                    if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eCommitment))
                    {
                        foreach (DataRowView rv in PersonCommitmentTable.DefaultView)
                        {
                            PersonCommitmentRow    = (PmStaffDataRow)rv.Row;
                            PersonCommitmentRecord = new TFormDataCommitment();

                            PersonCommitmentRecord.StartDate = PersonCommitmentRow.StartOfCommitment;
                            PersonCommitmentRecord.EndDate   = PersonCommitmentRow.EndOfCommitment;
                            PersonCommitmentRecord.Status    = PersonCommitmentRow.StatusCode;

                            PersonCommitmentRecord.ReceivingFieldKey = PersonCommitmentRow.ReceivingField.ToString("0000000000");
                            TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.ReceivingField, out FieldName,
                                                                      out FieldPartnerClass);
                            PersonCommitmentRecord.ReceivingFieldName = FieldName;

                            PersonCommitmentRecord.SendingFieldKey = PersonCommitmentRow.HomeOffice.ToString("0000000000");
                            TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.HomeOffice, out FieldName,
                                                                      out FieldPartnerClass);
                            PersonCommitmentRecord.SendingFieldName = FieldName;

                            PersonCommitmentRecord.RecruitingFieldKey = PersonCommitmentRow.OfficeRecruitedBy.ToString("0000000000");
                            TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.OfficeRecruitedBy, out FieldName,
                                                                      out FieldPartnerClass);
                            PersonCommitmentRecord.RecruitingFieldName = FieldName;

                            PersonCommitmentRecord.Comment = PersonCommitmentRow.StaffDataComments;

                            AFormDataPerson.AddCommitment(PersonCommitmentRecord);
                        }
                    }

                    if (AFormLetterInfo.IsRetrievalRequested(TFormDataRetrievalSection.eFutureCommitment))
                    {
                        foreach (DataRowView rv in PersonCommitmentTable.DefaultView)
                        {
                            PersonCommitmentRow = (PmStaffDataRow)rv.Row;

                            if (PersonCommitmentRow.StartOfCommitment >= DateTime.Today)
                            {
                                TPartnerServerLookups.GetPartnerShortName(PersonCommitmentRow.ReceivingField, out FieldName,
                                                                          out FieldPartnerClass);
                                AFormDataPerson.FutureFieldName       = FieldName;
                                AFormDataPerson.FutureCommitStartDate = PersonCommitmentRow.StartOfCommitment;
                                AFormDataPerson.FutureCommitEndDate   = PersonCommitmentRow.EndOfCommitment;

                                // only use the first commitment (list is sorted by start date)
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Passes data as a Typed DataSet to the caller, containing a DataTable that corresponds with <paramref name="AIndivDataItem"></paramref>.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the Person to load data for.</param>
        /// <param name="AIndivDataItem">The Individual Data Item for which data should be returned.</param>
        /// <param name="AReadTransaction">Open Database transaction.</param>
        /// <returns>A Typed DataSet containing a DataTable that corresponds with <paramref name="AIndivDataItem"></paramref>.</returns>
        private static IndividualDataTDS GetData(Int64 APartnerKey, TIndividualDataItemEnum AIndivDataItem, TDBTransaction AReadTransaction)
        {
            IndividualDataTDS IndividualDataDS = new IndividualDataTDS("IndividualData");   // create the IndividualDataTDS DataSet that will later be passed to the Client
            IndividualDataTDSMiscellaneousDataTable MiscellaneousDataDT;
            IndividualDataTDSMiscellaneousDataRow   MiscellaneousDataDR;

            #region Create 'Miscellaneous' DataRow

            MiscellaneousDataDT            = IndividualDataDS.MiscellaneousData;
            MiscellaneousDataDR            = MiscellaneousDataDT.NewRowTyped(false);
            MiscellaneousDataDR.PartnerKey = APartnerKey;

            MiscellaneousDataDT.Rows.Add(MiscellaneousDataDR);

            #endregion

            switch (AIndivDataItem)
            {
            case TIndividualDataItemEnum.idiSummary:
                BuildSummaryData(APartnerKey, ref IndividualDataDS, AReadTransaction);

                DetermineItemCounts(MiscellaneousDataDR, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPersonalLanguages:
                PmPersonLanguageAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);

                PLanguageTable LanguageTable = (PLanguageTable)TSharedDataCache.TMCommon.GetCacheableCommonTable(
                    TCacheableCommonTablesEnum.LanguageCodeList);
                PLanguageRow LanguageRow;

                foreach (IndividualDataTDSPmPersonLanguageRow PersonLanguageRow in IndividualDataDS.PmPersonLanguage.Rows)
                {
                    LanguageRow = (PLanguageRow)LanguageTable.Rows.Find(new object[] { PersonLanguageRow.LanguageCode });

                    if (LanguageRow != null)
                    {
                        PersonLanguageRow.LanguageDescription = LanguageRow.LanguageDescription;
                    }
                }

                break;

            case TIndividualDataItemEnum.idiSpecialNeeds:
                PmSpecialNeedAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPreviousExperiences:
                PmPastExperienceAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);

                PUnitTable UnitTable;
                PUnitRow   UnitRow;

                // For outreaches the event code is currently stored in the location field. Try to retrieve the correct
                // outreach event and return it's actual name (as the event does not mean much to anybody).
                foreach (IndividualDataTDSPmPastExperienceRow PastExpRow in IndividualDataDS.PmPastExperience.Rows)
                {
                    PUnitRow template = new PUnitTable().NewRowTyped(false);

                    template.OutreachCode = PastExpRow.PrevLocation;

                    UnitTable = PUnitAccess.LoadUsingTemplate(template, AReadTransaction);

                    if (UnitTable.Rows.Count > 0)
                    {
                        UnitRow = (PUnitRow)UnitTable.Rows[0];
                        PastExpRow.EventName = UnitRow.UnitName;
                    }
                }

                break;

            case TIndividualDataItemEnum.idiPersonalDocuments:
                PmDocumentAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiJobAssignments:
                PmJobAssignmentAccess.LoadViaPPartner(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiLocalPersonnelData:
                // TODO: Fix this so LocalPersonnelData can actually load some data
                bool labelsAvailable;
                TOfficeSpecificDataLabelsUIConnector OfficeSpecificDataLabelsUIConnector;
                OfficeSpecificDataLabelsUIConnector = new TOfficeSpecificDataLabelsUIConnector(APartnerKey,
                                                                                               TOfficeSpecificDataLabelUseEnum.Personnel);
                IndividualDataDS.Merge(OfficeSpecificDataLabelsUIConnector.GetDataLocalPartnerDataValues(APartnerKey, out labelsAvailable, false,
                                                                                                         AReadTransaction));
                break;

            case TIndividualDataItemEnum.idiProgressReports:
                PmPersonEvaluationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiCommitmentPeriods:
                PmStaffDataAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPersonSkills:
                PmPersonSkillAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPersonalAbilities:
                PmPersonAbilityAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiPassportDetails:
                PmPassportDetailsAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);

                PCountryTable CountryTable = (PCountryTable)TSharedDataCache.TMCommon.GetCacheableCommonTable(
                    TCacheableCommonTablesEnum.CountryList);
                PCountryRow CountryRow;

                foreach (IndividualDataTDSPmPassportDetailsRow PassportRow in IndividualDataDS.PmPassportDetails.Rows)
                {
                    CountryRow = (PCountryRow)CountryTable.Rows.Find(new object[] { PassportRow.PassportNationalityCode });

                    if (CountryRow != null)
                    {
                        PassportRow.PassportNationalityName = CountryRow.CountryName;
                    }
                }

                break;

            case TIndividualDataItemEnum.idiPersonalData:
                PmPersonalDataAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiEmergencyData:
                PmPersonalDataAccess.LoadByPrimaryKey(IndividualDataDS, APartnerKey, AReadTransaction);
                break;

            case TIndividualDataItemEnum.idiApplications:
                PmGeneralApplicationAccess.LoadViaPPersonPartnerKey(IndividualDataDS, APartnerKey, AReadTransaction);
                PmShortTermApplicationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);
                PmYearProgramApplicationAccess.LoadViaPPerson(IndividualDataDS, APartnerKey, AReadTransaction);

                IndividualDataTDSPmGeneralApplicationRow GenAppRow;
                TPartnerClass         PartnerClass;
                TStdPartnerStatusCode PartnerStatus;
                String EventOrFieldName;

                //TODO: now go through all short and long term apps and set the
                // two fields in general app for EventOrFieldName and ApplicationForEventOrField
                foreach (PmShortTermApplicationRow ShortTermRow in IndividualDataDS.PmShortTermApplication.Rows)
                {
                    GenAppRow = (IndividualDataTDSPmGeneralApplicationRow)IndividualDataDS.PmGeneralApplication.Rows.Find
                                    (new object[] { ShortTermRow.PartnerKey,
                                                    ShortTermRow.ApplicationKey, ShortTermRow.RegistrationOffice });
                    GenAppRow.ApplicationForEventOrField = Catalog.GetString("Event");

                    if (!ShortTermRow.IsStConfirmedOptionNull())
                    {
                        Ict.Petra.Server.MCommon.MCommonMain.RetrievePartnerShortName
                            (ShortTermRow.StConfirmedOption, out EventOrFieldName, out PartnerClass, out PartnerStatus);
                        GenAppRow.EventOrFieldName = EventOrFieldName;
                    }
                }

                foreach (PmYearProgramApplicationRow LongTermRow in IndividualDataDS.PmYearProgramApplication.Rows)
                {
                    GenAppRow = (IndividualDataTDSPmGeneralApplicationRow)IndividualDataDS.PmGeneralApplication.Rows.Find
                                    (new object[] { LongTermRow.PartnerKey,
                                                    LongTermRow.ApplicationKey, LongTermRow.RegistrationOffice });
                    GenAppRow.ApplicationForEventOrField = Catalog.GetString("Field");

                    if (!GenAppRow.IsGenAppPossSrvUnitKeyNull())
                    {
                        Ict.Petra.Server.MCommon.MCommonMain.RetrievePartnerShortName
                            (GenAppRow.GenAppPossSrvUnitKey, out EventOrFieldName, out PartnerClass, out PartnerStatus);
                        GenAppRow.EventOrFieldName = EventOrFieldName;
                    }
                }

                break;

                // TODO: work on all cases/load data for all Individual Data items
            }

            return(IndividualDataDS);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Retrieves data that will be shown on the 'Overview' UserControl and adds it to <paramref name="AIndividualDataDS" />.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of the Person to load data for.</param>
        /// <param name="AIndividualDataDS">Typed DataSet of Type <see cref="IndividualDataTDS" />. Needs to be instantiated already!</param>
        /// <param name="AReadTransaction">Open Database transaction.</param>
        /// <returns>void</returns>
        private static void BuildSummaryData(Int64 APartnerKey, ref IndividualDataTDS AIndividualDataDS, TDBTransaction AReadTransaction)
        {
            string StrNotAvailable = Catalog.GetString("Not Available");
            IndividualDataTDSSummaryDataTable     SummaryDT;
            IndividualDataTDSSummaryDataRow       SummaryDR;
            IndividualDataTDSMiscellaneousDataRow MiscellaneousDataDR = AIndividualDataDS.MiscellaneousData[0];
            PPersonTable           PPersonDT;
            PPersonRow             PersonDR = null;
            PmPassportDetailsTable PassportDetailsDT;
            PmStaffDataTable       PmStaffDataDT;
            PmStaffDataRow         PmStaffDataDR     = null;
            PmJobAssignmentTable   PmJobAssignmentDT = null;
            PUnitTable             PUnitDT           = null;
            PmJobAssignmentRow     PmJobAssignmentDR;
            IndividualDataTDSJobAssignmentStaffDataCombinedRow JobAssiStaffDataCombDR;
            int                       JobAssiStaffDataCombKey = 0;
            TCacheable                CommonCacheable         = new TCacheable();
            TPartnerCacheable         PartnerCacheable        = new TPartnerCacheable();
            string                    MaritalStatusDescr;
            StringCollection          PassportColumns;
            string                    Nationalities;
            PPartnerRelationshipTable PartnerRelationshipDT;
            PPartnerTable             PartnerDT;
            PPartnerRow               PartnerDR = null;
            PLocationRow              LocationDR;
            PPartnerLocationRow       PartnerLocationDR;
            string                    PhoneNumber;
            string                    EmailAddress;
            Int64                     ChurchPartnerKey;

            SummaryDT = new IndividualDataTDSSummaryDataTable();
            SummaryDR = SummaryDT.NewRowTyped(false);

            SummaryDR.PartnerKey = APartnerKey;

            #region Person Info

            PPersonDT = PPersonAccess.LoadByPrimaryKey(APartnerKey, AReadTransaction);

            if (PPersonDT.Rows.Count == 1)
            {
                PersonDR = (PPersonRow)PPersonDT.Rows[0];
            }

            if (PersonDR != null)
            {
                SummaryDR.DateOfBirth = PersonDR.DateOfBirth;
                SummaryDR.Gender      = PersonDR.Gender;

                MaritalStatusDescr = PartnerCodeHelper.GetMaritalStatusDescription(
                    @PartnerCacheable.GetCacheableTable, PersonDR.MaritalStatus);

                if (MaritalStatusDescr != String.Empty)
                {
                    MaritalStatusDescr = " - " + MaritalStatusDescr;
                }

                SummaryDR.MaritalStatus = PersonDR.MaritalStatus + MaritalStatusDescr;
            }
            else
            {
                SummaryDR.SetDateOfBirthNull();
                SummaryDR.Gender        = StrNotAvailable;
                SummaryDR.MaritalStatus = StrNotAvailable;
            }

            #region Nationalities

            PassportColumns = StringHelper.StrSplit(
                PmPassportDetailsTable.GetDateOfIssueDBName() + "," +
                PmPassportDetailsTable.GetDateOfExpirationDBName() + "," +
                PmPassportDetailsTable.GetPassportNationalityCodeDBName() + "," +
                PmPassportDetailsTable.GetMainPassportDBName(), ",");

            PassportDetailsDT = PmPassportDetailsAccess.LoadViaPPerson(APartnerKey,
                                                                       PassportColumns, AReadTransaction, null, 0, 0);

            Nationalities = Ict.Petra.Shared.MPersonnel.Calculations.DeterminePersonsNationalities(
                @CommonCacheable.GetCacheableTable, PassportDetailsDT);

            if (Nationalities != String.Empty)
            {
                SummaryDR.Nationalities = Nationalities;
            }
            else
            {
                SummaryDR.Nationalities = StrNotAvailable;
            }

            #endregion

            #region Phone and Email (from 'Best Address')

            if (TContactDetailsAggregate.GetPrimaryEmailAndPrimaryPhone(APartnerKey, out PhoneNumber, out EmailAddress))
            {
                SummaryDR.PrimaryPhoneNumber  = PhoneNumber ?? StrNotAvailable;
                SummaryDR.PrimaryEmailAddress = EmailAddress ?? StrNotAvailable;
            }
            else
            {
                SummaryDR.PrimaryPhoneNumber  = StrNotAvailable;
                SummaryDR.PrimaryEmailAddress = StrNotAvailable;
            }

            #endregion

            #endregion

            #region Commitments/Jobs

            PmStaffDataDT = PmStaffDataAccess.LoadViaPPerson(APartnerKey, AReadTransaction);
            MiscellaneousDataDR.ItemsCountCommitmentPeriods = PmStaffDataDT.Rows.Count;

            // First check if the PERSON has got any Commitments
            if (PmStaffDataDT.Rows.Count > 0)
            {
                foreach (DataRow DR in PmStaffDataDT.Rows)
                {
                    JobAssiStaffDataCombDR            = AIndividualDataDS.JobAssignmentStaffDataCombined.NewRowTyped(false);
                    JobAssiStaffDataCombDR.Key        = JobAssiStaffDataCombKey++;
                    JobAssiStaffDataCombDR.PartnerKey = APartnerKey;

                    PmStaffDataDR = (PmStaffDataRow)DR;

                    if (!(PmStaffDataDR.IsReceivingFieldNull()) &&
                        (PmStaffDataDR.ReceivingField != 0))
                    {
                        PUnitDT = PUnitAccess.LoadByPrimaryKey(PmStaffDataDR.ReceivingField, AReadTransaction);

                        JobAssiStaffDataCombDR.FieldKey  = PmStaffDataDR.ReceivingField;
                        JobAssiStaffDataCombDR.FieldName = PUnitDT[0].UnitName;
                    }
                    else
                    {
                        JobAssiStaffDataCombDR.FieldKey  = 0;
                        JobAssiStaffDataCombDR.FieldName = "[None]";
                    }

                    JobAssiStaffDataCombDR.Position = PmStaffDataDR.JobTitle;
                    JobAssiStaffDataCombDR.FromDate = PmStaffDataDR.StartOfCommitment;
                    JobAssiStaffDataCombDR.ToDate   = PmStaffDataDR.EndOfCommitment;

                    AIndividualDataDS.JobAssignmentStaffDataCombined.Rows.Add(JobAssiStaffDataCombDR);
                }
            }
            else
            {
                // The PERSON hasn't got any Commitments, therefore check if the PERSON has any Job Assignments

                PmJobAssignmentDT = PmJobAssignmentAccess.LoadViaPPartner(APartnerKey, AReadTransaction);

                if (PmJobAssignmentDT.Rows.Count > 0)
                {
                    foreach (DataRow DR in PmJobAssignmentDT.Rows)
                    {
                        JobAssiStaffDataCombDR            = AIndividualDataDS.JobAssignmentStaffDataCombined.NewRowTyped(false);
                        JobAssiStaffDataCombDR.Key        = JobAssiStaffDataCombKey++;
                        JobAssiStaffDataCombDR.PartnerKey = APartnerKey;

                        PmJobAssignmentDR = (PmJobAssignmentRow)DR;

                        if (PmJobAssignmentDR.UnitKey != 0)
                        {
                            PUnitDT = PUnitAccess.LoadByPrimaryKey(PmJobAssignmentDR.UnitKey, AReadTransaction);

                            JobAssiStaffDataCombDR.FieldKey  = PmJobAssignmentDR.UnitKey;
                            JobAssiStaffDataCombDR.FieldName = PUnitDT[0].UnitName;
                        }
                        else
                        {
                            JobAssiStaffDataCombDR.FieldKey  = 0;
                            JobAssiStaffDataCombDR.FieldName = "[None]";
                        }

                        JobAssiStaffDataCombDR.Position = PmJobAssignmentDR.PositionName;
                        JobAssiStaffDataCombDR.FromDate = PmJobAssignmentDR.FromDate;
                        JobAssiStaffDataCombDR.ToDate   = PmJobAssignmentDR.ToDate;

                        AIndividualDataDS.JobAssignmentStaffDataCombined.Rows.Add(JobAssiStaffDataCombDR);
                    }
                }
            }

            #endregion

            #region Church Info

            SummaryDR.ChurchName                           = StrNotAvailable;
            SummaryDR.ChurchAddress                        = StrNotAvailable;
            SummaryDR.ChurchPrimaryPhoneNumber             = StrNotAvailable;
            SummaryDR.ChurchPastor                         = StrNotAvailable;
            SummaryDR.ChurchPastorsPrimaryPhoneNumber      = StrNotAvailable;
            SummaryDR.NumberOfShownSupportingChurchPastors = 0;

            // Find SUPPCHURCH Relationship
            PartnerRelationshipDT = PPartnerRelationshipAccess.LoadUsingTemplate(new TSearchCriteria[] {
                new TSearchCriteria(PPartnerRelationshipTable.GetRelationKeyDBName(), APartnerKey),
                new TSearchCriteria(PPartnerRelationshipTable.GetRelationNameDBName(), "SUPPCHURCH")
            },
                                                                                 AReadTransaction);

            SummaryDR.NumberOfShownSupportingChurches = PartnerRelationshipDT.Rows.Count;

            if (PartnerRelationshipDT.Rows.Count > 0)
            {
                ChurchPartnerKey = PartnerRelationshipDT[0].PartnerKey;

                // Load Church Partner
                PartnerDT = PPartnerAccess.LoadByPrimaryKey(ChurchPartnerKey, AReadTransaction);

                if (PartnerDT.Rows.Count > 0)
                {
                    PartnerDR = PartnerDT[0];

                    // Church Name
                    if (PartnerDR.PartnerShortName != String.Empty)
                    {
                        SummaryDR.ChurchName = PartnerDR.PartnerShortName;
                    }

                    #region Church Address and Phone

                    ServerCalculations.DetermineBestAddress(PartnerRelationshipDT[0].PartnerKey, out PartnerLocationDR, out LocationDR);

                    if (LocationDR != null)
                    {
                        SummaryDR.ChurchAddress = Calculations.DetermineLocationString(LocationDR,
                                                                                       Calculations.TPartnerLocationFormatEnum.plfCommaSeparated);
                    }

                    if (TContactDetailsAggregate.GetPrimaryPhoneNumber(PartnerRelationshipDT[0].PartnerKey,
                                                                       out PhoneNumber))
                    {
                        SummaryDR.ChurchPrimaryPhoneNumber = PhoneNumber ?? StrNotAvailable;
                    }
                    else
                    {
                        SummaryDR.ChurchPrimaryPhoneNumber = StrNotAvailable;
                    }

                    #endregion

                    #region Pastor

                    // Find PASTOR Relationship
                    PartnerRelationshipDT.Rows.Clear();
                    PartnerRelationshipDT = PPartnerRelationshipAccess.LoadUsingTemplate(new TSearchCriteria[] {
                        new TSearchCriteria(PPartnerRelationshipTable.GetPartnerKeyDBName(), ChurchPartnerKey),
                        new TSearchCriteria(PPartnerRelationshipTable.GetRelationNameDBName(), "PASTOR")
                    },
                                                                                         AReadTransaction);

                    SummaryDR.NumberOfShownSupportingChurchPastors = PartnerRelationshipDT.Rows.Count;

                    if (PartnerRelationshipDT.Rows.Count > 0)
                    {
                        // Load PASTOR Partner
                        PartnerDT = PPartnerAccess.LoadByPrimaryKey(PartnerRelationshipDT[0].RelationKey, AReadTransaction);

                        if (PartnerDT.Rows.Count > 0)
                        {
                            PartnerDR = PartnerDT[0];

                            // Pastor's Name
                            if (PartnerDR.PartnerShortName != String.Empty)
                            {
                                SummaryDR.ChurchPastor = PartnerDR.PartnerShortName;
                            }

                            #region Pastor's Phone

                            if (TContactDetailsAggregate.GetPrimaryPhoneNumber(PartnerRelationshipDT[0].RelationKey,
                                                                               out PhoneNumber))
                            {
                                SummaryDR.ChurchPastorsPrimaryPhoneNumber = PhoneNumber ?? StrNotAvailable;
                            }
                            else
                            {
                                SummaryDR.ChurchPastorsPrimaryPhoneNumber = StrNotAvailable;
                            }

                            #endregion
                        }
                    }

                    #endregion
                }
            }

            #endregion

            // Add Summary DataRow to Summary DataTable
            SummaryDT.Rows.Add(SummaryDR);

            // Add Row to 'SummaryData' DataTable in Typed DataSet 'IndividualDataTDS'
            AIndividualDataDS.Merge(SummaryDT);
        }