Beispiel #1
0
        private void DateRangeValueEditor_Load(object sender, EventArgs e)
        {
            inputDateRangeControl.ClearDateRanges();
            foreach (var dateRange in DateRanges)
            {
                inputDateRangeControl.AddDateRangeType((InputDateRangeControlType)dateRange,
                                                       IQDateRangeElement.GetRangeDisplayName(dateRange));
            }

            if (Value == null || Value.Value == null)
            {
                // If no current value is provided, select the first element from the available ranges list
                if (DateRanges.Count > 0)
                {
                    inputDateRangeControl.DateRange = new InputDateRangeValue((InputDateRangeControlType)DateRanges[0]);
                }
                return;
            }

            DateTime?startDate = Value.Value.StartDate;
            DateTime?endDate   = Value.Value.EndDate;

            if (Value.RangeType != (int)InputDateRangeControlType.SpecificDates)
            {
                // If the current range is not 'specific dates' we need to set the start and end dates to 'today',
                // so that if the user selects 'specific dates' the default start and end dates are correctly initialized
                startDate = DateTime.Now.Date;
                endDate   = DateTime.Now.Date;
            }

            // DR 46097: Remove the 'time' part of the datetime value so that it doesn't mess up
            // the calculation of the new start and end dates by the input date range control
            if (startDate.HasValue)
            {
                startDate = startDate.Value.Date;
            }
            if (endDate.HasValue)
            {
                endDate = endDate.Value.Date;
            }

            inputDateRangeControl.DateRange = new InputDateRangeValue(
                (InputDateRangeControlType)Value.RangeType, startDate, endDate, Value.PeriodCount);
        }
Beispiel #2
0
 public override string ToString()
 {
     return(IQDateRangeElement.GetRangeDisplayName(RangeType));
 }