/// <summary> /// Sets the initial values of the controls for a date range bound. /// </summary> /// <param name="bound">The bound to load</param> /// <param name="rangeBoundList">The main range bound list.</param> /// <param name="specificDatePicker">The picker for the specific date.</param> /// <param name="windowAmountTextBox">The text box for the window amount.</param> /// <param name="windowIntervalList">The window interval list.</param> private void LoadBoundSettings(DateRangeBound bound, ListControl rangeBoundList, RadDatePicker specificDatePicker, RadNumericTextBox windowAmountTextBox, ListControl windowIntervalList) { Utility.LocalizeListControl(rangeBoundList, this.LocalResourceFile); Utility.LocalizeListControl(windowIntervalList, this.LocalResourceFile); SelectListValue(rangeBoundList, DateRangeBoundJsonTransferObject.GetListValueForBound(bound)); if (bound.IsSpecificDate) { specificDatePicker.SelectedDate = bound.SpecificDate; } else if (bound.IsWindow) { windowAmountTextBox.Value = bound.WindowAmount; SelectListValue(windowIntervalList, bound.WindowInterval.Value.ToString()); } }
public object FormatDateRange(DateRangeBoundJsonTransferObject start, DateRangeBoundJsonTransferObject end) { DateRangeBound startRangeBound; DateRangeBound endRangeBound; try { startRangeBound = DateRangeBound.Parse(start.value, start.specificDate, start.windowAmount, start.windowInterval); endRangeBound = DateRangeBound.Parse(end.value, end.specificDate, end.windowAmount, end.windowInterval); } catch (ArgumentNullException exc) { return new { isError = true, message = Localization.GetString("Missing " + exc.ParamName, ResourceFileRoot) }; } var dateRange = new DateRange(startRangeBound, endRangeBound); if (!string.IsNullOrEmpty(dateRange.ErrorMessage)) { return new { isError = true, message = Localization.GetString(dateRange.ErrorMessage, ResourceFileRoot) }; } var dateRangeResourceKey = startRangeBound.IsUnbounded && endRangeBound.IsUnbounded ? "Date Range Without Bounds.Text" : startRangeBound.IsUnbounded ? "Date Range Without Start.Format" : endRangeBound.IsUnbounded ? "Date Range Without End.Format" : "Date Range.Format"; var dateRangeText = string.Format( CultureInfo.CurrentCulture, Localization.GetString(dateRangeResourceKey, ResourceFileRoot), dateRange.GetStartDate(), dateRange.GetEndDate()); #if DEBUG dateRangeText = dateRangeText.Replace("[L]", string.Empty); #endif return new { isError = false, message = dateRangeText }; }