Example #1
0
        public void BindDictionaryTreeView(Guid parentID, TreeNode parentNode, ContentDomain domain, List<ITreeNode> parents)
        {
            using (DictionaryProvider provider = new DictionaryProvider())
            {
                //bind child dictionaries
                List<ITreeNode> list = new List<ITreeNode>();
                if (parentID.Equals(Guid.Empty))
                {
                    List<DictionaryTree> list1 = provider.GetDictionaryTreeList(parentID, this.Roles);
                    var q = from l in list1.Where(f => f.ClassificationID.HasValue)
                            join m in parents on l.ClassificationID.Value equals m.ID
                            select new DictionaryTree
                            {
                                ID = l.ID,
                                ParentID = l.ParentID,
                                Name = string.Format("{0} ({1})", l.Name, m.Name)
                            } as ITreeNode;
                    //l as ITreeNode;
                    list = q.ToList();
                }
                else
                {
                    list = provider.GetList(parentID, User.ID, Roles);
                }
                foreach (ITreeNode item in list)
                {
                    TreeNode node = new TreeNode(item.Name, item.ID.ToString());
                    node.SelectAction = TreeNodeSelectAction.Expand;
                    if (parentNode != null) parentNode.ChildNodes.Add(node);
                    else DictionaryTreeView.Nodes.Add(node);

                    this.BindDictionaryTreeView(item.ID, node, domain, parents);
                }
                //bind fields
                if (parentNode != null && !parentID.Equals(Guid.Empty))
                {
                    DictionaryTree entity = provider.DictionaryTrees.SingleOrDefault(d => d.ID == parentID);
                    List<IUserField> fields = domain.GetUserFields(this.User.ID, RequestClassificationTreeID, this.FieldPlaceHolderID).Where(uf => uf.DictionaryTreeID == parentID).ToList();

                    List<Guid> previous = this.PreviouseDictionaries;
                    previous.AddRange(fields.Select(f => f.DictionaryProperty.ID));
                    this.PreviouseDictionaries = previous;

                    //List<DictionaryProperty> source = entity.Dictionary.DictionaryProperties.ToList();
                    List<DictionaryProperty> source = provider.GetAvailableDictionaryProperties(this.Roles, entity.DictionaryID);

                    foreach (DictionaryProperty prop in source)
                    {
                        TreeNode node = new TreeNode(prop.Name, prop.ID.ToString());
                        node.SelectAction = TreeNodeSelectAction.None;
                        IUserField field = fields.Find(f => f.DictionaryProperty.ID == prop.ID);
                        if (field != null)
                        {
                            node.Checked = true;
                            node.Value = string.Format("{0},{1}", node.Value, field.Sequence);
                        }
                        else node.Checked = false;
                        parentNode.ChildNodes.AddAt(0, node);
                    }
                }
                //--
            }
        }
Example #2
0
        protected void GridPager_CurrentPageChanged(object sender, PagerEventArgs e)
        {
            using (DictionaryProvider provider = new DictionaryProvider())
            {
                DictionaryTree entity = provider.DictionaryTrees.Single(d => d.ID == DictionaryTreeID);
                List<GridColumn> columns = provider.GetGridColumns(this.User.ID, DictionaryTreeID, FieldPlaceHolder.Grid);
                System.Data.DataSet source = provider.GetList(DictionaryTreeID, this.User.ID, this.OrderExpression,
                    this.SearchConditions, new PagingInfo(false));
                //provider.GetDictionaryDataSource(entity, SearchExp);
                ValueField = entity.PK;
                TextField = entity.Dictionary.IdentifierField;
                if (source != null && source.Tables.Count > 0)
                {
                    GridPager.Visible = SelectorGrid.Visible = true;
                    GridPager.CurrentPage = e.CurrentPage;
                    GridPager.TotalRecords = source.Tables[0].DefaultView.Count;

                    SelectorGrid.DataSource = source;
                    SelectorGrid.PageIndex = e.CurrentPage;
                    SelectorGrid.DataBind();
                    this.AppendGridHeader(columns);
                }
            }
        }