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); }
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); }