Пример #1
0
        private string[] GetFullNames(OrganizationTreeItemViewModel organization)
        {
            if (organization == null)
            {
                return(null);
            }

            if (organization.Parent == null)
            {
                return(new string[] { organization.Name });
            }

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

            allnames.Add(organization.Name);
            var parent = organization.Parent;

            while (parent != null)
            {
                allnames.Add(parent.Name);
                parent = parent.Parent;
            }

            return(allnames.ToArray());
        }
Пример #2
0
        public DepartmentTreeItemViewModel(string name, int sort_no, OrganizationTreeItemViewModel parent)//插入子节点
        {
            T_Organization      = new T1_Organization();
            T_Organization.Name = name;
            //T_Organization.Code;
            T_Organization.Guid  = Guid.NewGuid();
            T_Organization.Level = parent.T_Organization.Level + 1;
            //if (sort_no > 0)
            //{
            //    for (int i = 0; i < parent.Children.Count; i++)
            //    {
            //        if ((parent.Children[i] as OrganizationTreeItemViewModel).T_Organization.Sort_No >= sort_no)
            //        {
            //            (parent.Children[i] as OrganizationTreeItemViewModel).T_Organization.Sort_No++;
            //        }
            //    }
            //}
            T_Organization.Sort_No      = sort_no;
            T_Organization.Create_Time  = DateTime.Now;
            T_Organization.Modify_Time  = DateTime.Now;
            T_Organization.Is_Disabled  = false;
            T_Organization.Parent_Code  = parent.T_Organization.Code;
            T_Organization.Parent_Guid  = parent.T_Organization.Guid;
            T_Organization.Parent_Level = parent.T_Organization.Level;
            //T_Organization.Remarks
            T_Organization.NodeType = 0;

            IsExpanded = true;
        }
Пример #3
0
        public DepartmentTreeItemViewModel(T1_Organization t_organization, OrganizationTreeItemViewModel parent)//插入子节点
        {
            T_Organization          = t_organization;
            T_Organization.NodeType = 0;

            IsExpanded = true;
        }
Пример #4
0
 public void RemoveChild(OrganizationTreeItemViewModel child)
 {
     if (Children.Contains(child))
     {
         child.Parent = null;
         Children.Remove(child);
     }
 }
Пример #5
0
 public void AddChild(OrganizationTreeItemViewModel child)
 {
     if (!Children.Contains(child))
     {
         child.Parent = this;
         child.Names  = GetFullNames(child);
         Children.Add(child);
     }
 }
Пример #6
0
 public void InsertChild(int index, OrganizationTreeItemViewModel child)
 {
     if (!Children.Contains(child))
     {
         child.Parent = this;
         child.Names  = GetFullNames(child);
         Children.Insert(index, child);
     }
 }
Пример #7
0
 public DeviceTreeItemViewModel(string name, OrganizationTreeItemViewModel parent) : base(name, parent)
 {
     if (name == "")
     {
         T_Organization.Name = "新建设备" + (T_Organization.Sort_No + 1).ToString();
     }
     else
     {
         T_Organization.Name = name;
     }
     device_init();
 }
Пример #8
0
        public DepartmentTreeItemViewModel(string name, OrganizationTreeItemViewModel parent) : this(name, -1, parent)//添加子节点
        {
            int sort_no = parent.Children.Count;

            if (parent.Children.Count > 0)
            {
                sort_no = parent.Children[parent.Children.Count - 1].T_Organization.Sort_No + 1;
            }
            T_Organization.Sort_No = sort_no;
            if (name == "")
            {
                T_Organization.Name = "新建子机构" + (sort_no + 1).ToString();
            }
            else
            {
                T_Organization.Name = name;
            }
        }
Пример #9
0
 private void OnChildrenChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     // Note: This section does not account for multiple items being involved in change operations.
     // Note: This section does not account for the replace operation.
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         OrganizationTreeItemViewModel child = (OrganizationTreeItemViewModel)e.NewItems[0];
         child.Parent = this;
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         OrganizationTreeItemViewModel child = (OrganizationTreeItemViewModel)e.OldItems[0];
         if (child.Parent == this)
         {
             child.Parent = null;
         }
     }
 }
Пример #10
0
        public OrganizationTreeItemViewModel(string name, int sort_no, OrganizationTreeItemViewModel parent)//插入子节点
        {
            T_Organization      = new T1_Organization();
            T_Organization.Name = name;
            //T_Organization.Code;
            T_Organization.Guid         = Guid.NewGuid();
            T_Organization.Level        = parent.T_Organization.Level + 1;
            T_Organization.Sort_No      = sort_no;
            T_Organization.Create_Time  = DateTime.Now;
            T_Organization.Modify_Time  = DateTime.Now;
            T_Organization.Is_Disabled  = false;
            T_Organization.Parent_Code  = parent.T_Organization.Code;
            T_Organization.Parent_Guid  = parent.T_Organization.Guid;
            T_Organization.Parent_Level = parent.T_Organization.Level;
            //T_Organization.Remarks
            T_Organization.NodeType = 0;

            IsExpanded = true;
        }
Пример #11
0
 public DeviceTreeItemViewModel(T1_Organization t_organzation, OrganizationTreeItemViewModel parent) : base(t_organzation.Name, t_organzation.Sort_No, parent)
 {
     T_Organization = t_organzation;
     device_init();
 }
Пример #12
0
 public DeviceTreeItemViewModel(string name, int sort_no, OrganizationTreeItemViewModel parent) : base(name, sort_no, parent)
 {
     device_init();
 }
Пример #13
0
 public DeviceTreeItemViewModel(OrganizationTreeItemViewModel parent) : this("", parent)
 {
 }