예제 #1
0
        internal static IEnumerable <ITreeNode> SelectData(TableSelector selector, ITreeNodeCreator creator,
                                                           Action action, string stateId)
        {
            DataTable table = selector.HostTable;
            int       start = table == null ? 0 : table.Rows.Count;

            action();
            if (table == null)
            {
                table = selector.HostTable;
            }
            int end = table.Rows.Count;

            for (int i = start; i < end; i++)
            {
                DataRow         row  = table.Rows[i];
                DataRowTreeNode node = creator.CreateNode(row);
                if (node.Id == stateId)
                {
                    node.State = new TreeNodeState {
                        Opened = true, Selected = true
                    };
                }
                yield return(node);
            }
        }
예제 #2
0
        public static void SetFakeDelete(TableSelector selector, ITableScheme scheme)
        {
            Tk5DataXml dataXml = scheme as Tk5DataXml;

            if (dataXml != null)
            {
                selector.FakeDelete = dataXml.FakeDeleteInfo;
            }
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the FilledListEventArgs class.
 /// </summary>
 public FilledListEventArgs(bool isPost, int pageNumber, int pageSize, int count,
                            string order, TableSelector listView, Object postObject, IParamBuilder condition)
 {
     IsPost     = isPost;
     PageNumber = pageNumber;
     PageSize   = pageSize;
     Count      = count;
     Order      = order;
     ListView   = listView;
     PostObject = postObject;
     Condition  = condition;
 }
예제 #4
0
        internal static ITreeNode GetTreeNode(TableSelector selector, ITreeNodeCreator creator, string id)
        {
            TkDebug.AssertArgumentNullOrEmpty(id, "id", creator);

            DataRow row = selector.TrySelectRowWithKeys(id);

            if (row == null)
            {
                return(null);
            }
            return(creator.CreateNode(row));
        }
예제 #5
0
        internal static IParamBuilder GetLevelBuilder(TableSelector selector,
                                                      LevelTreeDefinition treeDef, int level, string value, ILevelProvider provider)
        {
            IParamBuilder[] builders = new IParamBuilder[level + 1];
            IFieldInfo      idField  = selector.GetFieldInfo(treeDef.IdField);

            for (int i = 0; i <= level; ++i)
            {
                string likeValue = provider.GetSqlLikeValue(treeDef, i, value);
                builders[i] = SqlParamBuilder.CreateSingleSql(selector.Context, idField, "LIKE",
                                                              treeDef.IdField + i, likeValue);
            }
            IParamBuilder builder = SqlParamBuilder.CreateParamBuilderWithOr(builders);

            return(builder);
        }
예제 #6
0
        public static FieldListOrder FromSqlString(TableSelector selector, string orderBy)
        {
            FieldListOrder result = new FieldListOrder();

            if (string.IsNullOrEmpty(orderBy))
            {
                return(result);
            }

            orderBy = orderBy.Trim();
            if (orderBy.StartsWith("order by", StringComparison.OrdinalIgnoreCase))
            {
                orderBy = orderBy.Substring(8).Trim();
            }
            string[] items     = orderBy.Split(',');
            var      fieldList = selector.FieldList;

            foreach (var item in items)
            {
                var fieldInfo = fieldList.FirstOrDefault(field =>
                                                         item.IndexOf(field.FieldName, StringComparison.Ordinal) != -1);
                if (fieldInfo != null)
                {
                    DbOrder order;
                    if (item.IndexOf("DESC", StringComparison.OrdinalIgnoreCase) != -1)
                    {
                        order = DbOrder.Desc;
                    }
                    else
                    {
                        order = DbOrder.Asc;
                    }
                    result.FieldList.Add(new FieldOrder(fieldInfo.NickName, order));
                }
            }
            return(result);
        }
예제 #7
0
        internal static IParamBuilder GetValueBuilder(TableSelector selector,
                                                      DbTreeDefinition treeDef, int topLevel, NormalDataRowTreeNode node)
        {
            string layer = node.Layer;
            int    len   = layer.Length / 3;

            if (len < topLevel)
            {
                return(null);
            }

            IParamBuilder[] builders = new IParamBuilder[len - topLevel + 1];
            for (int i = 0; i < builders.Length; i++)
            {
                int    subLength = (topLevel + i - 1) * 3;
                string likeValue = layer.Substring(0, subLength).PadRight(subLength + 3, '_');
                string paramName = treeDef.LayerField + i.ToString(ObjectUtil.SysCulture);
                builders[i] = SqlParamBuilder.CreateSingleSql(selector.Context,
                                                              selector.GetFieldInfo(treeDef.LayerField), "LIKE", paramName, likeValue);
            }
            IParamBuilder builder = SqlParamBuilder.CreateParamBuilderWithOr(builders);

            return(builder);
        }
예제 #8
0
 public void Execute(TableSelector selector)
 {
     InternalExecute(selector);
 }
예제 #9
0
 public static void GetSelectCommand(TableSelector selector)
 {
     SetSelectCommand(selector);
     selector.DataAdapter.SelectCommand.CommandText = selector.SkeletonSelectSql;
 }