Exemple #1
0
        /// <summary>
        /// Updates the selected date with the text box text.
        /// </summary>
        private void UpdateSelectedDate()
        {
            if (this.textBox != null)
            {
                CuiDate cuiDate = null;
                if (CuiDate.TryParseExact(this.textBox.Text, out cuiDate, CultureInfo.CurrentCulture))
                {
                }
                else if (CuiDate.IsAddValid(this.textBox.Text))
                {
                    cuiDate = CuiDate.Add(new CuiDate(DateTime.Now), this.textBox.Text);
                }

                if (cuiDate != null && !cuiDate.IsNull && cuiDate.ToString().Length >= 11 && (!this.SelectedDate.HasValue || cuiDate.DateValue != this.SelectedDate.Value.Date))
                {
                    this.SelectedDate = cuiDate.DateValue;
                }

                this.textBox.Text = this.SelectedDateText;
            }
        }