Exemplo n.º 1
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.º 2
0
        public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey, bool AWithAddressDetails, bool AWithSubscriptions, bool AWithRelationships)
        {
            PartnerEditTDS MainDS = new PartnerEditTDS();

            TDBTransaction Transaction = null;

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

                    if (MainDS.PPartner.Rows.Count > 0)
                    {
                        switch (MainDS.PPartner[0].PartnerClass)
                        {
                            case MPartnerConstants.PARTNERCLASS_FAMILY:
                                PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                                break;

                            case MPartnerConstants.PARTNERCLASS_PERSON:
                                PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                                break;

                            case MPartnerConstants.PARTNERCLASS_CHURCH:
                                PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                                break;

                            case MPartnerConstants.PARTNERCLASS_ORGANISATION:
                                POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                                break;
                        }

                        if (AWithAddressDetails)
                        {
                            PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                            PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        }

                        if (AWithRelationships)
                        {
                            PPartnerRelationshipAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
                        }

                        if (AWithSubscriptions)
                        {
                            PSubscriptionAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
                        }
                    }
                });

            return MainDS;
        }
Exemplo n.º 3
0
        public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey, bool AWithAddressDetails, bool AWithSubscriptions, bool AWithRelationships)
        {
            PartnerEditTDS MainDS = new PartnerEditTDS();

            TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable);

            PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);

            if (MainDS.PPartner.Rows.Count == 0)
            {
                return(null);
            }

            switch (MainDS.PPartner[0].PartnerClass)
            {
            case MPartnerConstants.PARTNERCLASS_FAMILY:
                PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                break;

            case MPartnerConstants.PARTNERCLASS_PERSON:
                PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                break;

            case MPartnerConstants.PARTNERCLASS_CHURCH:
                PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                break;

            case MPartnerConstants.PARTNERCLASS_ORGANISATION:
                POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                break;
            }

            if (AWithAddressDetails)
            {
                PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
            }

            if (AWithRelationships)
            {
                PPartnerRelationshipAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
            }

            if (AWithSubscriptions)
            {
                PSubscriptionAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
            }

            DBAccess.GDBAccessObj.RollbackTransaction();

            return(MainDS);
        }
Exemplo n.º 4
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.º 5
0
        public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey,
                                                       out List <string> ASubscriptions,
                                                       out List <string> APartnerTypes,
                                                       out string ADefaultEmailAddress,
                                                       out string ADefaultPhoneMobile,
                                                       out string ADefaultPhoneLandline)
        {
            PartnerEditTDS MainDS               = new PartnerEditTDS();
            List <string>  Subscriptions        = new List <string>();
            List <string>  PartnerTypes         = new List <string>();
            string         DefaultEmailAddress  = String.Empty;
            string         DefaultPhoneMobile   = String.Empty;
            string         DefaultPhoneLandline = String.Empty;

            TDBTransaction Transaction = null;

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

                if (MainDS.PPartner.Rows.Count > 0)
                {
                    switch (MainDS.PPartner[0].PartnerClass)
                    {
                    case MPartnerConstants.PARTNERCLASS_FAMILY:
                        PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_PERSON:
                        PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_CHURCH:
                        PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_ORGANISATION:
                        POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_BANK:
                        PBankAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_UNIT:
                        PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;
                    }

                    if (true)
                    {
                        PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PPartnerRelationshipAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PPublicationAccess.LoadAll(MainDS, Transaction);
                        PSubscriptionAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);

                        foreach (PSubscriptionRow subscription in MainDS.PSubscription.Rows)
                        {
                            Subscriptions.Add(subscription.PublicationCode);
                        }
                    }

                    PPartnerStatusAccess.LoadAll(MainDS, Transaction);
                    PTypeAccess.LoadAll(MainDS, Transaction);
                    PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerTypeRow partnertype in MainDS.PPartnerType.Rows)
                    {
                        PartnerTypes.Add(partnertype.TypeCode);
                    }

                    PPartnerAttributeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerAttributeRow partnerattr in MainDS.PPartnerAttribute.Rows)
                    {
                        if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_EMAIL)
                        {
                            DefaultEmailAddress = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_PHONE)
                        {
                            DefaultPhoneLandline = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_MOBILE_PHONE)
                        {
                            DefaultPhoneMobile = partnerattr.Value;
                        }
                    }
                }
            });

            APartnerTypes         = PartnerTypes;
            ASubscriptions        = Subscriptions;
            ADefaultEmailAddress  = DefaultEmailAddress;
            ADefaultPhoneMobile   = DefaultPhoneMobile;
            ADefaultPhoneLandline = DefaultPhoneLandline;

            return(MainDS);
        }
Exemplo n.º 6
0
        public static String BuildAddressBlock(String AAddressLayoutBlock,
                                               TFormDataPartner AFormData,
                                               TPartnerClass APartnerClass,
                                               TDBTransaction ATransaction)
        {
            String AddressBlock = "";

            List <String> AddressTokenList     = new List <String>();
            String        AddressLineText      = "";
            String        AddressLineTokenText = "";
            Boolean       PrintAnyway          = false;
            Boolean       CapsOn           = false;
            Boolean       UseContact       = false;
            String        SpacePlaceholder = "";

            PPersonTable PersonTable;
            PPersonRow   PersonRow = null;
            PFamilyTable FamilyTable;
            PFamilyRow   FamilyRow         = null;
            Int64        ContactPartnerKey = 0;

            AddressTokenList = BuildTokenListFromAddressLayoutBlock(AAddressLayoutBlock);

            // initialize values
            AddressLineText = "";
            PrintAnyway     = false;

            foreach (String AddressLineToken in AddressTokenList)
            {
                switch (AddressLineToken)
                {
                case "[[TitleAndSpace]]":
                case "[[FirstNameAndSpace]]":
                case "[[FirstInitialAndSpace]]":
                case "[[LastNameAndSpace]]":

                    SpacePlaceholder = " ";
                    break;

                default:

                    SpacePlaceholder = "";
                    break;
                }

                switch (AddressLineToken)
                {
                case "[[AcademicTitle]]":

                    if (UseContact)
                    {
                        if (PersonRow != null)
                        {
                            AddressLineText += ConvertIfUpperCase(PersonRow.AcademicTitle, CapsOn);
                        }
                    }
                    else
                    {
                        if (AFormData.GetType() == typeof(TFormDataPerson))
                        {
                            AddressLineText += ConvertIfUpperCase(((TFormDataPerson)AFormData).AcademicTitle, CapsOn);
                        }
                    }

                    break;

                case "[[AddresseeType]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.AddresseeType, CapsOn);
                    break;

                case "[[Address3]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.Address3, CapsOn);
                    break;

                case "[[CapsOn]]":
                    CapsOn = true;
                    break;

                case "[[CapsOff]]":
                    CapsOn = false;
                    break;

                case "[[City]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.City, CapsOn);
                    break;

                case "[[CountryName]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.CountryName, CapsOn);
                    break;

                case "[[CountryInLocalLanguage]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.CountryInLocalLanguage, CapsOn);
                    break;

                case "[[County]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.County, CapsOn);
                    break;

                case "[[UseContact]]":

                    /* Get the person or family record that is acting as the contact
                     *  only applicable to churches and organisations. */
                    switch (APartnerClass)
                    {
                    case TPartnerClass.CHURCH:
                        PChurchTable ChurchTable;
                        PChurchRow   ChurchRow;
                        ChurchTable = PChurchAccess.LoadByPrimaryKey(Convert.ToInt64(AFormData.PartnerKey), ATransaction);

                        if (ChurchTable.Count > 0)
                        {
                            ChurchRow = (PChurchRow)ChurchTable.Rows[0];

                            if (!ChurchRow.IsContactPartnerKeyNull())
                            {
                                ContactPartnerKey = ChurchRow.ContactPartnerKey;
                            }
                        }

                        break;

                    case TPartnerClass.ORGANISATION:
                        POrganisationTable OrganisationTable;
                        POrganisationRow   OrganisationRow;
                        OrganisationTable = POrganisationAccess.LoadByPrimaryKey(Convert.ToInt64(AFormData.PartnerKey), ATransaction);

                        if (OrganisationTable.Count > 0)
                        {
                            OrganisationRow = (POrganisationRow)OrganisationTable.Rows[0];

                            if (!OrganisationRow.IsContactPartnerKeyNull())
                            {
                                ContactPartnerKey = OrganisationRow.ContactPartnerKey;
                            }
                        }

                        break;

                    default:
                        ContactPartnerKey = 0;
                        break;
                    }

                    if (ContactPartnerKey > 0)
                    {
                        PersonTable = PPersonAccess.LoadByPrimaryKey(ContactPartnerKey, ATransaction);

                        if (PersonTable.Count > 0)
                        {
                            PersonRow = (PPersonRow)PersonTable.Rows[0];
                        }
                        else
                        {
                            FamilyTable = PFamilyAccess.LoadByPrimaryKey(ContactPartnerKey, ATransaction);

                            if (FamilyTable.Count > 0)
                            {
                                FamilyRow = (PFamilyRow)FamilyTable.Rows[0];
                            }
                        }
                    }

                    UseContact = true;
                    break;

                case "[[CountryCode]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.CountryCode, CapsOn);
                    break;

                case "[[Decorations]]":

                    if (UseContact)
                    {
                        if (PersonRow != null)
                        {
                            AddressLineText += ConvertIfUpperCase(PersonRow.Decorations, CapsOn);
                        }
                    }
                    else
                    {
                        if (AFormData.GetType() == typeof(TFormDataPerson))
                        {
                            AddressLineText += ConvertIfUpperCase(((TFormDataPerson)AFormData).Decorations, CapsOn);
                        }
                    }

                    break;

                case "[[FirstName]]":
                case "[[FirstNameAndSpace]]":

                    AddressLineTokenText = "";

                    if (UseContact)
                    {
                        if (PersonRow != null)
                        {
                            AddressLineTokenText = ConvertIfUpperCase(PersonRow.FirstName, CapsOn);
                        }
                        else if (FamilyRow != null)
                        {
                            AddressLineTokenText = ConvertIfUpperCase(FamilyRow.FirstName, CapsOn);
                        }
                    }
                    else
                    {
                        AddressLineTokenText = ConvertIfUpperCase(AFormData.FirstName, CapsOn);
                    }

                    if ((AddressLineTokenText != null) &&
                        (AddressLineTokenText.Length > 0))
                    {
                        AddressLineText += AddressLineTokenText + SpacePlaceholder;
                    }

                    break;

                case "[[FirstInitial]]":
                case "[[FirstInitialAndSpace]]":

                    AddressLineTokenText = "";

                    if (UseContact)
                    {
                        if (PersonRow != null)
                        {
                            if (PersonRow.FirstName.Length > 0)
                            {
                                AddressLineTokenText = ConvertIfUpperCase(PersonRow.FirstName.Substring(0, 1), CapsOn);
                            }
                        }
                        else if (FamilyRow != null)
                        {
                            if (PersonRow.FirstName.Length > 0)
                            {
                                AddressLineTokenText = ConvertIfUpperCase(FamilyRow.FirstName.Substring(0, 1), CapsOn);
                            }
                        }
                    }
                    else
                    {
                        if (AFormData.FirstName.Length > 0)
                        {
                            AddressLineTokenText = ConvertIfUpperCase(AFormData.FirstName.Substring(0, 1), CapsOn);
                        }
                    }

                    if ((AddressLineTokenText != null) &&
                        (AddressLineTokenText.Length > 0))
                    {
                        AddressLineText += AddressLineTokenText + SpacePlaceholder;
                    }

                    break;

                case "[[LastName]]":
                case "[[LastNameAndSpace]]":

                    AddressLineTokenText = "";

                    if (UseContact)
                    {
                        if (PersonRow != null)
                        {
                            AddressLineTokenText = ConvertIfUpperCase(PersonRow.FamilyName, CapsOn);
                        }
                        else if (FamilyRow != null)
                        {
                            AddressLineTokenText = ConvertIfUpperCase(FamilyRow.FamilyName, CapsOn);
                        }
                    }
                    else
                    {
                        AddressLineTokenText = ConvertIfUpperCase(AFormData.LastName, CapsOn);
                    }

                    if ((AddressLineTokenText != null) &&
                        (AddressLineTokenText.Length > 0))
                    {
                        AddressLineText += AddressLineTokenText + SpacePlaceholder;
                    }

                    break;

                case "[[Address1]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.Address1, CapsOn);
                    break;

                case "[[MiddleName]]":

                    if (UseContact)
                    {
                        if (PersonRow != null)
                        {
                            AddressLineText += ConvertIfUpperCase(PersonRow.MiddleName1, CapsOn);
                        }
                    }
                    else
                    {
                        if (AFormData.GetType() == typeof(TFormDataPerson))
                        {
                            AddressLineText += ConvertIfUpperCase(((TFormDataPerson)AFormData).MiddleName, CapsOn);
                        }
                    }

                    break;

                case "[[Org/Church]]":

                    /* if the contact person is being printed then might still want the
                     *  Organisation or Church name printed.  This does it but only if there
                     *  is a valid contact. */
                    if (UseContact)
                    {
                        AddressLineText += ConvertIfUpperCase(AFormData.ShortName, CapsOn);
                    }

                    break;

                case "[[PartnerKey]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.PartnerKey, CapsOn);
                    break;

                case "[[ShortName]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.ShortName, CapsOn);
                    break;

                case "[[LocalName]]":

                    if (AFormData.LocalName != "")
                    {
                        AddressLineText += ConvertIfUpperCase(AFormData.LocalName, CapsOn);
                    }
                    else
                    {
                        AddressLineText += ConvertIfUpperCase(AFormData.ShortName, CapsOn);
                    }

                    break;

                case "[[PostalCode]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.PostalCode, CapsOn);
                    break;

                case "[[Enclosures]]":
                    AddressLineText += AFormData.Enclosures;
                    break;

                case "[[MailingCode]]":
                    AddressLineText += AFormData.MailingCode;
                    break;

                case "[[Tab]]":
                    AddressLineText += "\t";
                    break;

                case "[[Space]]":
                    AddressLineText += " ";
                    break;

                case "[[AddressStreet2]]":
                    AddressLineText += ConvertIfUpperCase(AFormData.AddressStreet2, CapsOn);
                    break;

                case "[[Title]]":
                case "[[TitleAndSpace]]":
                    AddressLineTokenText = ConvertIfUpperCase(AFormData.Title, CapsOn);

                    if ((AddressLineTokenText != null) &&
                        (AddressLineTokenText.Length > 0))
                    {
                        AddressLineText += AddressLineTokenText + SpacePlaceholder;
                    }

                    break;

                case "[[NoSuppress]]":
                    PrintAnyway = true;
                    break;

                case "[[LocationKey]]":
                    AddressLineText += AFormData.LocationKey;
                    break;

                case "[[LineFeed]]":

                    // only add line if not empty and not suppressed
                    if (PrintAnyway ||
                        (!PrintAnyway &&
                         (AddressLineText.Trim() != "")))
                    {
                        AddressBlock += AddressLineText + "\r\n";
                    }

                    // reset values
                    AddressLineText = "";
                    PrintAnyway     = false;
                    break;

                default:
                    AddressLineText += ConvertIfUpperCase(AddressLineToken, CapsOn);
                    break;
                }
            }

            // this is only for last line if there was no line feed:
            // only add line if not empty and not suppressed
            if (PrintAnyway ||
                (!PrintAnyway &&
                 (AddressLineText.Trim() != "")))
            {
                AddressBlock += AddressLineText + "\r\n";
            }

            // or just get the element list from cached table (since we need to get different ones depending on country)

            return(AddressBlock);
        }
Exemplo n.º 7
0
        public static PartnerEditTDS GetPartnerDetails(Int64 APartnerKey,
                                                       out List <string> ASubscriptions,
                                                       out List <string> APartnerTypes,
                                                       out string ADefaultEmailAddress,
                                                       out string ADefaultPhoneMobile,
                                                       out string ADefaultPhoneLandline)
        {
            PartnerEditTDS MainDS               = new PartnerEditTDS();
            List <string>  Subscriptions        = new List <string>();
            List <string>  PartnerTypes         = new List <string>();
            string         DefaultEmailAddress  = String.Empty;
            string         DefaultPhoneMobile   = String.Empty;
            string         DefaultPhoneLandline = String.Empty;

            TDBTransaction Transaction = new TDBTransaction();

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

                if (MainDS.PPartner.Rows.Count > 0)
                {
                    switch (MainDS.PPartner[0].PartnerClass)
                    {
                    case MPartnerConstants.PARTNERCLASS_FAMILY:
                        PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_PERSON:
                        PPersonAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_CHURCH:
                        PChurchAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_ORGANISATION:
                        POrganisationAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_BANK:
                        PBankAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;

                    case MPartnerConstants.PARTNERCLASS_UNIT:
                        PUnitAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                        break;
                    }

                    if (true)
                    {
                        PPartnerLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PLocationAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PPartnerRelationshipAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);
                    }

                    if (true)
                    {
                        PCountryAccess.LoadAll(MainDS, Transaction);
                    }

                    if (true)
                    {
                        PPublicationAccess.LoadAll(MainDS, Transaction);
                        PSubscriptionAccess.LoadViaPPartnerPartnerKey(MainDS, APartnerKey, Transaction);

                        foreach (PSubscriptionRow subscription in MainDS.PSubscription.Rows)
                        {
                            Subscriptions.Add(subscription.PublicationCode);
                        }
                    }

                    if (true)
                    {
                        PBankingDetailsAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PPartnerBankingDetailsAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                        PBankingDetailsUsageAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                        foreach (PartnerEditTDSPBankingDetailsRow banking in MainDS.PBankingDetails.Rows)
                        {
                            PBankAccess.LoadByPrimaryKey(MainDS, banking.BankKey, Transaction);
                            banking.Bic        = MainDS.PBank[0].Bic;
                            banking.BranchName = MainDS.PBank[0].BranchName;
                            banking.Iban       = FormatIBAN(banking.Iban);
                            MainDS.PBank.Rows.Clear();
                        }

                        foreach (PartnerEditTDSPBankingDetailsRow bd in MainDS.PBankingDetails.Rows)
                        {
                            bd.MainAccount =
                                (MainDS.PBankingDetailsUsage.Rows.Find(
                                     new object[] { APartnerKey, bd.BankingDetailsKey, MPartnerConstants.BANKINGUSAGETYPE_MAIN }) != null);
                        }

                        MainDS.PBankingDetailsUsage.Rows.Clear();
                    }

                    PPartnerStatusAccess.LoadAll(MainDS, Transaction);
                    PTypeRow templateRow   = MainDS.PType.NewRowTyped();
                    templateRow.SystemType = false;
                    templateRow.SetTypeDeletableNull();
                    templateRow.SetDateCreatedNull();
                    PTypeAccess.LoadUsingTemplate(MainDS, templateRow, Transaction);
                    PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerTypeRow partnertype in MainDS.PPartnerType.Rows)
                    {
                        PartnerTypes.Add(partnertype.TypeCode);
                    }

                    PPartnerAttributeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                    foreach (PPartnerAttributeRow partnerattr in MainDS.PPartnerAttribute.Rows)
                    {
                        if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_EMAIL)
                        {
                            DefaultEmailAddress = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_PHONE)
                        {
                            DefaultPhoneLandline = partnerattr.Value;
                        }
                        else if (partnerattr.AttributeType == MPartnerConstants.ATTR_TYPE_MOBILE_PHONE)
                        {
                            DefaultPhoneMobile = partnerattr.Value;
                        }
                    }
                }
            });

            APartnerTypes         = PartnerTypes;
            ASubscriptions        = Subscriptions;
            ADefaultEmailAddress  = DefaultEmailAddress;
            ADefaultPhoneMobile   = DefaultPhoneMobile;
            ADefaultPhoneLandline = DefaultPhoneLandline;

            return(MainDS);
        }