Example #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());
        }
Example #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;
        }
Example #3
0
        public DepartmentTreeItemViewModel(T1_Organization t_organization, OrganizationTreeItemViewModel parent)//插入子节点
        {
            T_Organization          = t_organization;
            T_Organization.NodeType = 0;

            IsExpanded = true;
        }
Example #4
0
 public void RemoveChild(OrganizationTreeItemViewModel child)
 {
     if (Children.Contains(child))
     {
         child.Parent = null;
         Children.Remove(child);
     }
 }
Example #5
0
 public void AddChild(OrganizationTreeItemViewModel child)
 {
     if (!Children.Contains(child))
     {
         child.Parent = this;
         child.Names  = GetFullNames(child);
         Children.Add(child);
     }
 }
Example #6
0
 public void InsertChild(int index, OrganizationTreeItemViewModel child)
 {
     if (!Children.Contains(child))
     {
         child.Parent = this;
         child.Names  = GetFullNames(child);
         Children.Insert(index, child);
     }
 }
 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();
 }
Example #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;
            }
        }
Example #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;
         }
     }
 }
Example #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;
        }
 public DeviceTreeItemViewModel(T1_Organization t_organzation, OrganizationTreeItemViewModel parent) : base(t_organzation.Name, t_organzation.Sort_No, parent)
 {
     T_Organization = t_organzation;
     device_init();
 }
 public DeviceTreeItemViewModel(string name, int sort_no, OrganizationTreeItemViewModel parent) : base(name, sort_no, parent)
 {
     device_init();
 }
 public DeviceTreeItemViewModel(OrganizationTreeItemViewModel parent) : this("", parent)
 {
 }