Esempio n. 1
0
 public void SetupSearchProperties(SearchInfo criteria)
 {
     criteria.PropertyName = SelectedProperty.Name;
     if (Child != null && Child.SelectedProperty != null)
     {
         criteria.Next          = SearchInfo.Make(Child.ParentType);
         criteria.Next.Operator = QueryOperator.Or;
         criteria.Next.Previous = criteria;
         Child.SetupSearchProperties(criteria.Next);
     }
 }
Esempio n. 2
0
        public SearchInfo BuildSearchInfo(bool gettingValuesOnly = false)
        {
            if (!OrderByCriteria && !(PropertySelect.SelectedIndex >= 0 && ComparerSelect.SelectedIndex >= 0))
            {
                return(null);
            }

            if (OrderByCriteria && Controls.Contains(ComparerSelect) && ComparerSelect.SelectedIndex < 0)
            {
                return(null);
            }

            SearchInfo criteria = SearchInfo.Make(PropertySelect.ParentType);

            criteria.Operator = (QueryOperator)QueryOperatorSelect.SelectedItem;

            //build property
            PropertySelect.SetupSearchProperties(criteria);

            //build comparer
            if (OrderByCriteria)
            {
                if (OrderBySelect.Text == "Descending")
                {
                    criteria.OrderByDescending = true;
                }

                if (Controls.Contains(ComparerSelect))
                {
                    criteria.SetupOrderByComparers((QueryComparer)ComparerSelect.SelectedItem);
                }
                else if (PropertySelect.GetLowestPropertyType().IsGenericType)
                {
                    criteria.SetupOrderByComparers(QueryComparer.All);
                }
            }
            else
            {
                criteria.SetupComparers((QueryComparer)ComparerSelect.SelectedItem);//  SearchProperty.StringToComparer(ComparerSelect.Text));
            }

            //build value
            if (PropertySelect.GetLowestPropertyType() == typeof(int) || PropertySelect.GetLowestPropertyType() == typeof(List <int>) || PropertySelect.GetLowestPropertyType().IsGenericType)
            {
                if (Controls.Contains(ValueSelect) && !gettingValuesOnly)
                {
                    try
                    {
                        criteria.SetupValue(Convert.ToInt32(ValueSelect.Text));
                    }
                    catch { return(null); }
                }
                else
                {
                    criteria.SetupValue(0);
                }
            }
            else if (PropertySelect.GetLowestPropertyType() == typeof(double) || PropertySelect.GetLowestPropertyType() == typeof(List <double>))
            {
                if (Controls.Contains(ValueSelect) && !gettingValuesOnly)
                {
                    try
                    {
                        criteria.SetupValue(double.Parse(ValueSelect.Text));// Convert.ToDouble(ValueSelect.Text));
                    }
                    catch { return(null); }
                }
            }
            else if (ValueSelect.DropDownStyle == ComboBoxStyle.DropDownList)
            {
                criteria.SetupValue(ValueSelect.SelectedItem);
            }
            else
            {
                criteria.SetupValue(ValueSelect.Text);
            }

            return(criteria);
        }