Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchConditions"></param>
        /// <param name="searchOrders"></param>
        public virtual void FillSearchConditions(IList <ISearchExpression> searchConditions, IList <ISearchOrder> searchOrders)
        {
            if (Order.HasValue)
            {
                if (Order.Value)
                {
                    searchOrders.Add(SearchOrder.Asc(PropertyNameToSearch));
                }
                else
                {
                    searchOrders.Add(SearchOrder.Desc(PropertyNameToSearch));
                }
            }

            if (IsNull)
            {
                if (!IsNot)
                {
                    //// 对帐单.对账单号 为空,其实意义就是对帐单为空
                    //if (string.IsNullOrEmpty(this.Navigator))
                    //{
                    //    searchConditions.Add(SearchExpression.IsNull(PropertyNameToSearch));
                    //}
                    //else
                    //{
                    //    // 为空的话,只去最前面一个
                    //    string[] ss = this.Navigator.Split(new char[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries);
                    //    searchConditions.Add(SearchExpression.IsNull(ss[0]));
                    //}
                    if (SearchNullUseFull || string.IsNullOrEmpty(this.Navigator))
                    {
                        searchConditions.Add(SearchExpression.IsNull(PropertyNameToSearch));
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(this.Navigator))
                        {
                            throw new ArgumentException("When SearchNullUseFull is false, it will use Navigator's first part, so navigator must not null!");
                        }
                        string[] ss = this.Navigator.Split(new char[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries);
                        searchConditions.Add(SearchExpression.IsNull(ss[0]));
                    }
                }
                else
                {
                    searchConditions.Add(SearchExpression.IsNotNull(PropertyNameToSearch));
                }
            }
            else
            {
                IMultiDataValueControl mdc = this.Control as IMultiDataValueControl;
                if (mdc != null)
                {
                    if (this.SelectedDataValues.Count == 0)
                    {
                        return;
                    }

                    if (!this.UseFuzzySearch.HasValue)
                    {
                        if (this.CanSelectFuzzySearch && mdc.SelectedDataValues.Count == 1)
                        {
                            if (!IsNot)
                            {
                                searchConditions.Add(SearchExpression.Like(PropertyNameToSearch, mdc.SelectedDataValues[0]));
                            }
                            else
                            {
                                searchConditions.Add(SearchExpression.NotLike(PropertyNameToSearch, mdc.SelectedDataValues[0]));
                            }
                        }
                        else
                        {
                            if (!IsNot)
                            {
                                searchConditions.Add(SearchExpression.InG(PropertyNameToSearch, mdc.SelectedDataValues));
                            }
                            else
                            {
                                searchConditions.Add(SearchExpression.NotInG(PropertyNameToSearch, mdc.SelectedDataValues));
                            }
                        }
                    }
                    else if (this.UseFuzzySearch.Value)
                    {
                        if (!IsNot)
                        {
                            searchConditions.Add(SearchExpression.GInG(PropertyNameToSearch, mdc.SelectedDataValues));
                        }
                        else
                        {
                            searchConditions.Add(SearchExpression.NotGInG(PropertyNameToSearch, mdc.SelectedDataValues));
                        }
                    }
                    else
                    {
                        if (!IsNot)
                        {
                            searchConditions.Add(SearchExpression.InG(PropertyNameToSearch, mdc.SelectedDataValues));
                        }
                        else
                        {
                            searchConditions.Add(SearchExpression.NotInG(PropertyNameToSearch, mdc.SelectedDataValues));
                        }
                    }
                }
                else
                {
                    if (this.SelectedDataValue == null)
                    {
                        return;
                    }

                    if (this.CanSelectFuzzySearch && (!this.UseFuzzySearch.HasValue || this.UseFuzzySearch.Value))
                    {
                        string s = this.SelectedDataValue.ToString();
                        if (!IsNot)
                        {
                            searchConditions.Add(SearchExpression.Like(PropertyNameToSearch, s));
                        }
                        else
                        {
                            searchConditions.Add(SearchExpression.NotLike(PropertyNameToSearch, s));
                        }
                    }
                    else
                    {
                        if (!IsNot)
                        {
                            searchConditions.Add(SearchExpression.Eq(PropertyNameToSearch, this.SelectedDataValue));
                        }
                        else
                        {
                            searchConditions.Add(SearchExpression.NotEq(PropertyNameToSearch, this.SelectedDataValue));
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(this.AdditionalSearchExpression))
            {
                searchConditions.Add(SearchExpression.Parse(this.AdditionalSearchExpression));
            }
        }