Exemplo n.º 1
0
        /// <summary>
        /// 解析過濾條件中的系統變數
        /// </summary>
        /// <returns></returns>
        public GFilterItemCollection ParseVariable()
        {
            GFilterItemCollection oItems;
            GFilterItem           oItem;

            oItems = new GFilterItemCollection();
            foreach (GFilterItem item in this.FilterItems)
            {
                if (item.ComparisonOperator == EComparisonOperator.Variable)
                {
                    oItem = ConvertItemForVariable(item);
                }
                else
                {
                    oItem = item.Clone();
                }

                if (BaseFunc.IsNotNull(oItem))
                {
                    oItems.Add(oItem);
                }
            }

            // 移除無查詢值的條件
            oItems.RemoveEmpty();
            return(oItems);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 建立物件複本
        /// </summary>
        /// <returns></returns>
        public GFilterItemCollection Clone()
        {
            GFilterItemCollection items = new GFilterItemCollection();

            foreach (GFilterItem item in this)
            {
                items.Add(item.Clone());
            }
            return(items);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 加入成員。
        /// </summary>
        /// <param name="items">過濾條件項目集合。</param>
        public void Add(GFilterItemCollection items)
        {
            // 集合無資料則離開
            if (BaseFunc.IsEmpty(items))
            {
                return;
            }

            foreach (GFilterItem oItem in items)
            {
                Add(oItem);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 解析並移除不需要的 [欄位變數] 過濾條件。
        /// </summary>
        /// <param name="programDefine">程式定義。</param>
        public GFilterItemCollection ParseRemoveField(GProgramDefine programDefine)
        {
            GFilterItemCollection oFilterItems;
            GFilterItem           oFilterItem;
            GFieldDefine          oFieldDefine;
            EVariableType         oVariableType;
            string sTableName;
            string sFieldName;

            oFilterItems = new GFilterItemCollection();
            foreach (GFilterItem item in this.FilterItems)
            {
                // 產生過濾條件複本
                oFilterItem = item.Clone();
                // 解析變數值
                this.VariableParser.Parse(item.FilterValue);
                // 變數類型
                oVariableType = this.VariableParser.VariableType;

                if (oVariableType == EVariableType.Field || oVariableType == EVariableType.TableField)
                {
                    // 拆解字串的資料表名稱及欄位名稱
                    StrFunc.StrSplitFieldName(this.VariableParser.Value, out sTableName, out sFieldName);
                    if (StrFunc.StrIsEmpty(sTableName))
                    {
                        sTableName = programDefine.ProgID;
                    }
                    // 只保留存在的 [欄位變數] 過濾條件
                    oFieldDefine = programDefine.FindField(sTableName, sFieldName);
                    if (BaseFunc.IsNotNull(oFieldDefine))
                    {
                        oFilterItems.Add(oFilterItem);
                    }
                }
                else
                {
                    // 加入非 [欄位變數] 過濾條件
                    oFilterItems.Add(oFilterItem);
                }
            }

            // 移除無查詢值的條件
            oFilterItems.RemoveEmpty();
            return(oFilterItems);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 解析並移除 [欄位變數] 過濾條件,GridFilter 無資料集故需移除欄位變數。
        /// </summary>
        public GFilterItemCollection ParseRemoveField()
        {
            GFilterItemCollection oFilterItems;

            oFilterItems = new GFilterItemCollection();
            foreach (GFilterItem item in this.FilterItems)
            {
                // 解析變數值
                this.VariableParser.Parse(item.FilterValue);
                // 只保留系統變數及常數類型的過濾條件
                if (this.VariableParser.VariableType == EVariableType.Variable ||
                    this.VariableParser.VariableType == EVariableType.Constant)
                {
                    oFilterItems.Add(item.Clone());
                }
            }
            return(oFilterItems);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 結合新的資料過濾條件項目集合。
        /// </summary>
        /// <param name="filterItems">欲結合的資料過濾條件項目集合</param>
        /// <param name="changeGroupNumber">改變條件群組編號</param>
        public void CombineFilterItems(GFilterItemCollection filterItems, bool changeGroupNumber = false)
        {
            if (changeGroupNumber)
            {
                foreach (GFilterItem item in this)
                {
                    item.GroupNumber += 1;
                }
            }

            foreach (GFilterItem item in filterItems)
            {
                if (!this.Contains(item))
                {
                    this.Add(item.Clone());
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 解析過濾條件中的欄位變數。
        /// </summary>
        /// <param name="dataSet">資料集。</param>
        /// <param name="tableName">作用資料表名稱。</param>
        /// <param name="rowIndex">作用資料列索引。</param>
        public GFilterItemCollection ParseField(DataSet dataSet, string tableName, int rowIndex)
        {
            var oFilterItems = new GFilterItemCollection();

            foreach (GFilterItem item in this.FilterItems)
            {
                // 產生過濾條件複本
                var oFilterItem = item.Clone();
                // 解析變數值
                this.VariableParser.Parse(item.FilterValue);
                // 變數類型
                var oVariableType = this.VariableParser.VariableType;
                // 取得欄位變數的值
                if (oVariableType == EVariableType.Field || oVariableType == EVariableType.TableField)
                {
                    // 拆解字串的資料表名稱及欄位名稱
                    StrFunc.StrSplitFieldName(this.VariableParser.Value, out string sTableName, out string sFieldName);
                    if (StrFunc.StrIsEmpty(sTableName))
                    {
                        sTableName = tableName;
                    }
                    // 取得作用資料列
                    var oRow = GetDataRow(dataSet, sTableName, sFieldName, rowIndex);
                    if (BaseFunc.IsNotNull(oRow))
                    {
                        oFilterItem.FilterValue = BaseFunc.CStr(oRow[sFieldName]);
                    }
                    else
                    {
                        oFilterItem.FilterValue = string.Empty;
                    }
                }
                oFilterItems.Add(oFilterItem);
            }

            // 移除無查詢值的條件
            oFilterItems.RemoveEmpty();
            return(oFilterItems);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 建構函式。
 /// </summary>
 /// <param name="sessionInfo">連線資訊。</param>
 /// <param name="filterItems">過濾條件集合。</param>
 public GFilterItemsParser(GSessionInfo sessionInfo, GFilterItemCollection filterItems)
 {
     FilterItems = filterItems;
     SessionInfo = sessionInfo;
 }