Пример #1
0
        /// <summary>
        /// Passes data as a Typed DataSet to the Partner Edit Screen, containing multiple
        /// DataTables. The DataSets tables are with default data for a new Partner.
        ///
        /// </summary>
        /// <param name="ASiteKey">SiteKey for which the Partner should be created (optional)</param>
        /// <param name="APartnerKey">PartnerKey that the Partner should have (optional)</param>
        /// <param name="APartnerClass">PartnerClass that the Partner should have (optional)</param>
        /// <param name="ADesiredCountryCode">Country Code that the Partner's first address should have
        /// (if &lt;&gt; '', this overrides the Country Code that would be found out from the
        /// Site Key)</param>
        /// <param name="AAcquisitionCode">AcquisitionCode that the Partner should have (optional)</param>
        /// <param name="APrivatePartner">Set to true if this should become a Private Partner
        /// of the current user</param>
        /// <param name="AFamilyPartnerKey">PartnerKey of the Family (only needed if new Partner is of
        /// Partner Class PERSON)</param>
        /// <param name="AFamilySiteKey"></param>
        /// <param name="AFamilyLocationKey">LocationKey of the selected Location of the Family
        /// (only needed if new Partner is of Partner Class PERSON)
        /// </param>
        /// <param name="ASiteCountryCode"></param>
        /// <returns>void</returns>
        public PartnerEditTDS GetDataNewPartner(System.Int64 ASiteKey,
            System.Int64 APartnerKey,
            TPartnerClass APartnerClass,
            String ADesiredCountryCode,
            String AAcquisitionCode,
            Boolean APrivatePartner,
            Int64 AFamilyPartnerKey,
            Int64 AFamilySiteKey,
            Int32 AFamilyLocationKey,
            out String ASiteCountryCode)
        {
            TDBTransaction ReadTransaction;
            PPartnerRow PartnerRow;
            PartnerEditTDSPPersonRow PersonRow;
            PartnerEditTDSPFamilyRow FamilyRow;
            PChurchRow ChurchRow;
            POrganisationRow OrganisationRow;
            PBankRow BankRow;
            PUnitRow UnitRow;
            PVenueRow VenueRow;
            PPartnerRelationshipRow PartnerRelationshipRow;
            PartnerEditTDSMiscellaneousDataTable MiscellaneousDataDT;
            PartnerEditTDSMiscellaneousDataRow MiscellaneousDataDR;
            PPartnerTable PersonFamilyPartnerDT;
            PLocationTable SiteLocationDT;
            StringCollection SiteLocationRequiredColumns;
            DateTime CreationDate;

            String CreationUserID;
            String GiftReceiptingDefaults;
            String ReceiptLetterFrequency;
            String LanguageCode;

            String[] GiftReceiptingDefaultsSplit;
            Boolean ReceiptEachGift;
            TPartnerFamilyIDHandling FamilyIDHandling;
            int FamilyID;
            String ProblemMessage;
            Int32 ItemsCountAddresses = 0;
            Int32 ItemsCountAddressesActive = 0;
            Int32 ItemsCountSubscriptions = 0;
            Int32 ItemsCountSubscriptionsActive = 0;
            Int32 ItemsCountPartnerTypes = 0;
            Int32 ItemsCountPartnerRelationships = 0;
            Int32 ItemsCountFamilyMembers = 0;
            Int32 ItemsCountInterests = 0;
            Int32 ItemsCountContacts = 0;
            DateTime LastContactDate = DateTime.Now;
            Int64 FoundationOwner1Key = 0;
            Int64 FoundationOwner2Key = 0;
            bool HasEXWORKERPartnerType = false;
            PFamilyTable PersonFamilyDT;
            TOfficeSpecificDataLabelsUIConnector OfficeSpecificDataLabelsUIConnector;
            Boolean OfficeSpecificDataLabelsAvailable;

            ASiteCountryCode = "";
            FNewPartnerPartnerKey = APartnerKey;
            FNewPartnerPartnerClass = APartnerClass;
            CreationDate = DateTime.Today;
            CreationUserID = UserInfo.GUserInfo.UserID;

            // create the FPartnerEditScreenDS DataSet that will later be passed to the Client
            FPartnerEditScreenDS = new PartnerEditTDS(DATASETNAME);
            FPartnerKey = FNewPartnerPartnerKey;
            FPartnerClass = FNewPartnerPartnerClass;

            ReadTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.RepeatableRead);

            try
            {
                /*
                 * Create DataRow for PPartner
                 */
                #region Calculations

                // Determine Gift Processing settings
                GiftReceiptingDefaults = TSystemDefaultsCache.GSystemDefaultsCache.GetStringDefault(
                    TSystemDefaultsCache.PARTNER_GIFTRECEIPTINGDEFAULTS);

                if (GiftReceiptingDefaults != "")
                {
                    GiftReceiptingDefaultsSplit = GiftReceiptingDefaults.Split(',');
                    ReceiptLetterFrequency = GiftReceiptingDefaultsSplit[0];

                    if (GiftReceiptingDefaultsSplit[1] == "no")
                    {
                        ReceiptEachGift = false;
                    }
                    else
                    {
                        ReceiptEachGift = true;
                    }
                }
                else
                {
                    ReceiptLetterFrequency = "Annual";
                    ReceiptEachGift = false;
                }

                // Determine LanguageCode
                if (FPartnerClass != TPartnerClass.PERSON)
                {
                    LanguageCode = TUserDefaults.GetStringDefault(MSysManConstants.PARTNER_LANGUAGE, "99");
                }
                else
                {
                    PersonFamilyPartnerDT = PPartnerAccess.LoadByPrimaryKey(AFamilyPartnerKey, ReadTransaction);

                    if (PersonFamilyPartnerDT[0].LanguageCode == "99")
                    {
                        LanguageCode = TUserDefaults.GetStringDefault(MSysManConstants.PARTNER_LANGUAGE, "99");
                    }
                    else
                    {
                        LanguageCode = PersonFamilyPartnerDT[0].LanguageCode;
                    }
                }

                #endregion

                // We get the default values for all DataColumns
                // and then modify some.
                PartnerRow = FPartnerEditScreenDS.PPartner.NewRowTyped(true);
                PartnerRow.PartnerKey = FPartnerKey;
                PartnerRow.DateCreated = CreationDate;
                PartnerRow.CreatedBy = CreationUserID;
                PartnerRow.PartnerClass = SharedTypes.PartnerClassEnumToString(APartnerClass);
                PartnerRow.AcquisitionCode = AAcquisitionCode;

                // logical DataColumns must be initialised for DataBinding to work
                PartnerRow.NoSolicitations = false;
                PartnerRow.DeletedPartner = false;
                PartnerRow.ChildIndicator = false;
                PartnerRow.ReceiptLetterFrequency = ReceiptLetterFrequency;
                PartnerRow.ReceiptEachGift = ReceiptEachGift;
                PartnerRow.LanguageCode = LanguageCode;

                if (!APrivatePartner)
                {
                    PartnerRow.StatusCode = SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscACTIVE);
                }
                else
                {
                    PartnerRow.StatusCode = SharedTypes.StdPartnerStatusCodeEnumToString(TStdPartnerStatusCode.spscPRIVATE);
                    PartnerRow.Restricted = SharedConstants.PARTNER_PRIVATE_USER;
                    PartnerRow.UserId = CreationUserID;
                }

                PartnerRow.StatusChange = CreationDate;
                #region Partner Types
                TLogging.LogAtLevel(7, "TPartnerEditUIConnector.GetDataNewPartner: before PartnerClass switch");

                switch (APartnerClass)
                {
                    case TPartnerClass.PERSON:
                        // Load p_family record of the FAMILY that the PERSON will belong to
                        PersonFamilyDT = PFamilyAccess.LoadByPrimaryKey(AFamilyPartnerKey, ReadTransaction);

                        // Create DataRow for PPerson using the default values for all DataColumns
                        TLogging.LogAtLevel(7, "TPartnerEditUIConnector.GetDataNewPartner: before adding Person DataRow");

                        PersonRow = FPartnerEditScreenDS.PPerson.NewRowTyped(true);
                        PersonRow.PartnerKey = FPartnerKey;
                        PersonRow.DateCreated = CreationDate;
                        PersonRow.CreatedBy = CreationUserID;
                        PersonRow.FamilyKey = AFamilyPartnerKey;
                        PersonRow.FamilyName = PersonFamilyDT[0].FamilyName;
                        FamilyIDHandling = new TPartnerFamilyIDHandling();

                        if (FamilyIDHandling.GetNewFamilyID(AFamilyPartnerKey, out FamilyID, out ProblemMessage) == TFamilyIDSuccessEnum.fiError)
                        {
                            // this should not really happen  but we cannot continue if it does
                            throw new EPartnerFamilyIDException(ProblemMessage);
                        }

                        PersonRow.FamilyId = FamilyID;
                        PersonRow.OccupationCode = MPartnerConstants.DEFAULT_CODE_UNKNOWN;
                        FPartnerEditScreenDS.PPerson.Rows.Add(PersonRow);
                        GetFamilyMembersInternal(AFamilyPartnerKey, "", out ItemsCountFamilyMembers, true);

                        /*
                         * Remove other Partner Class Tables.
                         * This is needed for correct working of the creation of new Partners on the Client side (the ShowData Method of the 'Top Part'
                         * relies on null DataTables when determining which data of which DataTables to put into which Controls).
                         */
                        FPartnerEditScreenDS.Tables.Remove(PFamilyTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(POrganisationTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PChurchTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PBankTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PUnitTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PVenueTable.GetTableName());

                        break;

                    case TPartnerClass.FAMILY:
                        TLogging.LogAtLevel(7, "TPartnerEditUIConnector.GetDataNewPartner: before adding Family DataRow");

                        // Create DataRow for PFamily using the default values for all DataColumns
                        FamilyRow = FPartnerEditScreenDS.PFamily.NewRowTyped(true);
                        FamilyRow.PartnerKey = FPartnerKey;
                        FamilyRow.DateCreated = CreationDate;
                        FamilyRow.CreatedBy = CreationUserID;
                        FPartnerEditScreenDS.PFamily.Rows.Add(FamilyRow);

                        /*
                         * Remove other Partner Class Tables.
                         * This is needed for correct working of the creation of new Partners on the Client side (the ShowData Method of the 'Top Part'
                         * relies on null DataTables when determining which data of which DataTables to put into which Controls).
                         */
                        FPartnerEditScreenDS.Tables.Remove(PPersonTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(POrganisationTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PChurchTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PBankTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PUnitTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PVenueTable.GetTableName());

                        break;

                    case TPartnerClass.CHURCH:
                        // Create DataRow for PChurch using the default values for all DataColumns
                        ChurchRow = FPartnerEditScreenDS.PChurch.NewRowTyped(true);
                        ChurchRow.PartnerKey = FPartnerKey;
                        ChurchRow.DateCreated = CreationDate;
                        ChurchRow.CreatedBy = CreationUserID;

                        // logical DataColumns must be initialised for DataBinding to work
                        ChurchRow.Accomodation = false;
                        ChurchRow.PrayerGroup = false;
                        ChurchRow.MapOnFile = false;
                        FPartnerEditScreenDS.PChurch.Rows.Add(ChurchRow);

                        /*
                         * Remove other Partner Class Tables.
                         * This is needed for correct working of the creation of new Partners on the Client side (the ShowData Method of the 'Top Part'
                         * relies on null DataTables when determining which data of which DataTables to put into which Controls).
                         */
                        FPartnerEditScreenDS.Tables.Remove(PPersonTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PFamilyTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(POrganisationTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PBankTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PUnitTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PVenueTable.GetTableName());

                        break;

                    case TPartnerClass.ORGANISATION:
                        // Create DataRow for POrganisation using the default values for all DataColumns
                        OrganisationRow = FPartnerEditScreenDS.POrganisation.NewRowTyped(true);
                        OrganisationRow.PartnerKey = FPartnerKey;
                        OrganisationRow.DateCreated = CreationDate;
                        OrganisationRow.CreatedBy = CreationUserID;

                        // logical DataColumns must be initialised for DataBinding to work
                        OrganisationRow.Religious = false;
                        OrganisationRow.Foundation = false;
                        FPartnerEditScreenDS.POrganisation.Rows.Add(OrganisationRow);

                        /*
                         * Remove other Partner Class Tables.
                         * This is needed for correct working of the creation of new Partners on the Client side (the ShowData Method of the 'Top Part'
                         * relies on null DataTables when determining which data of which DataTables to put into which Controls).
                         */
                        FPartnerEditScreenDS.Tables.Remove(PPersonTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PFamilyTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PChurchTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PBankTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PUnitTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PVenueTable.GetTableName());

                        break;

                    case TPartnerClass.BANK:
                        // Create DataRow for PBank using the default values for all DataColumns
                        BankRow = FPartnerEditScreenDS.PBank.NewRowTyped(true);
                        BankRow.PartnerKey = FPartnerKey;
                        BankRow.DateCreated = CreationDate;
                        BankRow.CreatedBy = CreationUserID;
                        FPartnerEditScreenDS.PBank.Rows.Add(BankRow);

                        /*
                         * Remove other Partner Class Tables.
                         * This is needed for correct working of the creation of new Partners on the Client side (the ShowData Method of the 'Top Part'
                         * relies on null DataTables when determining which data of which DataTables to put into which Controls).
                         */
                        FPartnerEditScreenDS.Tables.Remove(PPersonTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PFamilyTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(POrganisationTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PChurchTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PUnitTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PVenueTable.GetTableName());

                        break;

                    case TPartnerClass.UNIT:
                        // Create DataRow for PUnit using the default values for all DataColumns
                        UnitRow = FPartnerEditScreenDS.PUnit.NewRowTyped(true);
                        UnitRow.PartnerKey = FPartnerKey;
                        UnitRow.DateCreated = CreationDate;
                        UnitRow.CreatedBy = CreationUserID;
                        FPartnerEditScreenDS.PUnit.Rows.Add(UnitRow);

                        /*
                         * Remove other Partner Class Tables.
                         * This is needed for correct working of the creation of new Partners on the Client side (the ShowData Method of the 'Top Part'
                         * relies on null DataTables when determining which data of which DataTables to put into which Controls).
                         */
                        FPartnerEditScreenDS.Tables.Remove(PPersonTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PFamilyTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PChurchTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PBankTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(POrganisationTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PVenueTable.GetTableName());

                        break;

                    case TPartnerClass.VENUE:
                        // Create DataRow for PVenue using the default values for all DataColumns
                        VenueRow = FPartnerEditScreenDS.PVenue.NewRowTyped(true);
                        VenueRow.PartnerKey = FPartnerKey;
                        VenueRow.DateCreated = CreationDate;
                        VenueRow.CreatedBy = CreationUserID;

                        // Makeup a VenueCode for now, as there is now way to let the user spec one quickly...
                        VenueRow.VenueCode = 'V' + FPartnerKey.ToString().Substring(1);
                        FPartnerEditScreenDS.PVenue.Rows.Add(VenueRow);

                        /*
                         * Remove other Partner Class Tables.
                         * This is needed for correct working of the creation of new Partners on the Client side (the ShowData Method of the 'Top Part'
                         * relies on null DataTables when determining which data of which DataTables to put into which Controls).
                         */
                        FPartnerEditScreenDS.Tables.Remove(PPersonTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PFamilyTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PChurchTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PBankTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(POrganisationTable.GetTableName());
                        FPartnerEditScreenDS.Tables.Remove(PUnitTable.GetTableName());

                        break;
                }

                PartnerRow.AddresseeTypeCode = TSharedAddressHandling.GetDefaultAddresseeType(APartnerClass);
                TLogging.LogAtLevel(7, "TPartnerEditUIConnector.GetDataNewPartner: before adding new Partner DataRow");

                // Add DataRow for PPartner
                FPartnerEditScreenDS.PPartner.Rows.Add(PartnerRow);

                if (APartnerClass == TPartnerClass.PERSON)
                {
                    /*
                     * Copy specified Family Address into the PLocation and PPartnerLocation
                     * table (is needed on the Client side to copy this address as the default
                     * address of the new Person and gets deleted there as soon as copying is
                     * done)
                     */
//                  TLogging.LogAtLevel(7, "Getting Family Address - AFamilyPartnerKey: " + AFamilyPartnerKey.ToString() + "; AFamilyLocationKey: " + AFamilyLocationKey.ToString());
                    TPPartnerAddressAggregate.LoadByPrimaryKey(FPartnerEditScreenDS,
                        AFamilyPartnerKey,
                        AFamilySiteKey,
                        AFamilyLocationKey,
                        ReadTransaction);

                    // Copy Special Types from the PERSON'S FAMILY to the PERSON
                    TLogging.LogAtLevel(7, "TPartnerEditUIConnector.GetDataNewPartner: before loading Special Types from FAMILY");

                    GetPartnerTypesForNewPartnerFromFamily(AFamilyPartnerKey, ReadTransaction);

                    /*
                     * Create Relationship between Family and Person
                     */
                    PartnerRelationshipRow = FPartnerEditScreenDS.PPartnerRelationship.NewRowTyped(true);
                    PartnerRelationshipRow.PartnerKey = AFamilyPartnerKey;
                    PartnerRelationshipRow.RelationKey = FPartnerKey;
                    PartnerRelationshipRow.RelationName = "FAMILY";
                    PartnerRelationshipRow.Comment = SharedConstants.ROW_IS_SYSTEM_GENERATED;
                    PartnerRelationshipRow.DateCreated = CreationDate;
                    PartnerRelationshipRow.CreatedBy = CreationUserID;
                    FPartnerEditScreenDS.PPartnerRelationship.Rows.Add(PartnerRelationshipRow);
                }

                #endregion

                // Note: Location and PartnerLocation for a new Partner are set up on the Client side!
                // Determine CountryCode for first Address of the Partner, if it is not overwritten
                if (ADesiredCountryCode == "")
                {
                    // TODO 1 oChristianK cPartner Edit / New Partner : Use a proper function to determine the 'Best' Address of the Unit...
                    SiteLocationRequiredColumns = new StringCollection();
                    SiteLocationRequiredColumns.Add(PLocationTable.GetLocationKeyDBName());
                    SiteLocationRequiredColumns.Add(PLocationTable.GetCountryCodeDBName());
                    SiteLocationDT = PLocationAccess.LoadViaPPartner(ASiteKey, SiteLocationRequiredColumns, ReadTransaction, null, 0, 0);

                    // For the moment just take the CountryCode that we find in the (random) first record...
                    ASiteCountryCode = SiteLocationDT[0].CountryCode;
                }

                /*
                 * Office Specific Data
                 */
                OfficeSpecificDataLabelsUIConnector = new TOfficeSpecificDataLabelsUIConnector(FPartnerKey,
                    MCommonTypes.PartnerClassEnumToOfficeSpecificDataLabelUseEnum(FPartnerClass));
                OfficeSpecificDataLabelsAvailable =
                    (OfficeSpecificDataLabelsUIConnector.CountLabelUse(SharedTypes.PartnerClassEnumToString(FPartnerClass), ReadTransaction) != 0);


                MiscellaneousDataDT = FPartnerEditScreenDS.MiscellaneousData;
                MiscellaneousDataDR = MiscellaneousDataDT.NewRowTyped(false);
                MiscellaneousDataDR.PartnerKey = FPartnerKey;

                if (AFamilyLocationKey != 0)
                {
                    MiscellaneousDataDR.SelectedSiteKey = AFamilySiteKey;
                    MiscellaneousDataDR.SelectedLocationKey = AFamilyLocationKey;
                }
                else
                {
                    MiscellaneousDataDR.SelectedSiteKey = -1;
                    MiscellaneousDataDR.SelectedLocationKey = -1;
                }

                MiscellaneousDataDR.SetLastGiftDateNull();
                MiscellaneousDataDR.LastGiftInfo = "";
                MiscellaneousDataDR.ItemsCountAddresses = ItemsCountAddresses;
                MiscellaneousDataDR.ItemsCountAddressesActive = ItemsCountAddressesActive;
                MiscellaneousDataDR.ItemsCountSubscriptions = ItemsCountSubscriptions;
                MiscellaneousDataDR.ItemsCountSubscriptionsActive = ItemsCountSubscriptionsActive;
                MiscellaneousDataDR.ItemsCountPartnerTypes = ItemsCountPartnerTypes;
                MiscellaneousDataDR.ItemsCountPartnerRelationships = ItemsCountPartnerRelationships;
                MiscellaneousDataDR.ItemsCountFamilyMembers = ItemsCountFamilyMembers;
                MiscellaneousDataDR.ItemsCountInterests = ItemsCountInterests;
                MiscellaneousDataDR.OfficeSpecificDataLabelsAvailable = OfficeSpecificDataLabelsAvailable;
                MiscellaneousDataDR.FoundationOwner1Key = FoundationOwner1Key;
                MiscellaneousDataDR.FoundationOwner2Key = FoundationOwner2Key;
                MiscellaneousDataDR.HasEXWORKERPartnerType = HasEXWORKERPartnerType;
                MiscellaneousDataDR.ItemsCountContacts = ItemsCountContacts;
                MiscellaneousDataDR.LastContactDate = LastContactDate;
                MiscellaneousDataDT.Rows.Add(MiscellaneousDataDR);
                MiscellaneousDataDT.AcceptChanges();
            }
            catch (Exception Exp)
            {
                TLogging.Log("Exception occured in GetDataNewPartner: " + Exp.ToString());
            }
            DBAccess.GDBAccessObj.CommitTransaction();

            // Remove all Tables that were not filled with data before remoting them
            // This will be the DataTables that exist for a certain Partner Class,
            // eg. Person  only one of those Tables will be filled, the other ones are
            // not needed at the Client side.
            // FPartnerEditScreenDS.RemoveEmptyTables;
            // For the moment we only remove the following table so that the Partner
            // Edit screen can discover the value of MiscellaneousDataDR.ItemsCountFamilyMembers
            FPartnerEditScreenDS.Tables.Remove(PartnerEditTDSFamilyMembersTable.GetTableName());

            return FPartnerEditScreenDS;
        }
Пример #2
0
        private PDataLabelValuePartnerTable GetDataLocalPartnerDataValuesInternal(out Boolean ALabelsAvailable, Boolean ACountOnly)
        {
            TDBTransaction ReadTransaction;
            Boolean NewTransaction = false;
            TOfficeSpecificDataLabelsUIConnector OfficeSpecificDataLabelsUIConnector;
            PDataLabelValuePartnerTable DataLabelValuePartnerDT;
            OfficeSpecificDataLabelsTDS OfficeSpecificDataLabels;

            ALabelsAvailable = false;

            DataLabelValuePartnerDT = new PDataLabelValuePartnerTable();

            try
            {
                ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                    TEnforceIsolationLevel.eilMinimum,
                    out NewTransaction);


                OfficeSpecificDataLabelsUIConnector = new TOfficeSpecificDataLabelsUIConnector(FPartnerKey,
                    MCommonTypes.PartnerClassEnumToOfficeSpecificDataLabelUseEnum(FPartnerClass));
                OfficeSpecificDataLabels = OfficeSpecificDataLabelsUIConnector.GetData();
                ALabelsAvailable =
                    (OfficeSpecificDataLabelsUIConnector.CountLabelUse(SharedTypes.PartnerClassEnumToString(FPartnerClass), ReadTransaction) != 0);

                if (!ACountOnly)
                {
                    DataLabelValuePartnerDT.Merge(OfficeSpecificDataLabels.PDataLabelValuePartner);
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TPartnerEditUIConnector.GetDataLocalPartnerDataValuesInternal: committed own transaction.");
                }
            }

            return DataLabelValuePartnerDT;
        }
        private DataTable GetDataLabelsForPartnerClassesListTable(TDBTransaction AReadTransaction, string ATableName)
        {
            const string PARTNERCLASSCOL = "PartnerClass";
            const string DLAVAILCOL = "DataLabelsAvailable";

            DataTable TmpTable;
            DataRow NewDR;
            TOfficeSpecificDataLabelsUIConnector OfficeSpecificDataLabelsUIConnector;

            // Create our custom Cacheable DataTable on-the-fly
            TmpTable = new DataTable(ATableName);
            DataColumn PKColumn = new DataColumn(PARTNERCLASSCOL, System.Type.GetType("System.String"));
            TmpTable.Columns.Add(PKColumn);
            TmpTable.Columns.Add(new DataColumn(DLAVAILCOL, System.Type.GetType("System.Boolean")));
            TmpTable.PrimaryKey = new DataColumn[] {
                PKColumn
            };

            /*
             * Create an Instance of TOfficeSpecificDataLabelsUIConnector - PartnerKey and DataLabelUse are not important here
             * because we only call Method 'CountLabelUse', which doesn't rely on any of them.
             */
            OfficeSpecificDataLabelsUIConnector = new TOfficeSpecificDataLabelsUIConnector(0,
                TOfficeSpecificDataLabelUseEnum.Family);

            // DataLabels available for PERSONs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.PERSON);
            NewDR[DLAVAILCOL] =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for FAMILYs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.FAMILY);
            NewDR[DLAVAILCOL] =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for CHURCHes?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.CHURCH);
            NewDR[DLAVAILCOL] =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for ORGANISATIONs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.ORGANISATION);
            NewDR[DLAVAILCOL] =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for UNITs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.UNIT);
            NewDR[DLAVAILCOL] =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for BANKs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.BANK);
            NewDR[DLAVAILCOL] =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            // DataLabels available for VENUEs?
            NewDR = TmpTable.NewRow();
            NewDR[PARTNERCLASSCOL] = SharedTypes.PartnerClassEnumToString(TPartnerClass.VENUE);
            NewDR[DLAVAILCOL] =
                (OfficeSpecificDataLabelsUIConnector.CountLabelUse(NewDR[PARTNERCLASSCOL].ToString(), AReadTransaction) != 0);
            TmpTable.Rows.Add(NewDR);

            return TmpTable;
        }