Пример #1
0
        private void OnValueSelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!throwevent)
            {
                return;
            }
            bool added = false;

            if (this.ValueDatePicker.SelectedDate.HasValue)
            {
                if (this.PeriodItem == null)
                {
                    this.PeriodItem = new PeriodItem(Index - 1);
                    added           = true;
                }
                this.PeriodItem.value = this.ValueDatePicker.SelectedDate.Value.ToShortDateString();
                this.PeriodItem.operationGranularity = this.granulartityComBox.SelectedItem.ToString();
                if (string.IsNullOrEmpty(this.PeriodItem.operationDate))
                {
                    String sign = this.SignComboBox.SelectedItem.ToString();
                    if (DateOperator.getBySign(sign) != null)
                    {
                        this.PeriodItem.operationDate = DateOperator.getBySign(sign).name;
                    }
                }
                if (!string.IsNullOrEmpty(this.numberValueTextBox.Text))
                {
                    bool isValid = TagFormulaUtil.isSyntaxeFormulaCorrectly(this.numberValueTextBox.Text);
                    if (!isValid)
                    {
                        int result;
                        isValid = int.TryParse(this.numberValueTextBox.Text, out result);
                    }
                    this.PeriodItem.operationNumber = isValid ? this.numberValueTextBox.Text : "";
                }
                this.PeriodItem.operation = this.operationComboBox.SelectedItem.ToString();
            }
            else
            {
                this.PeriodItem.value = null;
            }
            if (Added != null && added && update)
            {
                Added(this);
            }
            else if (Updated != null && update)
            {
                Updated(this);
            }
        }
Пример #2
0
        private void OnValidateFormula(object sender, KeyEventArgs e)
        {
            if (!throwevent)
            {
                return;
            }
            if (this.PeriodItem == null)
            {
                this.PeriodItem = new PeriodItem(Index - 1);
            }
            if (ValueDatePicker.SelectedDate.HasValue)
            {
                this.PeriodItem.valueDateTime = ValueDatePicker.SelectedDate.Value;
            }

            this.PeriodItem.operationGranularity = this.granulartityComBox.SelectedItem.ToString();
            if (string.IsNullOrEmpty(this.PeriodItem.operationDate))
            {
                String sign = this.SignComboBox.SelectedItem.ToString();
                if (DateOperator.getBySign(sign) != null)
                {
                    this.PeriodItem.operationDate = DateOperator.getBySign(sign).name;
                }
            }
            if (!string.IsNullOrEmpty(this.numberValueTextBox.Text))
            {
                bool isValid = TagFormulaUtil.isSyntaxeFormulaCorrectly(this.numberValueTextBox.Text);
                if (!isValid)
                {
                    int result;
                    isValid = int.TryParse(this.numberValueTextBox.Text, out result);
                }
                this.PeriodItem.operationNumber = isValid ? this.numberValueTextBox.Text : "";
            }
            this.PeriodItem.operation = this.operationComboBox.SelectedItem.ToString();

            this.PeriodItem.formula = FormulaTextBox.Text.Trim().ToUpper();
            if (e.Key == Key.Enter && ValidateFormula != null && update)
            {
                ValidateFormula(this);
            }
        }
Пример #3
0
        /// <summary>
        /// Returns an SQL Date clause given an operator and two dates.
        /// Probably belongs in common.
        /// </summary>
        /// <param name="aDateOperator">A date operator.</param>
        /// <param name="aDate1">A date1.</param>
        /// <param name="aDate2">A date2.</param>
        /// <returns></returns>
        public static string DateClause(DateOperator aDateOperator, DateTime aDate1, DateTime aDate2)
        {
            string vWork = null;

            switch (aDateOperator)
            {
            case DateOperator.LessThan:
                vWork = String.Format("< '{0}'", aDate1.SortFormatStartOfDay());
                break;

            case DateOperator.LessEqual:
                vWork = String.Format("<= '{0}'", aDate1.SortFormatEndOfDay());
                break;

            case DateOperator.GreaterThan:
                vWork = String.Format("> '{0}'", aDate1.SortFormatEndOfDay());
                break;

            case DateOperator.GreaterEqual:
                vWork = String.Format(">= '{0}'", aDate1.SortFormatStartOfDay());
                break;

            case DateOperator.Equal:
                vWork = String.Format("between '{0}' and '{1}'", aDate1.SortFormatStartOfDay(), aDate1.SortFormatEndOfDay());
                break;

            case DateOperator.Between:
                vWork = String.Format("between '{0}' and '{1}'", aDate1.SortFormatStartOfDay(), aDate2.SortFormatEndOfDay());
                break;

            default:
                vWork = String.Format("between '{0}' and '{1}'", aDate1.SortFormatStartOfDay(), aDate1.SortFormatEndOfDay());
                break;
            }
            return(vWork);
        }