/// <summary>
        /// post all gift batches in the given period, but leave some (or none) unposted
        /// </summary>
        public static bool PostBatches(int AYear, int APeriod, int ALeaveBatchesUnposted, TDataBase ADataBase)
        {
            GiftBatchTDS MainDS = new GiftBatchTDS();

            AGiftBatchRow GiftBatchTemplateRow = MainDS.AGiftBatch.NewRowTyped(false);

            GiftBatchTemplateRow.LedgerNumber = FLedgerNumber;
            GiftBatchTemplateRow.BatchYear    = AYear;
            GiftBatchTemplateRow.BatchPeriod  = APeriod;
            GiftBatchTemplateRow.BatchStatus  = MFinanceConstants.BATCH_UNPOSTED;

            TDBTransaction Transaction = new TDBTransaction();

            ADataBase.ReadTransaction(ref Transaction,
                                      delegate
            {
                AGiftBatchAccess.LoadUsingTemplate(MainDS, GiftBatchTemplateRow, Transaction);
            });

            int countUnPosted = MainDS.AGiftBatch.Count;

            List <Int32> GiftBatchesToPost  = new List <int>();
            List <Int32> generatedGlBatches = new List <int>();

            foreach (AGiftBatchRow batch in MainDS.AGiftBatch.Rows)
            {
                if (countUnPosted <= ALeaveBatchesUnposted)
                {
                    break;
                }

                countUnPosted--;

                GiftBatchesToPost.Add(batch.BatchNumber);
            }

            TVerificationResultCollection VerificationResult;

            if (!TGiftTransactionWebConnector.PostGiftBatches(FLedgerNumber, GiftBatchesToPost, generatedGlBatches, out VerificationResult, ADataBase))
            {
                TLogging.Log(VerificationResult.BuildVerificationResultString());
                return(false);
            }

            return(true);
        }