/// <summary>
        /// Called when data got saved in the screen. This Method takes over changed data
        /// into FMainDS, which is different than the Partner Edit screen's FMainDS, in
        /// order to have current data on which decisions on whether to refresh certain
        /// parts of the 'Overview' need to be updated.
        /// </summary>
        /// <param name="APartnerAttributesOrRelationsChanged">NOT USED IN THIS CONTEXT!  (Set to true by the SaveChanges Method
        /// of the Partner Edit screen if PartnerAttributes or Relationships have changed.)</param>
        public void RefreshPersonnelDataAfterMerge(bool APartnerAttributesOrRelationsChanged)
        {
            //
            // Need to merge Tables from PartnerEditTDS into IndividualDataTDS so the updated s_modification_id_t of modififed Rows is held correctly in IndividualDataTDS, too!
            //

            // ...but first empty relevant DataTables to ensure that DataRows that got deleted in FPartnerEditTDS are reflected in FMainDS (just performing a Merge wouldn't remove them!)
            if (FMainDS.Tables.Contains(PPartnerLocationTable.GetTableName()))
            {
                FMainDS.Tables[PPartnerLocationTable.GetTableName()].Rows.Clear();
            }

            if (FMainDS.Tables.Contains(PLocationTable.GetTableName()))
            {
                FMainDS.Tables[PLocationTable.GetTableName()].Rows.Clear();
            }

            if (FMainDS.Tables.Contains(PPartnerRelationshipTable.GetTableName()))
            {
                FMainDS.Tables[PPartnerRelationshipTable.GetTableName()].Rows.Clear();
            }

            // Now perform the Merge operation
            FMainDS.Merge(FPartnerEditTDS);

            // Call AcceptChanges on IndividualDataTDS so that we don't have any changed data anymore (this is done to PartnerEditTDS, too, after this Method returns)!
            FMainDS.AcceptChanges();
        }
Пример #2
0
        /// <summary>
        /// Retrieves all of the PartnerInfo data.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of Partner to find the PartnerInfo data for</param>
        /// <param name="APartnerInfoDS">Typed DataSet that contains the requested data.</param>
        /// <param name="AReadTransaction" >Open DB Transaction.</param>
        /// <returns>True if Partner exists, otherwise false.</returns>
        public static bool AllPartnerInfoData(Int64 APartnerKey, ref PartnerInfoTDS APartnerInfoDS,
                                              TDBTransaction AReadTransaction)
        {
            bool        ReturnValue = false;
            PPartnerRow PartnerDR;

            TLocationPK           BestLocationPK;
            PLocationRow          LocationDR;
            PLocationRow          LocationDR2;
            PPartnerLocationRow   PartnerLocationDR;
            PPartnerLocationRow   PartnerLocationDR2;
            PLocationTable        LocationDT;
            PPartnerLocationTable PartnerLocationDT;

            try
            {
                /*
                 * Check for existance of Partner
                 */
                PartnerDR = MCommonMain.CheckPartnerExists2(APartnerKey, true, AReadTransaction.DataBaseObj);

                if (PartnerDR != null)
                {
                    /*
                     * Perform security checks; these throw ESecurityPartnerAccessDeniedException
                     * in case access isn't granted.
                     */
                    TSecurity.CanAccessPartnerExc(PartnerDR, AReadTransaction.DataBaseObj);

                    /*
                     * Get the Partner's Address data of its 'Best' Address
                     */
                    if (TMailing.GetPartnersBestLocationData(APartnerKey, out BestLocationPK,
                                                             out LocationDR, out PartnerLocationDR, AReadTransaction.DataBaseObj))
                    {
                        #region Process Address

                        /*
                         * Check for existance of PLocation and PPartnerLocation Tables in the passed in
                         * DataSet APartnerInfoDS.
                         */
                        if (!APartnerInfoDS.Tables.Contains(PLocationTable.GetTableName()))
                        {
                            // Need to create Table here
                            APartnerInfoDS.Tables.Add(new PLocationTable());
                        }

                        if (!APartnerInfoDS.Tables.Contains(PPartnerLocationTable.GetTableName()))
                        {
                            // Need to create Table here
                            APartnerInfoDS.Tables.Add(new PPartnerLocationTable());
                        }

                        // Add copies of the Location and PartnerLocation DataRows of the 'Best Address'

                        /*
                         * Remove DataColumns that might have been added by the call to
                         * TMailing.GetPartnersBestLocationData - otherwise PartnerLocationDR2.ItemArray
                         * assignment will fail.
                         */
                        if (PartnerLocationDR.Table.Columns.Contains(Calculations.PARTNERLOCATION_BESTADDR_COLUMN))
                        {
                            PartnerLocationDR.Table.Columns.Remove(Calculations.PARTNERLOCATION_BESTADDR_COLUMN);
                        }

                        if (PartnerLocationDR.Table.Columns.Contains(Calculations.PARTNERLOCATION_ICON_COLUMN))
                        {
                            PartnerLocationDR.Table.Columns.Remove(Calculations.PARTNERLOCATION_ICON_COLUMN);
                        }

                        LocationDR2                  = APartnerInfoDS.PLocation.NewRowTyped(false);
                        LocationDR2.ItemArray        = LocationDR.ItemArray;
                        PartnerLocationDR2           = APartnerInfoDS.PPartnerLocation.NewRowTyped(false);
                        PartnerLocationDR2.ItemArray = PartnerLocationDR.ItemArray;

                        APartnerInfoDS.PLocation.Rows.Add(LocationDR2);
                        APartnerInfoDS.PPartnerLocation.Rows.Add(PartnerLocationDR2);

                        #endregion

                        // Apply Address Security
                        LocationDT        = APartnerInfoDS.PLocation;
                        PartnerLocationDT = APartnerInfoDS.PPartnerLocation;

                        TPPartnerAddressAggregate.ApplySecurity(ref PartnerLocationDT,
                                                                ref LocationDT);

                        // Process 'Head' data and rest of data for the Partner
                        HeadInternal(PartnerDR, ref APartnerInfoDS);
                        RestInternal(PartnerDR, ref APartnerInfoDS, AReadTransaction);

                        ReturnValue = true;
                    }
                }
            }
            catch (ESecurityPartnerAccessDeniedException)
            {
                // don't log this exception - this is thrown on purpose here and the Client needs to deal with it.
                throw;
            }
            catch (Exception Exp)
            {
                TLogging.Log("TServerLookups_PartnerInfo.AllPartnerInfoData exception: " + Exp.ToString(), TLoggingType.ToLogfile);
                TLogging.Log(Exp.StackTrace, TLoggingType.ToLogfile);

                throw;
            }

            return(ReturnValue);
        }
Пример #3
0
        /// <summary>
        /// Determines the 'Best Address' of the PERSON and its Phone Number and Email Address.
        /// </summary>
        /// <param name="APhoneNumberOfPerson">Phone Number of the PERSON in international format.</param>
        /// <param name="AEmailAddressOfPerson">Email Address of the PERSON.</param>
        /// <returns><see cref="Ict.Petra.Shared.MPartner.TLocationPK" /> pointing to the 'Best Address' of the PERSON.</returns>
        private TLocationPK DetermineAddressComponents(out string APhoneNumberOfPerson, out string AEmailAddressOfPerson)
        {
            TLocationPK ReturnValue = Ict.Petra.Shared.MPartner.Calculations.DetermineBestAddress(
                FMainDS.Tables[PartnerEditTDSPPartnerLocationTable.GetTableName()]);
            DataRow BestPartnerLocationDR;
            DataRow BestLocationDR;
            string  TelephoneNumber;
            string  Extension;
            string  CountryCode;

            // Initialise out Arguments
            APhoneNumberOfPerson  = null;
            AEmailAddressOfPerson = null;

            BestPartnerLocationDR = FMainDS.Tables[PartnerEditTDSPPartnerLocationTable.GetTableName()].Rows.Find(new object[]
                                                                                                                 { FMainDS.PPerson[0].PartnerKey, ReturnValue.SiteKey, ReturnValue.LocationKey });

            if (BestPartnerLocationDR != null)
            {
                BestLocationDR = FMainDS.Tables[PLocationTable.GetTableName()].Rows.Find(new object[]
                                                                                         { ReturnValue.SiteKey, ReturnValue.LocationKey });

                if (!BestPartnerLocationDR.IsNull(PPartnerLocationTable.GetTelephoneNumberDBName()))
                {
                    TelephoneNumber = (string)BestPartnerLocationDR[PPartnerLocationTable.GetTelephoneNumberDBName()];
                }
                else
                {
                    TelephoneNumber = String.Empty;
                }

                if (!BestPartnerLocationDR.IsNull(PPartnerLocationTable.GetExtensionDBName()))
                {
                    Extension = ((int)BestPartnerLocationDR[PPartnerLocationTable.GetExtensionDBName()]).ToString();
                }
                else
                {
                    Extension = String.Empty;
                }

                if (!BestLocationDR.IsNull(PLocationTable.GetCountryCodeDBName()))
                {
                    CountryCode = (string)BestLocationDR[PLocationTable.GetCountryCodeDBName()];
                }
                else
                {
                    CountryCode = String.Empty;
                }

                APhoneNumberOfPerson = Ict.Petra.Shared.MPartner.Calculations.FormatIntlPhoneNumber(
                    TelephoneNumber,
                    Extension,
                    CountryCode,
                    @TDataCache.GetCacheableDataTableFromCache);

                if (!BestPartnerLocationDR.IsNull(PPartnerLocationTable.GetEmailAddressDBName()))
                {
                    AEmailAddressOfPerson = (string)BestPartnerLocationDR[PPartnerLocationTable.GetEmailAddressDBName()];
                }
                else
                {
                    AEmailAddressOfPerson = String.Empty;
                }
            }
            else
            {
                MessageBox.Show("Unexpected condition: 'Best Address of PERSON is null'", DEV_FIX);
            }

            return(ReturnValue);
        }