Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #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);
        }
Пример #4
0
        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;
        }
Пример #5
0
        public static BudgetTDS LoadAllBudgets(Int32 ALedgerNumber)
        {
            #region Validate Arguments

            if (ALedgerNumber <= 0)
            {
                throw new EFinanceSystemInvalidLedgerNumberException(String.Format(Catalog.GetString(
                            "Function:{0} - The Ledger number must be greater than 0!"),
                        Utilities.GetMethodName(true)), ALedgerNumber);
            }

            #endregion Validate Arguments

            BudgetTDS MainDS = new BudgetTDS();
            TDBTransaction Transaction = null;

            try
            {
                DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                    TEnforceIsolationLevel.eilMinimum,
                    ref Transaction,
                    delegate
                    {
                        ALedgerAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, Transaction);

                        #region Validate Data

                        if ((MainDS.ALedger == null) || (MainDS.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

                        //Load all by Ledger but none may exist
                        ABudgetAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        ABudgetRevisionAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);

                        ABudgetTable BudgetTable = new ABudgetTable();
                        ABudgetRow TemplateRow = (ABudgetRow)BudgetTable.NewRow();
                        TemplateRow.LedgerNumber = ALedgerNumber;

                        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();
            }
            catch (Exception ex)
            {
                TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}",
                        Utilities.GetMethodSignature(),
                        Environment.NewLine,
                        ex.Message));
                throw ex;
            }

            return MainDS;
        }
Пример #6
0
        public static BudgetTDS LoadBudgetsForYear(Int32 ALedgerNumber, Int32 ABudgetYear)
        {
            #region Validate Arguments

            if (ALedgerNumber <= 0)
            {
                throw new EFinanceSystemInvalidLedgerNumberException(String.Format(Catalog.GetString(
                            "Function:{0} - The Ledger number must be greater than 0!"),
                        Utilities.GetMethodName(true)), ALedgerNumber);
            }
            else if (ABudgetYear < 0)
            {
                throw new ArgumentException(String.Format(Catalog.GetString("Function:{0} - The Budget Year number cannot be negative!"),
                        Utilities.GetMethodName(true)));
            }

            #endregion Validate Arguments

            BudgetTDS MainDS = new BudgetTDS();
            TDBTransaction Transaction = null;

            try
            {
                DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                    TEnforceIsolationLevel.eilMinimum,
                    ref Transaction,
                    delegate
                    {
                        ALedgerAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, Transaction);

                        #region Validate Data

                        if ((MainDS.ALedger == null) || (MainDS.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 numPeriods = MainDS.ALedger[0].NumberOfAccountingPeriods;

                        //Load all by Year
                        LoadABudgetByYearWithCustomColumns(ref MainDS, ALedgerNumber, ABudgetYear, numPeriods, Transaction);

                        //Load budget period data
                        ABudgetTable BudgetTable = new ABudgetTable();
                        ABudgetRow TemplateRow = (ABudgetRow)BudgetTable.NewRow();
                        TemplateRow.Year = ABudgetYear;

                        ABudgetPeriodAccess.LoadViaABudgetTemplate(MainDS, TemplateRow, Transaction);
                        //TODO: add Budget Revision capability when decision made to add it to OP.
                        //  Assume Revision=0 for now until implemented
                        ABudgetRevisionAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, ABudgetYear, 0, 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();
            }
            catch (Exception ex)
            {
                TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}",
                        Utilities.GetMethodSignature(),
                        Environment.NewLine,
                        ex.Message));
                throw ex;
            }

            return MainDS;
        }