public static bool TrainBankStatement(Int32 ALedgerNumber, DateTime ADateOfStatement, string ABankAccountCode)
        {
            // get the statement keys
            TDBTransaction ReadTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted);

            AEpStatementTable Statements = new AEpStatementTable();
            AEpStatementRow   row        = Statements.NewRowTyped(false);

            row.LedgerNumber    = ALedgerNumber;
            row.Date            = ADateOfStatement;
            row.BankAccountCode = ABankAccountCode;

            Statements = AEpStatementAccess.LoadUsingTemplate(row, ReadTransaction);

            DBAccess.GDBAccessObj.RollbackTransaction();

            if (Statements.Rows.Count == 0)
            {
                return(false);
            }

            // search for already posted gift batches, and do the matching for these imported statements
            TBankImportMatching.Train(Statements);

            return(true);
        }
        public static TSubmitChangesResult StoreNewBankStatement(BankImportTDS AStatementAndTransactionsDS,
                                                                 out Int32 AFirstStatementKey)
        {
            string MyClientID = DomainManager.GClientID.ToString();

            AFirstStatementKey = -1;

            TProgressTracker.InitProgressTracker(MyClientID,
                                                 Catalog.GetString("Processing new bank statements"),
                                                 AStatementAndTransactionsDS.AEpStatement.Rows.Count + 1);

            TProgressTracker.SetCurrentState(MyClientID,
                                             Catalog.GetString("Saving to database"),
                                             0);

            try
            {
                // Must not throw away the changes because we need the correct statement keys
                AStatementAndTransactionsDS.DontThrowAwayAfterSubmitChanges = true;
                BankImportTDSAccess.SubmitChanges(AStatementAndTransactionsDS);

                AFirstStatementKey = -1;

                if (AStatementAndTransactionsDS != null)
                {
                    TProgressTracker.SetCurrentState(MyClientID,
                                                     Catalog.GetString("starting to train"),
                                                     1);

                    AFirstStatementKey = AStatementAndTransactionsDS.AEpStatement[0].StatementKey;

                    // search for already posted gift batches, and do the matching for these imported statements
                    TBankImportMatching.Train(AStatementAndTransactionsDS.AEpStatement);
                }

                TProgressTracker.FinishJob(MyClientID);
            }
            catch (Exception ex)
            {
                TLogging.Log(ex.ToString());
                TProgressTracker.CancelJob(MyClientID);
                return(TSubmitChangesResult.scrError);
            }

            return(TSubmitChangesResult.scrOK);
        }