/// <summary> /// Determines whether the filter's comparison type and filter compare value(s) evaluates to true for the specified value /// </summary> /// <param name="filterValues">The filter values.</param> /// <param name="value">The value.</param> /// <returns> /// <c>true</c> if [is compared to value] [the specified filter values]; otherwise, <c>false</c>. /// </returns> public override bool IsComparedToValue(List <string> filterValues, string value) { if (filterValues == null || filterValues.Count < 2) { return(false); } ComparisonType?filterComparisonType = filterValues[0].ConvertToEnumOrNull <ComparisonType>(); ComparisonType?equalToCompareValue = GetEqualToCompareValue().ConvertToEnumOrNull <ComparisonType>(); DateTime? valueAsDateTime = value.AsDateTime(); // uses Tab Delimited since slidingDateRangePicker is | delimited var filterValueValues = filterValues[1].Split(new string[] { "\t" }, StringSplitOptions.None); // Parse for RelativeValue of DateTime (if specified) filterValueValues[0] = ParseRelativeValue(filterValueValues[0]); DateTime?filterValueAsDateTime1; DateTime?filterValueAsDateTime2 = null; if (filterComparisonType == ComparisonType.Between) { var dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues(filterValueValues[1]); filterValueAsDateTime1 = dateRange.Start; filterValueAsDateTime2 = dateRange.End; } else { filterValueAsDateTime1 = filterValueValues[0].AsDateTime(); filterValueAsDateTime2 = null; } return(ComparisonHelper.CompareNumericValues(filterComparisonType.Value, valueAsDateTime?.Ticks, filterValueAsDateTime1?.Ticks, filterValueAsDateTime2?.Ticks)); }
/// <summary> /// Determines whether the filter's comparison type and filter compare value(s) evaluates to true for the specified value /// </summary> /// <param name="filterValues">The filter values.</param> /// <param name="value">The value.</param> /// <returns> /// <c>true</c> if [is compared to value] [the specified filter values]; otherwise, <c>false</c>. /// </returns> public override bool IsComparedToValue(List <string> filterValues, string value) { if (filterValues == null || filterValues.Count < 2) { return(false); } ComparisonType?filterComparisonType = filterValues[0].ConvertToEnumOrNull <ComparisonType>(); ComparisonType?equalToCompareValue = GetEqualToCompareValue().ConvertToEnumOrNull <ComparisonType>(); var filterValueAsDecimal = filterValues[1].AsDecimalOrNull(); var valueAsDecimal = value.AsDecimalOrNull(); return(ComparisonHelper.CompareNumericValues(filterComparisonType.Value, valueAsDecimal, filterValueAsDecimal, null)); }
/// <summary> /// Gets the grid field. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override DataControlField GetGridField(Type entityType, string selection) { ComparisonType comparisonType; decimal totalAmountCutoff; string[] selectionValues = selection.Split('|'); if (selectionValues.Length < 2) { // shouldn't happen, but just in case, just do the default comparisonType = ComparisonType.GreaterThanOrEqualTo; totalAmountCutoff = 0.00M; } else { comparisonType = selectionValues[0].ConvertToEnum <ComparisonType>(ComparisonType.GreaterThanOrEqualTo); totalAmountCutoff = selectionValues[1].AsDecimalOrNull() ?? 0.00M; } // if it is just greater than or equal to 0, they want to show total giving, regardless of amount // so there is no need to do the comparison logic bool skipComparison = (comparisonType == ComparisonType.GreaterThanOrEqualTo && totalAmountCutoff == 0.00M); var callbackField = new CallbackField(); callbackField.ItemStyle.HorizontalAlign = HorizontalAlign.Right; callbackField.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; callbackField.OnFormatDataValue += (sender, e) => { decimal?totalGiving = e.DataValue as decimal?; if (!totalGiving.HasValue || totalGiving.Value == 0.00M) { e.FormattedValue = string.Empty; } else if (skipComparison || ComparisonHelper.CompareNumericValues(comparisonType, totalGiving, totalAmountCutoff)) { // it meets the comparison criteria, so display total amount e.FormattedValue = totalGiving?.FormatAsCurrency(); } else { // if the total giving is an amount that doesn't meet the comparison criteria, show blank e.FormattedValue = string.Empty; } }; return(callbackField); }