private DataTable GetAccountListTable(TDBTransaction AReadTransaction, System.Int32 ALedgerNumber, string ATableName)
        {
            StringCollection FieldList = new StringCollection();

            FieldList.Add(AAccountTable.GetLedgerNumberDBName());
            FieldList.Add(AAccountTable.GetAccountCodeDBName());
            FieldList.Add(AAccountTable.GetAccountTypeDBName());
            FieldList.Add(AAccountTable.GetAccountCodeShortDescDBName());
            FieldList.Add(AAccountTable.GetAccountActiveFlagDBName());
            FieldList.Add(AAccountTable.GetPostingStatusDBName());
            FieldList.Add(AAccountTable.GetForeignCurrencyFlagDBName());
            FieldList.Add(AAccountTable.GetForeignCurrencyCodeDBName());
            GLSetupTDS TempDS = new GLSetupTDS();

            AAccountAccess.LoadViaALedger(TempDS, ALedgerNumber, FieldList, AReadTransaction);

            // load AAccountProperty and set the BankAccountFlag
            AAccountPropertyAccess.LoadViaALedger(TempDS, ALedgerNumber, AReadTransaction);

            foreach (AAccountPropertyRow accProp in TempDS.AAccountProperty.Rows)
            {
                if ((accProp.PropertyCode == MFinanceConstants.ACCOUNT_PROPERTY_BANK_ACCOUNT) && (accProp.PropertyValue == "true"))
                {
                    TempDS.AAccount.DefaultView.RowFilter = String.Format("{0}='{1}'",
                                                                          AAccountTable.GetAccountCodeDBName(),
                                                                          accProp.AccountCode);
                    GLSetupTDSAAccountRow acc = (GLSetupTDSAAccountRow)TempDS.AAccount.DefaultView[0].Row;
                    acc.BankAccountFlag = true;
                    TempDS.AAccount.DefaultView.RowFilter = "";
                }
            }

            // not currently needed as an Account is only a Bank Account if it has a 'Bank Account' Account Property
            // load AAccountHierarchyDetails and check if this account reports to the CASH account

            /*AAccountHierarchyDetailAccess.LoadViaAAccountHierarchy(TempDS,
             *  ALedgerNumber,
             *  MFinanceConstants.ACCOUNT_HIERARCHY_STANDARD,
             *  AReadTransaction);
             *
             * TLedgerInfo ledgerInfo = new TLedgerInfo(ALedgerNumber);
             * TGetAccountHierarchyDetailInfo accountHierarchyTools = new TGetAccountHierarchyDetailInfo(ledgerInfo);
             * List <string>children = accountHierarchyTools.GetChildren(MFinanceConstants.CASH_ACCT);
             *
             * foreach (GLSetupTDSAAccountRow account in TempDS.AAccount.Rows)
             * {
             *  if (children.Contains(account.AccountCode))
             *  {
             *      account.CashAccountFlag = true;
             *  }
             * }*/

            return(TempDS.AAccount);
        }
        private void CheckIfRevaluationIsDone()
        {
            if (!FInfoMode)
            {
                return;
            }

            /*
             * I'm no longer looking at this flag,
             * since it can be set even though some accounts are left requiring revaluation.
             * See Mantis 0004059
             *
             * if ((new TLedgerInitFlagHandler(FledgerInfo.LedgerNumber,
             *       TLedgerInitFlagEnum.Revaluation).Flag))
             * {
             *  return; // Revaluation has been performed for the current period.
             * }
             */

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      ref Transaction,
                                                                      delegate
            {
                // TODO: could also check for the balance in this month of the foreign currency account. if all balances are zero, no revaluation is needed.
                string testForForeignKeyAccount =
                    String.Format("SELECT COUNT(*) FROM PUB_a_account WHERE {0} = {1} and {2} = true",
                                  AAccountTable.GetLedgerNumberDBName(),
                                  FledgerInfo.LedgerNumber,
                                  AAccountTable.GetForeignCurrencyFlagDBName());

                Int32 ForeignAccountCount = Convert.ToInt32(DBAccess.GDBAccessObj.ExecuteScalar(testForForeignKeyAccount, Transaction));

                if (ForeignAccountCount > 0)
                {
                    TVerificationResult tvr = new TVerificationResult(
                        Catalog.GetString("Currency revaluation"),
                        Catalog.GetString(
                            "Before proceeding you may want to revalue the foreign currency accounts."), "",
                        TPeriodEndErrorAndStatusCodes.PEEC_05.ToString(), TResultSeverity.Resv_Noncritical);
                    // Error is non-critical - the user can choose to continue.
                    FverificationResults.Add(tvr);
                }
            });     // Get NewOrExisting AutoReadTransaction
        }
        private void CheckIfRevaluationIsDone()
        {
            if ((new TLedgerInitFlagHandler(FledgerInfo.LedgerNumber,
                                            TLedgerInitFlagEnum.Revaluation).Flag))
            {
                return; // Revaluation has been performed for the current period.
            }

            bool           NewTransaction = false;
            TDBTransaction transaction;

            try
            {
                transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                                                                                TEnforceIsolationLevel.eilMinimum,
                                                                                out NewTransaction);

                // TODO: could also check for the balance in this month of the foreign currency account. if all balances are zero, no revaluation is needed.
                string testForForeignKeyAccount =
                    String.Format("SELECT COUNT(*) FROM PUB_a_account WHERE {0} = {1} and {2} = true",
                                  AAccountTable.GetLedgerNumberDBName(),
                                  FledgerInfo.LedgerNumber,
                                  AAccountTable.GetForeignCurrencyFlagDBName());

                if (Convert.ToInt32(DBAccess.GDBAccessObj.ExecuteScalar(testForForeignKeyAccount, transaction)) != 0)
                {
                    TVerificationResult tvr = new TVerificationResult(
                        Catalog.GetString("Ledger revaluation"),
                        Catalog.GetString("Please run a foreign currency revaluation first."), "",
                        TPeriodEndErrorAndStatusCodes.PEEC_05.ToString(), TResultSeverity.Resv_Critical);
                    // Error is critical but additional checks can still be done
                    FverificationResults.Add(tvr);
                    FHasCriticalErrors = true;
                }
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }
            }
        }