Пример #1
0
        public void DrawTree(TreeListNode ParentNode)
        {
            using (new WaitCursor())
            {
                string ParentValue = ParentNode == null ?
                                     (string)TreeList.RootValue : (string)((object[])ParentNode.Tag)[0];

                IList <BaseEntity> ListEntity =
                    Dp.ListFastLoadEntities(Td.ClassType, null,
                                            string.Join(",", Columns), string.Concat(
                                                TreeList.ParentFieldName, "=@0",
                                                SqlCondition.Length > 0 ?
                                                " AND " + SqlCondition :
                                                string.Empty), OrderField,
                                            new FieldParam("0", ParentValue));

                if (ParentNode != null)
                {
                    ((object[])ParentNode.Tag)[1] = true;
                }

                if (ListEntity == null || ListEntity.Count == 0)
                {
                    if (ParentNode != null)
                    {
                        ParentNode.HasChildren = false;
                    }
                    return;
                }
                object[] NodeValue = new object[Columns.Length - 1];
                TreeList.BeginUnboundLoad();
                try
                {
                    OnTreeClick = true;
                    foreach (BusinessEntity Entity in ListEntity)
                    {
                        for (int i = 1; i < Columns.Length; i++)
                        {
                            NodeValue[i - 1] = Td.GetFieldDef(Columns[i])
                                               .GetValue(Entity);
                        }
                        TreeListNode Node = TreeList.AppendNode(NodeValue, ParentNode);

                        Node.Tag = new object[2] {
                            Td.GetFieldDef(Columns[0]).GetValue(Entity), false
                        };

                        if (onAfterAddNode != null)
                        {
                            onAfterAddNode(Node, Entity);
                        }
                    }
                }
                finally
                {
                    TreeList.EndUnboundLoad();
                    OnTreeClick = false;
                }
            }
        }