/// <summary> /// Checks whether two strings are in correct order (lexical comparison). Null values are accepted. /// </summary> /// <param name="ATxt1">The first string; it is supposed to be lesser or equal than ATxt2.</param> /// <param name="ATxt2">The second string; it is supposed to be greater or equal than ATxt1.</param> /// <param name="AFirstDescription">Description what the value is about (for the /// error message).</param> /// <param name="ASecondDescription">Description what the value is about (for the /// error message).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AResultControl">Which <see cref="System.Windows.Forms.Control" /> is involved (can be null).</param> /// <returns>Null if <paramref name="ATxt1" /> is lesser or equal than /// <paramref name="ATxt2" />, otherwise a <see cref="TVerificationResult" /> is returned that /// contains details about the problem, with a message that uses <paramref name="AFirstDescription" /> /// and <paramref name="ASecondDescription" />.</returns> public static TVerificationResult FirstLesserOrEqualThanSecondString(String ATxt1, String ATxt2, String AFirstDescription, String ASecondDescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null, System.Windows.Forms.Control AResultControl = null) { TVerificationResult ReturnValue; string FirstDescription = THelper.NiceValueDescription(AFirstDescription); string SecondDescription = THelper.NiceValueDescription(ASecondDescription); // Check if (System.String.Compare(ATxt1, ATxt2, false) <= 0) { // Lexical comparision results in: ATxt1 <= ATxt2 ReturnValue = null; } else { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_INCONGRUOUSSTRINGS, StrInvalidStringOrder, new string[] { FirstDescription, SecondDescription })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } return(ReturnValue); }
/// <summary> /// Checks whether an integer time is in the range 0..86399 /// </summary> /// <param name="AValue">Integer number.</param> /// <param name="ADescription">Description what the integer number is about (for the error /// message).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <returns>Null if <paramref name="AValue" /> contains a valid integer number or is null, /// otherwise a <see cref="TVerificationResult" /> is returned that contains details about the problem, /// with a message that uses <paramref name="ADescription" />.</returns> public static TVerificationResult IsValidIntegerTime(Int64?AValue, String ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null) { TVerificationResult ReturnValue = null; String Description = THelper.NiceValueDescription(ADescription); if (!AValue.HasValue) { return(null); } // Check if ((AValue.Value < 0) || (AValue.Value >= 86400)) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_INVALIDINTEGERTIME, CommonResourcestrings.StrInvalidStringEntered + Environment.NewLine + StrMustBeTime, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn); } } return(ReturnValue); }
/// <summary> /// Checks whether the date is today or in the past. Null values are accepted. /// </summary> /// <param name="ADate">The date to check.</param> /// <param name="ADescription">The name of the date value.</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <returns>Null if the date <paramref name="ADate" /> is today or in the past, /// otherwise a verification result with a message that uses <paramref name="ADescription" />. /// </returns> public static TVerificationResult IsCurrentOrPastDate(DateTime?ADate, String ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null) { TVerificationResult ReturnValue; String Description = THelper.NiceValueDescription(ADescription); if (!ADate.HasValue) { return(null); } // Check if (ADate <= DateTime.Today) { //MessageBox.Show('Date <= Today'); ReturnValue = null; } else { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NOFUTUREDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateMustNotBeFutureDate, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn); } } return(ReturnValue); }
/// <summary> /// This is called in case a date is invalid, in order to generate a generic /// <see cref="TVerificationResult" />. /// </summary> /// <param name="ADescription">Either a name for the date value or an empty string.</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <returns>A Verification Result with the error message.</returns> public static TVerificationResult GetInvalidDateVerificationResult(String ADescription, object AResultContext = null) { String Description = THelper.NiceValueDescription(ADescription); return(new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_INVALIDDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrMustBeDate, new string[] { Description }))); }
/// <summary> /// Checks whether the date is not undefined. DateTime.MinValue is seen as undefined by this Method. /// Null values are accepted. /// </summary> /// <param name="ADate">The date to check.</param> /// <param name="ADescription">The name of the date value.</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AAlternativeFirstDayOfPeriod"></param> /// <remarks>Usage in the Data Validation Framework: rather than using this Method, use Method /// 'TValidationControlHelper.IsNotInvalidDate' for checking the validity of dates as the latter can deal not only with /// empty dates, but dates that are invalid in other respects (e.g. exceeding a valid date range)!!!</remarks> /// <returns>Null if validation succeeded, otherwise a <see cref="TVerificationResult" /> is /// returned that contains details about the problem.</returns> public static TVerificationResult IsNotCorporateDateTime(DateTime?ADate, String ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null, int AAlternativeFirstDayOfPeriod = 1) { TVerificationResult ReturnValue; DateTime TheDate = TSaveConvert.ObjectToDate(ADate); DateTime FirstOfMonth; DateTime FirstOfMonthAlternative; String Description = THelper.NiceValueDescription(ADescription); if (!ADate.HasValue) { return(null); } FirstOfMonth = new DateTime(TheDate.Year, TheDate.Month, 1); FirstOfMonthAlternative = new DateTime(TheDate.Year, TheDate.Month, AAlternativeFirstDayOfPeriod); // Checks if ((TheDate == FirstOfMonth) || (TheDate == FirstOfMonthAlternative)) { //MessageBox.Show('Date <> DateTime.MinValue'); ReturnValue = null; } else { if (AAlternativeFirstDayOfPeriod == 1) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_INVALIDDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateMustNotBeLaterThanFirstDayOfMonth, new string[] { Description })); } else { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_INVALIDDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + String.Format(Catalog.GetString("The first day of the period should be either 1 or {0}."), AAlternativeFirstDayOfPeriod))); } if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn); } } return(ReturnValue); }
/// <summary> /// Checks whether the date is not undefined. DateTime.MinValue is seen as undefined by this Method. /// Null values are accepted. They are treated as valid, unless <paramref name="ATreatNullAsInvalid" /> is /// set to true. /// </summary> /// <param name="ADate">The date to check.</param> /// <param name="ADescription">The name of the date value.</param> /// <param name="ATreatNullAsInvalid">Set this to true to treated null value in <paramref name="ADate" /> as invalid.</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AResultControl">Which <see cref="System.Windows.Forms.Control" /> is involved (can be null).</param> /// <remarks>Usage in the Data Validation Framework: rather than using this Method, use Method /// 'TSharedValidationControlHelper.IsNotInvalidDate' for checking the validity of dates as the latter can deal not only with /// empty dates, but dates that are invalid in other respects (e.g. exceeding a valid date range)!!!</remarks> /// <returns>Null if validation succeeded, otherwise a <see cref="TVerificationResult" /> is /// returned that contains details about the problem.</returns> public static TVerificationResult IsNotUndefinedDateTime(DateTime?ADate, String ADescription, bool ATreatNullAsInvalid = false, object AResultContext = null, System.Data.DataColumn AResultColumn = null, System.Windows.Forms.Control AResultControl = null) { TVerificationResult ReturnValue; DateTime TheDate = TSaveConvert.ObjectToDate(ADate); String Description = THelper.NiceValueDescription(ADescription); if (!ADate.HasValue) { if (!ATreatNullAsInvalid) { return(null); } else { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NOUNDEFINEDDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateMustNotBeEmpty, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } } // Check if (TheDate != DateTime.MinValue) { //MessageBox.Show('Date <> DateTime.MinValue'); ReturnValue = null; } else { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NOUNDEFINEDDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateMustNotBeEmpty, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } return(ReturnValue); }
/// <summary> /// Checks whether the string <paramref name="AString" /> contains a valid DateTime. /// </summary> /// <param name="AString">The date to check.</param> /// <param name="ADescription">The name of the date value.</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <returns>Null if <paramref name="AString" /> contains a valid DateTime, otherwise a /// <see cref="TVerificationResult" /> with a message which uses /// <paramref name="ADescription" /> is returned.</returns> public static TVerificationResult IsValidDateTime(String AString, String ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null) { TVerificationResult ReturnValue = null; String Description = THelper.NiceValueDescription(ADescription); DateTime temp; if (!DateTime.TryParse(AString, out temp)) { ReturnValue = GetInvalidDateVerificationResult(Description, AResultContext); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn); } } return(ReturnValue); }
/// <summary> /// Checks whether an Object is null value or empty string. /// </summary> /// <param name="AValue">The Object to check.</param> /// <param name="ADescription">Description what the value is about (for the /// error message).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <returns>Null if <paramref name="AValue" /> is not null, /// otherwise a <see cref="TVerificationResult" /> is returned that /// contains details about the problem, with a message that uses <paramref name="ADescription" />.</returns> public static TVerificationResult ValueMustNotBeNullOrEmptyString(object AValue, string ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null) { TVerificationResult ReturnValue = null; String Description = THelper.NiceValueDescription(ADescription); // Check if ((AValue == null) || (AValue.ToString() == String.Empty)) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NONULL, StrValueMustNotBeNullOrEmptyString, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn); } } return(ReturnValue); }
/// <summary> /// Checks whether an Object is null. /// </summary> /// <param name="AValue">The Object to check.</param> /// <param name="ADescription">Description what the value is about (for the /// error message).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AResultControl">Which <see cref="System.Windows.Forms.Control" /> is involved (can be null).</param> /// <returns>Null if <paramref name="AValue" /> is not null, /// otherwise a <see cref="TVerificationResult" /> is returned that /// contains details about the problem, with a message that uses <paramref name="ADescription" />.</returns> public static TVerificationResult ValueMustNotBeNull(object AValue, string ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null, System.Windows.Forms.Control AResultControl = null) { TVerificationResult ReturnValue = null; String Description = THelper.NiceValueDescription(ADescription); // Check if (AValue == null) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NONULL, StrValueMustNotBeNull, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } return(ReturnValue); }
/// <summary> /// Checks whether the first submitted date is later than the second submitted /// date. Null dates are accepted. /// </summary> /// <param name="ADate1">First date.</param> /// <param name="ADate2">Second date.</param> /// <param name="AFirstDateDescription">Description what the first date is about (for the /// error message).</param> /// <param name="ASecondDateDescription">Description what the second date is about (for /// the error message).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <returns>Null if validation succeeded, otherwise a <see cref="TVerificationResult" /> is /// returned that contains details about the problem, with a message that uses /// <paramref name="AFirstDateDescription" /> and <paramref name="ASecondDateDescription" />.</returns> public static TVerificationResult FirstGreaterThanSecondDate(DateTime?ADate1, DateTime?ADate2, string AFirstDateDescription, string ASecondDateDescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null) { TVerificationResult ReturnValue; String FirstDateDescription = THelper.NiceValueDescription(AFirstDateDescription); String SecondDateDescription = THelper.NiceValueDescription(ASecondDateDescription); if ((!ADate1.HasValue) || (!ADate2.HasValue)) { return(null); } // Check if (ADate1 > ADate2) { //MessageBox.Show('ADate1 <= ADate2'); ReturnValue = null; } else { if (ADate1 != new DateTime(0001, 1, 1)) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_INVALIDDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateCannotBeEarlierOrEqual, new string[] { FirstDateDescription, SecondDateDescription })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn); } } else { ReturnValue = null; } } return(ReturnValue); }
/// <summary> /// Checks whether a strings is null or <see cref="String.Empty" />. Null values are accepted. /// </summary> /// <param name="AValue">The string to check.</param> /// <param name="ADescription">Description what the value is about (for the /// error message).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AResultControl">Which <see cref="System.Windows.Forms.Control" /> is involved (can be null).</param> /// <returns>Null if <paramref name="AValue" /> is not null and not <see cref="String.Empty" />, /// otherwise a <see cref="TVerificationResult" /> is returned that /// contains details about the problem, with a message that uses <paramref name="ADescription" />.</returns> public static TVerificationResult StringMustNotBeEmpty(string AValue, string ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null, System.Windows.Forms.Control AResultControl = null) { TVerificationResult ReturnValue = null; String Description = THelper.NiceValueDescription(ADescription); // Check if ((AValue == null) || (AValue == String.Empty)) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NOEMPTYSTRING, CommonResourcestrings.StrInvalidStringEntered + Environment.NewLine + StrStringMustNotBeEmpty, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } return(ReturnValue); }
/// <summary> /// Checks whether a strings' length is lesser or equal to the specified amount of characters. Null values are accepted. /// </summary> /// <param name="AValue">The string to check.</param> /// <param name="APermittedStringLength">The permitted amount of characters.</param> /// <param name="ADescription">Description what the value is about (for the /// error message).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AResultControl">Which <see cref="System.Windows.Forms.Control" /> is involved (can be null).</param> /// <returns>Null if <paramref name="AValue" /> is not null and not <see cref="String.Empty" />, /// otherwise a <see cref="TVerificationResult" /> is returned that /// contains details about the problem, with a message that uses <paramref name="ADescription" />.</returns> public static TVerificationResult StringLengthLesserOrEqual(string AValue, int APermittedStringLength, string ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null, System.Windows.Forms.Control AResultControl = null) { TVerificationResult ReturnValue = null; String Description = THelper.NiceValueDescription(ADescription); // Check if ((AValue != null) && (AValue.Length > APermittedStringLength)) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_STRINGTOOLONG, CommonResourcestrings.StrInvalidStringEntered + Environment.NewLine + StrStringTooLong, new string[] { Description, APermittedStringLength.ToString(), AValue.Length.ToString() })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } return(ReturnValue); }
/// <summary> /// Checks whether the date is today or in the future. Null values are accepted. /// </summary> /// <param name="ADate">Date to check.</param> /// <param name="ADescription">Name of the date value.</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AResultControl">Which <see cref="System.Windows.Forms.Control" /> is involved (can be null).</param> /// <returns>Null if the date <paramref name="ADate" /> is today or in the future, /// otherwise a verification result with a message that uses <paramref name="ADescription" />. /// </returns> public static TVerificationResult IsCurrentOrFutureDate(DateTime?ADate, String ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null, System.Windows.Forms.Control AResultControl = null) { TVerificationResult ReturnValue; DateTime TheDate = TSaveConvert.ObjectToDate(ADate); String Description = THelper.NiceValueDescription(ADescription); if (!ADate.HasValue) { return(null); } // Check if (TheDate >= DateTime.Today) { //MessageBox.Show('Date >= Today'); ReturnValue = null; } else { if (TheDate != DateTime.MinValue) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NOPASTDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateMustNotBePastDate, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } else { ReturnValue = null; } } return(ReturnValue); }
/// <summary> /// Checks whether the date is not undefined. DateTime.MinValue is seen as undefined by this Method. /// Null values are accepted. /// </summary> /// <param name="ADate">The date to check.</param> /// <param name="ADescription">The name of the date value.</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <param name="AResultControl">Which <see cref="System.Windows.Forms.Control" /> is involved (can be null).</param> /// <remarks>Usage in the Data Validation Framework: rather than using this Method, use Method /// 'TSharedValidationControlHelper.IsNotInvalidDate' for checking the validity of dates as the latter can deal not only with /// empty dates, but dates that are invalid in other respects (e.g. exceeding a valid date range)!!!</remarks> /// <returns>Null if validation succeeded, otherwise a <see cref="TVerificationResult" /> is /// returned that contains details about the problem.</returns> public static TVerificationResult IsNotCorporateDateTime(DateTime?ADate, String ADescription, object AResultContext = null, System.Data.DataColumn AResultColumn = null, System.Windows.Forms.Control AResultControl = null) { TVerificationResult ReturnValue; DateTime TheDate = TSaveConvert.ObjectToDate(ADate); DateTime FirstOfMonth; String Description = THelper.NiceValueDescription(ADescription); if (!ADate.HasValue) { return(null); } FirstOfMonth = new DateTime(TheDate.Year, TheDate.Month, 1); // Checks if (TheDate == FirstOfMonth) { //MessageBox.Show('Date <> DateTime.MinValue'); ReturnValue = null; } else { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_INVALIDDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateMustNotBeLaterThanFirstDayOfMonth, new string[] { Description })); if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn, AResultControl); } } return(ReturnValue); }
/// <summary> /// Checks whether the date is within a specified date range. Null values are accepted. /// </summary> /// <remarks>This Method is capable of returning varying<see cref="TVerificationResult" /> objects! The objects /// returned are determined by the values specified for <paramref name="ALowerRangeCheckType" /> and /// <paramref name="AUpperRangeCheckType" />!</remarks> /// <param name="ADate">Date to check.</param> /// <param name="ALowerDateRangeEnd">Lower end of the valid Date Range.</param> /// <param name="AUpperDateRangeEnd">Upper end of the valid Date Range.</param> /// <param name="ADescription">Name of the date value.</param> /// <param name="ALowerRangeCheckType">Type of Date Check: lower end of the valid Date Range (defaults to <see cref="TDateBetweenDatesCheckType.dbdctUnspecific" />).</param> /// <param name="AUpperRangeCheckType">Type of Date Check: upper end of the valid Date Range (defaults to <see cref="TDateBetweenDatesCheckType.dbdctUnspecific" />).</param> /// <param name="AResultContext">Context of verification (can be null).</param> /// <param name="AResultColumn">Which <see cref="System.Data.DataColumn" /> failed (can be null).</param> /// <returns>Null if the date <paramref name="ADate" /> is between the lower and the upper end of the Date Range specified /// (lower and upper end dates are included), otherwise a verification result with a message that uses /// <paramref name="ADescription" />. /// </returns> public static TVerificationResult IsDateBetweenDates(DateTime?ADate, DateTime?ALowerDateRangeEnd, DateTime?AUpperDateRangeEnd, String ADescription, TDateBetweenDatesCheckType ALowerRangeCheckType = TDateBetweenDatesCheckType.dbdctUnspecific, TDateBetweenDatesCheckType AUpperRangeCheckType = TDateBetweenDatesCheckType.dbdctUnspecific, object AResultContext = null, System.Data.DataColumn AResultColumn = null) { TVerificationResult ReturnValue = null; DateTime TheDate = TSaveConvert.ObjectToDate(ADate); DateTime LowerDateRangeEndDate = TSaveConvert.ObjectToDate(ALowerDateRangeEnd); DateTime UpperDateRangeEndDate = TSaveConvert.ObjectToDate(AUpperDateRangeEnd); String Description = THelper.NiceValueDescription(ADescription); if ((!ADate.HasValue) || (!ALowerDateRangeEnd.HasValue) || (!AUpperDateRangeEnd.HasValue)) { return(null); } // Check if ((TheDate < LowerDateRangeEndDate) || (TheDate > UpperDateRangeEndDate)) { if ((ALowerRangeCheckType == TDateBetweenDatesCheckType.dbdctUnspecific) && (AUpperRangeCheckType == TDateBetweenDatesCheckType.dbdctUnspecific)) { ReturnValue = GetUnspecificDateRangeCheckVerificationResult(LowerDateRangeEndDate, UpperDateRangeEndDate, Description, AResultContext); } else if (TheDate < LowerDateRangeEndDate) { if (ALowerRangeCheckType == TDateBetweenDatesCheckType.dbdctNoPastDate) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NOPASTDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateMustNotBePastDate, new string[] { Description })); } else if (ALowerRangeCheckType == TDateBetweenDatesCheckType.dbdctUnrealisticDate) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_UNREALISTICDATE_ERROR, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateNotSensible, new string[] { Description })); } else { ReturnValue = GetUnspecificDateRangeCheckVerificationResult(LowerDateRangeEndDate, UpperDateRangeEndDate, Description, AResultContext); } } else if (TheDate > UpperDateRangeEndDate) { if (AUpperRangeCheckType == TDateBetweenDatesCheckType.dbdctNoFutureDate) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_NOFUTUREDATE, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateMustNotBeFutureDate, new string[] { Description })); } else if (AUpperRangeCheckType == TDateBetweenDatesCheckType.dbdctUnrealisticDate) { ReturnValue = new TVerificationResult(AResultContext, ErrorCodes.GetErrorInfo(CommonErrorCodes.ERR_UNREALISTICDATE_ERROR, CommonResourcestrings.StrInvalidDateEntered + Environment.NewLine + StrDateNotSensible, new string[] { Description })); } else { ReturnValue = GetUnspecificDateRangeCheckVerificationResult(LowerDateRangeEndDate, UpperDateRangeEndDate, Description, AResultContext); } } if (AResultColumn != null) { ReturnValue = new TScreenVerificationResult(ReturnValue, AResultColumn); } } else { ReturnValue = null; } return(ReturnValue); }