Beispiel #1
0
        private DataTable GetSource(string ttbSearch, string rblAtSchool)
        {
            DataTable table2 = DataSourceUtil.GetDataTable2();

            DataView view2 = table2.DefaultView;

            List <string> filters = new List <string>();

            if (!String.IsNullOrEmpty(ttbSearch))
            {
                // RowFilter的用法:http://www.csharp-examples.net/dataview-rowfilter/
                filters.Add(String.Format("Name LIKE '*{0}*'", DataSourceUtil.EscapeLikeValue(ttbSearch)));
            }


            if (rblAtSchool != "-1")
            {
                filters.Add(String.Format("AtSchool = {0}", rblAtSchool));
            }

            if (filters.Count > 0)
            {
                // RowFilter的用法:http://www.csharp-examples.net/dataview-rowfilter/
                view2.RowFilter = String.Join(" AND ", filters.ToArray());
            }

            return(view2.ToTable());
        }
Beispiel #2
0
        private DataTable GetSource(string ddlAtSchool, JArray filteredData)
        {
            DataTable table2 = DataSourceUtil.GetDataTable2();

            DataView view2 = table2.DefaultView;

            List <string> filters = new List <string>();

            // 表格工具栏中的下拉列表过滤项
            if (ddlAtSchool != "-1")
            {
                filters.Add(String.Format("AtSchool = {0}", ddlAtSchool));
            }

            // 表头菜单的过滤项
            if (filteredData != null && filteredData.Count > 0)
            {
                foreach (JObject filteredObj in filteredData)
                {
                    // 本过滤项是[所学专业]列的过滤项
                    string columnID = filteredObj.Value <string>("column");

                    if (columnID == "Major")
                    {
                        JObject item         = filteredObj.Value <JObject>("item");
                        string  itemOperator = item.Value <string>("operator");
                        string  itemValue    = item.Value <string>("value");

                        if (!String.IsNullOrEmpty(itemValue))
                        {
                            string escapedValue = DataSourceUtil.EscapeLikeValue(itemValue);
                            if (itemOperator == "equal")
                            {
                                filters.Add(String.Format("Major = '{0}'", escapedValue));
                            }
                            else if (itemOperator == "contain")
                            {
                                filters.Add(String.Format("Major LIKE '*{0}*'", escapedValue));
                            }
                            else if (itemOperator == "start")
                            {
                                filters.Add(String.Format("Major LIKE '{0}*'", escapedValue));
                            }
                            else if (itemOperator == "end")
                            {
                                filters.Add(String.Format("Major LIKE '*{0}'", escapedValue));
                            }
                        }
                    }
                }
            }

            if (filters.Count > 0)
            {
                // RowFilter的用法:http://www.csharp-examples.net/dataview-rowfilter/
                view2.RowFilter = String.Join(" AND ", filters.ToArray());
            }

            return(view2.ToTable());
        }