private void OnRecipientKeyChanged(Int64 APartnerKey,
                                           String APartnerShortName,
                                           bool AValidSelection,
                                           out bool ADoValidateRecurringGiftDestination)
        {
            ADoValidateRecurringGiftDestination = false;

            if (FRecipientKeyChangedInProcess ||
                FPetraUtilsObject.SuppressChangeDetection ||
                FShowDetailsInProcess)
            {
                return;
            }

            // get the recipient ledger number
            Int64 RecipientLedgerNumber = 0;

            if (APartnerKey > 0)
            {
                RecipientLedgerNumber = TRemote.MFinance.Gift.WebConnectors.GetRecipientFundNumber(APartnerKey,
                                                                                                   DateTime.Now);
            }

            FRecipientKeyChangedInProcess = true;

            try
            {
                FPreviouslySelectedDetailRow.BeginEdit();
                txtDetailRecipientKeyMinistry.Text                = string.Empty;
                FPreviouslySelectedDetailRow.RecipientKey         = APartnerKey;
                FPreviouslySelectedDetailRow.RecipientDescription = APartnerShortName;
                FPreviouslySelectedDetailRow.RecipientClass       = txtDetailRecipientKey.CurrentPartnerClass.ToString();

                FPetraUtilsObject.SuppressChangeDetection = true;

                //Set RecipientLedgerNumber
                FPreviouslySelectedDetailRow.RecipientLedgerNumber = RecipientLedgerNumber;

                if (!FKeyMinistryChangedInProcess)
                {
                    GetRecipientData(APartnerKey, FMotivationDetailHasChangedFlag);
                    ADoValidateRecurringGiftDestination = true;
                }

                FPetraUtilsObject.SuppressChangeDetection = false;

                // do not want to update motivation comboboxes if recipient key is being changed due to a new Recurring Gift or the motivation detail being changed
                if (!FMotivationDetailHasChangedFlag && !FNewGiftInProcess &&
                    TRemote.MFinance.Gift.WebConnectors.GetMotivationGroupAndDetailForPartner(APartnerKey, ref FMotivationGroup,
                                                                                              ref FMotivationDetail))
                {
                    if (cmbDetailMotivationGroupCode.GetSelectedString() != FMotivationGroup)
                    {
                        // note - this will also update the Motivation Detail
                        cmbDetailMotivationGroupCode.SetSelectedString(FMotivationGroup, -1);
                    }

                    if (cmbMotivationDetailCode.GetSelectedString() != FMotivationDetail)
                    {
                        cmbMotivationDetailCode.SetSelectedString(FMotivationDetail, -1);
                    }

                    FPreviouslySelectedDetailRow.MotivationGroupCode  = FMotivationGroup;
                    FPreviouslySelectedDetailRow.MotivationDetailCode = FMotivationDetail;
                }

                FPetraUtilsObject.SuppressChangeDetection = true;

                if (APartnerKey > 0)
                {
                    ApplyRecipientCostCentreCode();
                }
                else
                {
                    UpdateRecipientKeyText(APartnerKey, FPreviouslySelectedDetailRow, FMotivationGroup, FMotivationDetail);

                    DisplayMotivationDetailCostCentreCode();
                }
            }
            finally
            {
                FRecipientKeyChangedInProcess = false;
                ReconcileKeyMinistryFromCombo(FPreviouslySelectedDetailRow);
                FPreviouslySelectedDetailRow.EndEdit();
                FPetraUtilsObject.SuppressChangeDetection = false;
            }
        }
        /// <summary>
        /// Update the transaction base amount calculation
        /// </summary>
        /// <param name="AUpdateCurrentRowOnly"></param>
        public void UpdateBaseAmount(Boolean AUpdateCurrentRowOnly)
        {
            Int32 LedgerNumber;
            Int32 CurrentBatchNumber;

            DateTime BatchEffectiveDate;

            decimal BatchExchangeRateToBase    = 0;
            string  BatchCurrencyCode          = string.Empty;
            decimal IntlToBaseCurrencyExchRate = 0;
            bool    IsTransactionInIntlCurrency;

            string LedgerBaseCurrency = string.Empty;
            string LedgerIntlCurrency = string.Empty;

            bool TransactionsFromCurrentBatch = false;

            AGiftBatchRow CurrentBatchRow = GetBatchRow();

            if (FShowDetailsInProcess ||
                !(((TFrmGiftBatch)this.ParentForm).GetBatchControl().FBatchLoaded) ||
                (CurrentBatchRow == null) ||
                (CurrentBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED))
            {
                return;
            }

            BatchCurrencyCode       = CurrentBatchRow.CurrencyCode;
            BatchExchangeRateToBase = CurrentBatchRow.ExchangeRateToBase;

            if ((FBatchRow != null) &&
                (CurrentBatchRow.LedgerNumber == FBatchRow.LedgerNumber) &&
                (CurrentBatchRow.BatchNumber == FBatchRow.BatchNumber))
            {
                TransactionsFromCurrentBatch = true;
                FBatchCurrencyCode           = BatchCurrencyCode;
                FBatchExchangeRateToBase     = BatchExchangeRateToBase;
            }

            LedgerNumber       = CurrentBatchRow.LedgerNumber;
            CurrentBatchNumber = CurrentBatchRow.BatchNumber;

            BatchEffectiveDate = CurrentBatchRow.GlEffectiveDate;
            LedgerBaseCurrency = FMainDS.ALedger[0].BaseCurrency;
            LedgerIntlCurrency = FMainDS.ALedger[0].IntlCurrency;

            IntlToBaseCurrencyExchRate = ((TFrmGiftBatch)ParentForm).InternationalCurrencyExchangeRate(CurrentBatchRow,
                                                                                                       out IsTransactionInIntlCurrency);

            if (!LoadGiftDataForBatch(LedgerNumber, CurrentBatchNumber))
            {
                //No transactions exist to process or corporate exchange rate not found
                return;
            }

            //If only updating the currency active row
            if (AUpdateCurrentRowOnly && (FPreviouslySelectedDetailRow != null))
            {
                try
                {
                    FPreviouslySelectedDetailRow.BeginEdit();

                    FPreviouslySelectedDetailRow.GiftAmount = GLRoutines.Divide((decimal)txtDetailGiftTransactionAmount.NumberValueDecimal,
                                                                                BatchExchangeRateToBase);

                    if (!IsTransactionInIntlCurrency)
                    {
                        FPreviouslySelectedDetailRow.GiftAmountIntl = (IntlToBaseCurrencyExchRate == 0) ? 0 : GLRoutines.Divide(
                            FPreviouslySelectedDetailRow.GiftAmount,
                            IntlToBaseCurrencyExchRate);
                    }
                    else
                    {
                        FPreviouslySelectedDetailRow.GiftAmountIntl = FPreviouslySelectedDetailRow.GiftTransactionAmount;
                    }

                    if (FSETUseTaxDeductiblePercentageFlag)
                    {
                        EnableTaxDeductibilityPct(chkDetailTaxDeductible.Checked);
                        UpdateTaxDeductibilityAmounts(this, null);
                    }
                }
                finally
                {
                    FPreviouslySelectedDetailRow.EndEdit();
                }
            }
            else
            {
                if (TransactionsFromCurrentBatch && (FPreviouslySelectedDetailRow != null))
                {
                    try
                    {
                        //Rows already active in transaction tab. Need to set current row as code further below will not update selected row
                        FPreviouslySelectedDetailRow.BeginEdit();

                        FPreviouslySelectedDetailRow.GiftAmount = GLRoutines.Divide(FPreviouslySelectedDetailRow.GiftTransactionAmount,
                                                                                    BatchExchangeRateToBase);

                        if (!IsTransactionInIntlCurrency)
                        {
                            FPreviouslySelectedDetailRow.GiftAmountIntl = (IntlToBaseCurrencyExchRate == 0) ? 0 : GLRoutines.Divide(
                                FPreviouslySelectedDetailRow.GiftAmount,
                                IntlToBaseCurrencyExchRate);
                        }
                        else
                        {
                            FPreviouslySelectedDetailRow.GiftAmountIntl = FPreviouslySelectedDetailRow.GiftTransactionAmount;
                        }
                    }
                    finally
                    {
                        FPreviouslySelectedDetailRow.EndEdit();
                    }
                }

                //Update all transactions
                UpdateTransactionsCurrencyAmounts(CurrentBatchRow, IntlToBaseCurrencyExchRate, IsTransactionInIntlCurrency);
            }
        }