Пример #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);
        }
Пример #2
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);
        }
Пример #3
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);
        }