public static BudgetTDS LoadBudget(Int32 ALedgerNumber)
        {
            BudgetTDS MainDS = new BudgetTDS();

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum,
                                                                      ref Transaction,
                                                                      delegate
            {
                //TODO: need to filter on Year
                ABudgetAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                ABudgetRevisionAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                //TODO: need to filter on ABudgetPeriod using LoadViaBudget or LoadViaUniqueKey
                ABudgetPeriodAccess.LoadAll(MainDS, Transaction);
                ALedgerAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, Transaction);

                //            ABudgetPeriodTable BudgetPeriodTable = new ABudgetPeriodTable();
                //            ABudgetPeriodRow TemplateRow = (ABudgetPeriodRow)BudgetPeriodTable.NewRow(false);
                //
                //            TemplateRow.BudgetSequence;
                //            ABudgetPeriodAccess.LoadViaABudgetTemplate(MainDS, TemplateRow, Transaction);
            });

            // Accept row changes here so that the Client gets 'unmodified' rows
            MainDS.AcceptChanges();

            // Remove all Tables that were not filled with data before remoting them.
            MainDS.RemoveEmptyTables();

            return(MainDS);
        }
        public static BudgetTDS LoadBudgetForAutoGenerate(Int32 ALedgerNumber)
        {
            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                      TEnforceIsolationLevel.eilMinimum,
                                                                      ref Transaction,
                                                                      delegate
            {
                //TODO: need to filter on Year
                ABudgetAccess.LoadViaALedger(FMainDS, ALedgerNumber, Transaction);
                ABudgetRevisionAccess.LoadViaALedger(FMainDS, ALedgerNumber, Transaction);
                //TODO: need to filter on ABudgetPeriod using LoadViaBudget or LoadViaUniqueKey
                ABudgetPeriodAccess.LoadAll(FMainDS, Transaction);
                ALedgerAccess.LoadByPrimaryKey(FMainDS, ALedgerNumber, Transaction);
                ABudgetTypeAccess.LoadAll(FMainDS, Transaction);
            });

            // Accept row changes here so that the Client gets 'unmodified' rows
            FMainDS.AcceptChanges();

            // Remove all Tables that were not filled with data before remoting them.
            FMainDS.RemoveEmptyTables();

            return(FMainDS);
        }
Beispiel #3
0
        public static BudgetTDS LoadBudgetForAutoGenerate(Int32 ALedgerNumber)
        {
            BudgetTDS FMainDS = new BudgetTDS();

            TDBTransaction Transaction = new TDBTransaction();
            TDataBase      db          = DBAccess.Connect("LoadBudgetForAutoGenerate");

            db.ReadTransaction(
                ref Transaction,
                delegate
            {
                ALedgerAccess.LoadByPrimaryKey(FMainDS, ALedgerNumber, Transaction);

                #region Validate Data

                if ((FMainDS.ALedger == null) || (FMainDS.ALedger.Count == 0))
                {
                    throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString(
                                                                                               "Function:{0} - Ledger data for Ledger number {1} does not exist or could not be accessed!"),
                                                                                           Utilities.GetMethodName(true),
                                                                                           ALedgerNumber));
                }

                #endregion Validate Data

                int CurrentFinancialYear = FMainDS.ALedger[0].CurrentFinancialYear;

                //Load all by Ledger/Year but none may exist
                ABudgetTable BudgetTable = new ABudgetTable();
                ABudgetRow TemplateRow   = (ABudgetRow)BudgetTable.NewRow();

                TemplateRow.LedgerNumber = ALedgerNumber;
                TemplateRow.Year         = CurrentFinancialYear;

                StringCollection Operators = StringHelper.InitStrArr(new string[] { "=", "=" });
                StringCollection OrderList = new StringCollection();

                OrderList.Add("ORDER BY");
                OrderList.Add(ABudgetTable.GetCostCentreCodeDBName() + " ASC");
                OrderList.Add(ABudgetTable.GetAccountCodeDBName() + " ASC");

                ABudgetAccess.LoadUsingTemplate(FMainDS, TemplateRow, Operators, null, Transaction, OrderList, 0, 0);
                ABudgetPeriodAccess.LoadViaABudgetTemplate(FMainDS, TemplateRow, Operators, null, Transaction, OrderList, 0, 0);

                ABudgetRevisionAccess.LoadByPrimaryKey(FMainDS, ALedgerNumber, CurrentFinancialYear, 0, Transaction);

                ABudgetTypeAccess.LoadAll(FMainDS, Transaction);
            });

            // Accept row changes here so that the Client gets 'unmodified' rows
            FMainDS.AcceptChanges();

            // Remove all Tables that were not filled with data before remoting them.
            FMainDS.RemoveEmptyTables();

            return(FMainDS);
        }