private DataTable GetAccountingPeriodListTable(TDBTransaction AReadTransaction, System.Int32 ALedgerNumber, string ATableName) { StringCollection FieldList = new StringCollection(); FieldList.Add(AAccountingPeriodTable.GetLedgerNumberDBName()); FieldList.Add(AAccountingPeriodTable.GetAccountingPeriodNumberDBName()); FieldList.Add(AAccountingPeriodTable.GetAccountingPeriodDescDBName()); FieldList.Add(AAccountingPeriodTable.GetPeriodStartDateDBName()); FieldList.Add(AAccountingPeriodTable.GetPeriodEndDateDBName()); return(AAccountingPeriodAccess.LoadViaALedger(ALedgerNumber, FieldList, AReadTransaction)); }
public static bool GetFirstDayOfAccountingPeriod(Int32 ALedgerNumber, DateTime ADateInAPeriod, out DateTime AFirstDayOfPeriod) { TDBTransaction Transaction = null; DateTime Result = DateTime.MinValue; // Used by importing so the isolation level is serializable DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.Serializable, ref Transaction, delegate { // Get the accounting periods for this ledger. The table will contain more than 12 rows. // The start dates will be the correct day and month but may have been inserted for an arbitrary year when the table was first created. // We are really only interested in the Day anyway AAccountingPeriodTable periods = AAccountingPeriodAccess.LoadViaALedger(ALedgerNumber, Transaction); DataView periodsView = new DataView(periods, "", String.Format("{0} ASC", AAccountingPeriodTable.GetPeriodStartDateDBName()), DataViewRowState.CurrentRows); AAccountingPeriodRow row = (AAccountingPeriodRow)periodsView[0].Row; Result = new DateTime(ADateInAPeriod.Year, ADateInAPeriod.Month, row.PeriodStartDate.Day); if (ADateInAPeriod.Day < row.PeriodStartDate.Day) { Result = Result.AddMonths(-1); } }); AFirstDayOfPeriod = Result; return(Result != DateTime.MinValue); }
public static bool GetFirstDayOfAccountingPeriod(Int32 ALedgerNumber, DateTime ADateInAPeriod, out DateTime AFirstDayOfPeriod, TDataBase ADataBase = null) { TDBTransaction Transaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("GetFirstDayOfAccountingPeriod", ADataBase); DateTime Result = DateTime.MinValue; db.ReadTransaction(ref Transaction, delegate { // Get the accounting periods for this ledger. The table will contain more than 12 rows. // The start dates will be the correct day and month but may have been inserted for an arbitrary year when the table was first created. // We are really only interested in the Day anyway AAccountingPeriodTable periods = AAccountingPeriodAccess.LoadViaALedger(ALedgerNumber, Transaction); DataView periodsView = new DataView(periods, "", String.Format("{0} ASC", AAccountingPeriodTable.GetPeriodStartDateDBName()), DataViewRowState.CurrentRows); AAccountingPeriodRow row = (AAccountingPeriodRow)periodsView[0].Row; Result = new DateTime(ADateInAPeriod.Year, ADateInAPeriod.Month, row.PeriodStartDate.Day); if (ADateInAPeriod.Day < row.PeriodStartDate.Day) { Result = Result.AddMonths(-1); } }); if (ADataBase == null) { db.CloseDBConnection(); } AFirstDayOfPeriod = Result; return(Result != DateTime.MinValue); }