/// <summary> /// Validates the MPartner Marital Status screen data. /// </summary> /// <param name="AContext">Context that describes where the data validation failed.</param> /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param> /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if /// data validation errors occur.</param> public static void ValidateConferenceCostType(object AContext, PcCostTypeRow ARow, ref TVerificationResultCollection AVerificationResultCollection) { DataColumn ValidationColumn; TVerificationResult VerificationResult = null; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'UnassignableDate' must not be empty if the flag is set ValidationColumn = ARow.Table.Columns[PcCostTypeTable.ColumnUnassignableDateId]; if (true) { if (ARow.UnassignableFlag) { VerificationResult = TValidationControlHelper.IsNotInvalidDate(ARow.UnassignableDate, String.Empty, AVerificationResultCollection, true, AContext, ValidationColumn); } // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult); } }
/// <summary> /// Validates the GL Batch Date dialog. /// </summary> /// <param name="ABatchDate">The Data being validated</param> /// <param name="ADescription">Description of control</param> /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if /// data validation errors occur.</param> /// <param name="AStartDateCurrentPeriod">If the caller knows this value it can be supplied. Otherwise the server will supply the value for the ledger.</param> /// <param name="AEndDateLastForwardingPeriod">If the caller knows this value it can be supplied. Otherwise the server will supply the value for the ledger.</param> /// <returns>True if the validation found no data validation errors, otherwise false.</returns> public static bool ValidateGLBatchDateManual(DateTime?ABatchDate, string ADescription, ref TVerificationResultCollection AVerificationResultCollection, DateTime AStartDateCurrentPeriod, DateTime AEndDateLastForwardingPeriod) { TScreenVerificationResult VerificationResult = null; int VerifResultCollAddedCount = 0; // 'Reversal Date' must be a valid date TVerificationResult Result = TValidationControlHelper.IsNotInvalidDate(ABatchDate, ADescription, AVerificationResultCollection, true, null); if (Result != null) { VerificationResult = new TScreenVerificationResult(Result, null); } // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(VerificationResult, null)) { VerifResultCollAddedCount++; } else { // 'Reversal Date' must lie within the required date range Result = TDateChecks.IsDateBetweenDates(ABatchDate, AStartDateCurrentPeriod, AEndDateLastForwardingPeriod, ADescription, TDateBetweenDatesCheckType.dbdctUnspecific, TDateBetweenDatesCheckType.dbdctUnspecific, null); if (Result != null) { VerificationResult = new TScreenVerificationResult(Result, null); } // Handle addition/removal to/from TVerificationResultCollection if (AVerificationResultCollection.Auto_Add_Or_AddOrRemove(VerificationResult, null)) { VerifResultCollAddedCount++; } } return(VerifResultCollAddedCount == 0); }
/// <summary> /// Validates the Daily Exchange Rates screen data. /// </summary> /// <param name="AContext">Context that describes where the data validation failed.</param> /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param> /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if /// data validation errors occur.</param> /// <param name="AMinDateTime">The earliest allowable date.</param> /// <param name="AMaxDateTime">The latest allowable date.</param> /// <param name="AIgnoreZeroRateCheck">If true a zero rate will be allowed. This will be the case when the Daily Exchange Rate screen is modal.</param> /// <param name="ALedgerTableRef">A ledger table containg the available ledgers and their base currencies</param> /// <param name="AEarliestAccountingPeriodStartDate">The earliest accounting period start date in all the active ledgers</param> /// <param name="ALatestAccountingPeriodEndDate">The latest accounting period end date in all the active ledgers</param> public static void ValidateDailyExchangeRate(object AContext, ADailyExchangeRateRow ARow, ref TVerificationResultCollection AVerificationResultCollection, DateTime AMinDateTime, DateTime AMaxDateTime, bool AIgnoreZeroRateCheck, ALedgerTable ALedgerTableRef, DateTime AEarliestAccountingPeriodStartDate, DateTime ALatestAccountingPeriodEndDate) { DataColumn ValidationColumn; TVerificationResult VerificationResult; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // RateOfExchange must be positive (definitely not zero unless in modal mode) ValidationColumn = ARow.Table.Columns[ADailyExchangeRateTable.ColumnRateOfExchangeId]; if (true) { if (AIgnoreZeroRateCheck) { VerificationResult = TNumericalChecks.IsPositiveOrZeroDecimal(ARow.RateOfExchange, String.Empty, AContext, ValidationColumn); } else { VerificationResult = TNumericalChecks.IsPositiveDecimal(ARow.RateOfExchange, String.Empty, AContext, ValidationColumn); } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult); } // Date must not be empty and must be in range ValidationColumn = ARow.Table.Columns[ADailyExchangeRateTable.ColumnDateEffectiveFromId]; if (true) { VerificationResult = TValidationControlHelper.IsNotInvalidDate(ARow.DateEffectiveFrom, String.Empty, AVerificationResultCollection, true, AContext, ValidationColumn); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult); if (VerificationResult == null) { if ((AMinDateTime > DateTime.MinValue) && (AMaxDateTime < DateTime.MaxValue)) { // Check that the date is in range VerificationResult = TDateChecks.IsDateBetweenDates(ARow.DateEffectiveFrom, AMinDateTime, AMaxDateTime, String.Empty, TDateBetweenDatesCheckType.dbdctUnspecific, TDateBetweenDatesCheckType.dbdctUnspecific, AContext, ValidationColumn); } else if (AMaxDateTime < DateTime.MaxValue) { VerificationResult = TDateChecks.FirstLesserOrEqualThanSecondDate(ARow.DateEffectiveFrom, AMaxDateTime, String.Empty, Ict.Common.StringHelper.DateToLocalizedString(AMaxDateTime), AContext, ValidationColumn); if ((VerificationResult == null) && (ARow.RowState == DataRowState.Added)) { // even without a specific minimum date it should not be too far back if (ARow.DateEffectiveFrom < AEarliestAccountingPeriodStartDate) { VerificationResult = new TScreenVerificationResult(AContext, ValidationColumn, Catalog.GetString( "The date is before the start of the earliest current accounting period of any active ledger."), TResultSeverity.Resv_Noncritical); } } } else if (AMinDateTime > DateTime.MinValue) { VerificationResult = TDateChecks.FirstGreaterOrEqualThanSecondDate(ARow.DateEffectiveFrom, AMinDateTime, String.Empty, Ict.Common.StringHelper.DateToLocalizedString(AMinDateTime), AContext, ValidationColumn); if ((VerificationResult == null) && (ARow.RowState == DataRowState.Added)) { // even without a specific maximum date it should not be too far ahead if (ARow.DateEffectiveFrom > ALatestAccountingPeriodEndDate) { VerificationResult = new TScreenVerificationResult(AContext, ValidationColumn, Catalog.GetString( "The date is after the end of the latest forwarding period of any active ledger."), TResultSeverity.Resv_Noncritical); } } } else if ((AMinDateTime == DateTime.MinValue) && (AMaxDateTime == DateTime.MaxValue) && (ARow.RowState == DataRowState.Added)) { // even without a specific maximum date it should not be too far ahead if (ARow.DateEffectiveFrom > ALatestAccountingPeriodEndDate) { VerificationResult = new TScreenVerificationResult(AContext, ValidationColumn, Catalog.GetString( "The date is after the end of the latest forwarding period of any active ledger."), TResultSeverity.Resv_Noncritical); } // even without a specific minimum date it should not be too far back else if (ARow.DateEffectiveFrom < AEarliestAccountingPeriodStartDate) { VerificationResult = new TScreenVerificationResult(AContext, ValidationColumn, Catalog.GetString( "The date is before the start of the earliest current accounting period of any active ledger."), TResultSeverity.Resv_Noncritical); } } // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult); } } // Time must not be negative (indicating an error) ValidationColumn = ARow.Table.Columns[ADailyExchangeRateTable.ColumnTimeEffectiveFromId]; if (true) { VerificationResult = TTimeChecks.IsValidIntegerTime(ARow.TimeEffectiveFrom, String.Empty, AContext, ValidationColumn); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult); } if (true) { // These tests are for the GUI only ValidationColumn = ARow.Table.Columns[ADailyExchangeRateTable.ColumnToCurrencyCodeId]; if (true) { // One of the currencies should be the base currency of one of the ledgers if (ARow.RowState == DataRowState.Added) { // Only do this test if the To Currency ComboBox is enabled TScreenVerificationResult vr = null; DataView fromView = new DataView(ALedgerTableRef, String.Format("{0}='{1}'", ALedgerTable.GetBaseCurrencyDBName(), ARow.FromCurrencyCode), String.Empty, DataViewRowState.CurrentRows); if (fromView.Count == 0) { DataView toView = new DataView(ALedgerTableRef, String.Format("{0}='{1}'", ALedgerTable.GetBaseCurrencyDBName(), ARow.ToCurrencyCode), String.Empty, DataViewRowState.CurrentRows); if (toView.Count == 0) { vr = new TScreenVerificationResult(AContext, ValidationColumn, "One of the currencies should normally be a base currency for one of the Ledgers", TResultSeverity.Resv_Noncritical); } } // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, vr); } } } }