/// <summary>
        /// Update Budget Period Amounts for each record that was created or modified during an import
        /// </summary>
        private void UpdateABudgetPeriodAmounts(BudgetTDS AMainDS, int ACurrentBudgetYear)
        {
            DataView BudgetDV = new DataView(AMainDS.ABudget);

            BudgetDV.RowFilter = String.Format("Isnull({0},'') <> '' And ({0}='Added' Or {0}='Updated')",
                                               ABudgetTable.GetCommentDBName());

            BudgetDV.Sort = String.Format("{0} ASC",
                                          ABudgetTable.GetYearDBName());

            foreach (DataRowView drv in BudgetDV)
            {
                BudgetTDSABudgetRow budgetRow = (BudgetTDSABudgetRow)drv.Row;

                int budgetSeq = budgetRow.BudgetSequence;

                DataView budgetPeriodsDV = new DataView(AMainDS.ABudgetPeriod);

                budgetPeriodsDV.RowFilter = String.Format("{0}={1}",
                                                          ABudgetPeriodTable.GetBudgetSequenceDBName(),
                                                          budgetRow.BudgetSequence);
                budgetPeriodsDV.Sort = String.Format("{0} ASC",
                                                     ABudgetPeriodTable.GetPeriodNumberDBName());

                foreach (DataRowView drv2 in budgetPeriodsDV)
                {
                    ABudgetPeriodRow budgetPeriodRow = (ABudgetPeriodRow)drv2.Row;

                    int    period             = budgetPeriodRow.PeriodNumber;
                    string periodAmountColumn = string.Empty;

                    if (period <= FNumberOfPeriods)
                    {
                        periodAmountColumn            = "Period" + period.ToString("00") + "Amount";
                        budgetRow[periodAmountColumn] = budgetPeriodRow.BudgetBase;
                    }
                    else
                    {
                        //TODO After data migration, this should not happen so add an error message.
                        // In old Petra, budget periods always go up to 20, but are only populated
                        //   up to number of financial periods
                    }
                }
            }

            //Remove import related comment
            // - done separately to loop above to avoid confusion as DataView filtering is on Comment field
            foreach (DataRowView drv in BudgetDV)
            {
                BudgetTDSABudgetRow budgetRow = (BudgetTDSABudgetRow)drv.Row;
                budgetRow.Comment = string.Empty;
            }
        }
        /// <summary>
        /// Update Budget Period Amounts for each record that was created or modified during an import
        /// </summary>
        private void UpdateABudgetPeriodAmounts(BudgetTDS AMainDS, int ASelectedBudgetYear)
        {
            foreach (BudgetTDSABudgetRow budgetRow in AMainDS.ABudget.Rows)
            {
                if (budgetRow.RowState == DataRowState.Unchanged)
                {
                    continue;
                }

                int budgetSeq = budgetRow.BudgetSequence;

                DataView budgetPeriodsDV = new DataView(AMainDS.ABudgetPeriod);

                budgetPeriodsDV.RowFilter = String.Format("{0}={1}",
                                                          ABudgetPeriodTable.GetBudgetSequenceDBName(),
                                                          budgetRow.BudgetSequence);
                budgetPeriodsDV.Sort = String.Format("{0} ASC",
                                                     ABudgetPeriodTable.GetPeriodNumberDBName());

                foreach (DataRowView drv2 in budgetPeriodsDV)
                {
                    ABudgetPeriodRow budgetPeriodRow = (ABudgetPeriodRow)drv2.Row;

                    int    period             = budgetPeriodRow.PeriodNumber;
                    string periodAmountColumn = string.Empty;

                    if (period <= FNumberOfPeriods)
                    {
                        periodAmountColumn            = "Period" + period.ToString("00") + "Amount";
                        budgetRow[periodAmountColumn] = budgetPeriodRow.BudgetBase;
                    }
                    else
                    {
                        //TODO After data migration, this should not happen so add an error message.
                        // In old Petra, budget periods always go up to 20, but are only populated
                        //   up to number of financial periods
                    }
                }
            }

            //Attempts using LINQ
            //DataTable BudgetPeriodAmounts = new DataTable();
            //BudgetPeriodAmounts.Columns.Add("BudgetSequence", typeof(int));
            //BudgetPeriodAmounts.Columns.Add("PeriodNumber", typeof(int));
            //BudgetPeriodAmounts.Columns.Add("Amount", typeof(decimal));
            //BudgetPeriodAmounts.PrimaryKey = new DataColumn[] {BudgetPeriodAmounts.Columns["BudgetSequence"],
            //                             BudgetPeriodAmounts.Columns["PeriodNumber"]};

            //var varBudgetPeriodAmounts =
            //    from BudgetTDSABudgetRow budgetRow in FMainDS.ABudget.Rows
            //                 where budgetRow.Year == ASpecificYear
            //                 join ABudgetPeriodRow budgetPeriodRow in FMainDS.ABudgetPeriod.Rows on budgetRow.BudgetSequence equals budgetPeriodRow.BudgetSequence
            //                 select new
            //                 {
            //                     BudgetSequence = budgetRow.BudgetSequence,
            //                     PeriodNumber = budgetPeriodRow.PeriodNumber,
            //                     Amount = budgetPeriodRow.BudgetBase
            //                 }; //produces flat sequence

            //foreach (var rowObj in varBudgetPeriodAmounts)
            //{
            //    DataRow row = BudgetPeriodAmounts.NewRow();
            //    BudgetPeriodAmounts.Rows.Add(rowObj.BudgetSequence, rowObj.PeriodNumber, rowObj.Amount);
            //}

            //DataView BudgetsPeriodAmountsForYearDV = new DataView(BudgetPeriodAmounts);
            //BudgetsPeriodAmountsForYearDV.Sort = "BudgetSequence ASC, PeriodNumber ASC";


            //for (int i = 0; i < BudgetsForYear.Count; i++)
            //{
            //    BudgetTDSABudgetRow budgetRow = (BudgetTDSABudgetRow)BudgetsForYear[i].Row;

            //    for (int j = 1; j <= FNumberOfPeriods; j++)
            //    {
            //        DataRow budgetsPeriodAmounts = BudgetsPeriodAmountsForYearDV[(FNumberOfPeriods * i) + j - 1].Row;

            //        string columnName = "Period" + j.ToString("00") + "Amount";

            //        if (budgetRow.BudgetSequence == (int)budgetsPeriodAmounts["BudgetSequence"])
            //        {
            //            budgetRow[columnName] = (decimal)budgetsPeriodAmounts["Amount"];
            //        }
            //    }
            //}
        }