/// <summary> /// TResetForwardPeriodICH.RunOperation /// Delete old year and update periods for those in new year (eg. 13 becomes 1, 14 becomes 2, etc) /// </summary> public override Int32 RunOperation() { Int32 JobSize = 0; bool NewTransaction; Boolean ShouldCommit = false; TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { String Query = "SELECT * FROM PUB_a_ich_stewardship WHERE " + "a_ledger_number_i=" + FLedgerInfo.LedgerNumber; DataTable Tbl = DBAccess.GDBAccessObj.SelectDT(Query, "AIchStewardship", Transaction); if (Tbl.Rows.Count > 0) { AIchStewardshipTable StewardshipTbl = new AIchStewardshipTable(); StewardshipTbl.Merge(Tbl); for (Int32 Idx = StewardshipTbl.Rows.Count - 1; Idx >= 0; Idx--) { AIchStewardshipRow StewardshipRow = StewardshipTbl[Idx]; if (StewardshipRow.PeriodNumber > FLedgerInfo.NumberOfAccountingPeriods) { StewardshipRow.PeriodNumber -= FLedgerInfo.NumberOfAccountingPeriods; JobSize++; } else { StewardshipRow.Delete(); } } if (!FInfoMode) { StewardshipTbl.ThrowAwayAfterSubmitChanges = true; AIchStewardshipAccess.SubmitChanges(StewardshipTbl, Transaction); ShouldCommit = true; } } } finally { if (NewTransaction) { if (ShouldCommit) { DBAccess.GDBAccessObj.CommitTransaction(); } else { DBAccess.GDBAccessObj.RollbackTransaction(); } } } return JobSize; }
private DataTable GetICHStewardshipListTable(TDBTransaction AReadTransaction, System.Int32 ALedgerNumber, string ATableName) { StringCollection FieldList = new StringCollection(); FieldList.Add(AIchStewardshipTable.GetLedgerNumberDBName()); FieldList.Add(AIchStewardshipTable.GetCostCentreCodeDBName()); FieldList.Add(AIchStewardshipTable.GetPeriodNumberDBName()); FieldList.Add(AIchStewardshipTable.GetIchNumberDBName()); FieldList.Add(AIchStewardshipTable.GetDateProcessedDBName()); return(AIchStewardshipAccess.LoadViaALedger(ALedgerNumber, FieldList, AReadTransaction)); }