示例#1
0
 /// <summary>
 /// Update a SearchCriterion with a list of values
 /// multiselect must be true
 /// </summary>
 /// <remarks></remarks>
 /// <seealso cref=""/>
 /// <param name="name"></param>
 /// <param name="values"></param>
 /// <param name="multiSelect"></param>
 /// <param name="range"></param>
 /// <param name="dataType"></param>
 public void Update(SearchComponentBase scb, List <string> values, bool multiSelect = true, string valueSearchOperation = "OR")
 {
     //1. prüfe ob name in list vorhanden
     if (ContainsSearchCriterion(scb.Name, scb.Type))
     {
         SearchCriterion sco = Get(scb.Name, scb.Type);
         //2. check if MultiSelect
         if (multiSelect)
         {
             if (values.Count > 0)
             {
                 sco.Values = values;
             }
             else
             {
                 SearchCriteriaList.Remove(sco);
             }
         }
     }
     else
     {
         //wenn nicht vorhanden dann füge hinzu
         if (values.Count > 0)
         {
             SearchCriteriaList.Add(new SearchCriterion(values, multiSelect, valueSearchOperation, scb));
         }
     }
 }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks></remarks>
 /// <seealso cref=""/>
 /// <param name="name"></param>
 /// <param name="value"></param>
 public void RemoveValueOfSearchCriteria(string name, string value)
 {
     if (ContainsSearchCriterion(name, value))
     {
         SearchCriterion sco = Get(name, value);
         if (sco != null)
         {
             sco.Values.Remove(value);
             if (sco.Values.Count() == 0)
             {
                 SearchCriteriaList.Remove(sco);
             }
         }
     }
 }
示例#3
0
        /// <summary>
        /// Update a SearchCriterion with one value
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <param name="multiSelect"></param>
        /// <param name="range"></param>
        /// <param name="dataType"></param>
        public void Update(SearchComponentBase scb, string value, bool multiSelect = false, string valueSearchOperation = "OR")
        {
            //1. prüfe ob name in list vorhanden
            if (ContainsSearchCriterion(scb.Name, scb.Type))
            {
                SearchCriterion sco = Get(scb.Name, scb.Type);

                //2. check if MultiSelect
                if (multiSelect)
                {
                    // diffferent values can be in  the list
                    // if the values is in the list remove the value
                    if (sco.Values.Contains(value))
                    {
                        sco.Values.Remove(value);
                        if (sco.Values.Count() == 0)
                        {
                            SearchCriteriaList.Remove(sco);
                        }
                    }
                    // else add value to the list
                    else
                    {
                        sco.Values.Add(value);
                    }
                }
                else
                {
                    // override values of SearchCriterion if not multiselect
                    // or remove if values contains this value
                    if (sco.Values.Contains(value))
                    {
                        sco.Values.Clear();
                        SearchCriteriaList.Remove(sco);
                    }
                    else
                    {
                        sco.Values.Clear();

                        bool isDefault = false;
                        if (scb is Property)
                        {
                            Property p = (Property)scb;
                            if (p.DefaultValue == value)
                            {
                                isDefault = true;
                            }
                        }

                        if (!isDefault)
                        {
                            sco.Values.Clear();
                            if (!String.IsNullOrEmpty(value))
                            {
                                sco.Values.Add(value);
                            }
                            else
                            {
                                SearchCriteriaList.Remove(sco);
                            }
                        }
                        else
                        {
                            SearchCriteriaList.Remove(sco);
                        }
                    }
                }
            }
            else
            {
                //wenn nicht vorhanden dann füge hinzu
                if (scb != null && !String.IsNullOrEmpty(value))
                {
                    SearchCriteriaList.Add(new SearchCriterion(value, multiSelect, valueSearchOperation, scb));
                }
            }
        }