Exemplo n.º 1
0
 public TreeIndex(CataItem item, FamilyBrowserVM familyBrowserVM)
 {
     InitializeComponent();
     _parentItem             = item;
     this.ParentName.Content = item.Name;
     Vm = familyBrowserVM;
 }
Exemplo n.º 2
0
        //删除节点
        private void DeleteNode_Click(object sender, RoutedEventArgs e)
        {
            CataItem item = Treeview1.SelectedItem as CataItem;

            FamilyBrowserVM vm = this.DataContext as FamilyBrowserVM;

            if (item == null)
            {
                MessageBox.Show("请选择要删除的节点");
            }

            //获取当前选中节点的父类
            CataItem parent = item.Parent as CataItem;

            if (parent != null)
            {
                if (item.NameId == ServerManagement.id || ServerManagement.id == 1)
                {
                    //在父节点中删除选中的子节点
                    vm.SetCatalogdelete(item.Id);
                    parent.Children.Remove(item);
                    item.Identifying = Convert.ToInt32(CataItem.Stater.Delete);
                }
                else
                {
                    MessageBox.Show("您没有权限删除这个节点");
                }
            }
            else
            {
                MessageBox.Show("父节点不能删除");
            }
        }
Exemplo n.º 3
0
 public TreeUpdate(CataItem item, FamilyBrowserVM vM)
 {
     InitializeComponent();
     _parentItem             = item;
     this.ParentName.Content = item.Name.ToString();
     VM = vM;
 }
Exemplo n.º 4
0
        private void TreeView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            CataItem item = Treeview1.SelectedItem as CataItem;

            if (item != null)
            {
                string tex = item.Id.ToString();
                MessageBox.Show(tex);
            }
        }
Exemplo n.º 5
0
        //修改节点事件
        private void UpdateNode_Click(object sender, RoutedEventArgs e)
        {
            CataItem        item = Treeview1.SelectedItem as CataItem;
            FamilyBrowserVM vm   = this.DataContext as FamilyBrowserVM;

            if (item != null)
            {
                TreeUpdate update = new TreeUpdate(item, vm);
                update.ShowDialog();
            }
        }
Exemplo n.º 6
0
        //添加节点事件
        private void InputNode_Click(object sender, RoutedEventArgs e)
        {
            CataItem        item = Treeview1.SelectedItem as CataItem;
            FamilyBrowserVM vm   = this.DataContext as FamilyBrowserVM;

            if (item != null)
            {
                TreeIndex index = new TreeIndex(item, vm);
                index.ShowDialog();
            }
            else
            {
                MessageBox.Show("请选择父级节点");
            }
        }
Exemplo n.º 7
0
        //通过审核
        private void audit_Click(object sender, RoutedEventArgs e)
        {
            var      vM   = this.DataContext as FamilyBrowserVM;
            CataItem item = Treeview1.SelectedItem as CataItem;

            if (item.newname.Length > 2)
            {
                //修改
                vM.PassAuditUpdate(item.Id, item.newname);
                //UnfoldTreeview();
            }
            else if (item.Audit == "未审核")
            {
                vM.PassAuditAdd(item.Id);
                //UnfoldTreeview();
            }
            vM.FileUplod();
        }
Exemplo n.º 8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (this.NodeInput.Text != "")
            {
                CataItem list = new CataItem();
                if (ServerManagement.id == 1)
                {
                    Vm.SetCatalogAdminAdd(this.NodeInput.Text, ra.Next(), _parentItem.Id);
                }
                else
                {
                    Vm.SetCatalogAdd(this.NodeInput.Text, ra.Next(), _parentItem.Id);
                }

                list.Identifying = Convert.ToInt32(CataItem.Stater.Input);
                list.Name        = this.NodeInput.Text;
                _parentItem.Children.Add(list);
                this.Close();
            }
            else
            {
                this.pointout.Text = "添加节点名称不能为空";
            }
        }
Exemplo n.º 9
0
        //拒绝审核
        private void AuditRefuse_Click(object sender, RoutedEventArgs e)
        {
            CataItem item = Treeview1.SelectedItem as CataItem;
            var      vM   = this.DataContext as FamilyBrowserVM;

            if (item.newname.Length > 2)
            {
                vM.AuditRefuse(item.Id);
                //UnfoldTreeview();
            }
            else if (item.Audit == "未审核")
            {
                vM.AuditRefuseadd(item.Id);
                CataItem parent = item.Parent as CataItem;
                if (parent != null)
                {
                    //在父节点中删除选中的子节点
                    parent.Children.Remove(item);
                    item.Identifying = Convert.ToInt32(CataItem.Stater.Delete);
                    //UnfoldTreeview();
                }
            }
            vM.FileUplod();
        }
Exemplo n.º 10
0
        //合并(测试)
        public string merge2()
        {
            List <CataItem> list     = new List <CataItem>();
            List <int>      parentid = new List <int>();

            using (var cmd = m_liteDB.CreateCommand())
            {
                cmd.CommandText = "SELECT id,name,parent FROM catalog where identifying =0";
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        //组装字典
                        CataItem item = new CataItem();
                        item.Id   = reader.GetInt32(0);
                        item.Name = reader.GetString(1);
                        parentid.Add(reader.GetInt32(2));
                        list.Add(item);
                    }
                }
            }

            //打开下载的文件
            LiteDB NewliteDB = new LiteDB(m_folder);

            NewliteDB.Open(0);
            using (var newcmd = NewliteDB.CreateCommand())
            {
                for (int j = 0; j < parentid.Count; j++)
                {
                    newcmd.CommandText = string.Format("SELECT id,name,parent FROM catalog where id='{0}'", parentid[j]);
                    using (var reader = newcmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            using (var addcom = NewliteDB.CreateCommand())
                            {
                                addcom.CommandText = string.Format("insert into catalog(id,name,parent,audit) values('{0}','{1}','{2}','{3}')", list[j].Id, list[j].Name, parentid[j], 1);
                                addcom.ExecuteScalar();
                            }
                        }
                        else
                        {
                            using (var cmd = m_liteDB.CreateCommand())
                            {
                                cmd.CommandText = string.Format("SELECT id,name,parent FROM catalog where id='{0}'", parentid[j]);
                                using (var readerparent = cmd.ExecuteReader())
                                {
                                    while (readerparent.Read())
                                    {
                                        using (var addcom = NewliteDB.CreateCommand())
                                        {
                                            addcom.CommandText = string.Format("insert into catalog(id,name,parent) values('{0}','{1}','{2}')", readerparent.GetInt32(0), readerparent.GetString(1), readerparent.GetInt32(2));
                                            addcom.ExecuteScalar();
                                        }
                                    }
                                }

                                using (var addcom = NewliteDB.CreateCommand())
                                {
                                    addcom.CommandText = string.Format("insert into catalog(id,name,parent,audit) values('{0}','{1}','{2}','{3}')", list[j].Id, list[j].Name, parentid[j], 1);
                                    addcom.ExecuteScalar();
                                }
                            }
                        }
                    }
                }
            }
            NewliteDB.Close();
            Updatetreeview();
            return("a");
        }
Exemplo n.º 11
0
        //合并(测试)
        public void merge()
        {
            List <int>      parentid = new List <int>();
            List <CataItem> list     = new List <CataItem>();

            using (var cmd = m_liteDB.CreateCommand())
            {
                //查询所有修改过后的结点
                cmd.CommandText = "SELECT id,newname,parent FROM catalog where identifying =2";
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        //组装字典
                        CataItem item = new CataItem();
                        int      a    = reader.GetInt32(0);
                        string   ab   = reader.GetString(1);
                        item.Id   = reader.GetInt32(0);
                        item.Name = reader.GetString(1);
                        parentid.Add(reader.GetInt32(2));
                        list.Add(item);
                    }
                }
            }

            LiteDB NewliteDB = new LiteDB(m_folder);

            NewliteDB.Open(0);

            using (var newcmd = NewliteDB.CreateCommand())
            {
                for (int j = 0; j < list.Count; j++)
                {
                    newcmd.CommandText = string.Format("SELECT id,name,parent FROM catalog where id='{0}'", parentid[j]);
                    using (var updatereader = newcmd.ExecuteReader())
                    {
                        if (updatereader.Read())
                        {
                            using (var updatecom = NewliteDB.CreateCommand())
                            {
                                updatecom.CommandText = string.Format("UPDATE catalog set name='{0}',audit='{1}' where id={2}", list[j].Name, 1, list[j].Id);
                                updatecom.ExecuteScalar();
                            }
                        }
                        else
                        {
                            using (var cmd = m_liteDB.CreateCommand())
                            {
                                cmd.CommandText = string.Format("SELECT id,name,parent FROM catalog where id='{0}'", parentid[j]);
                                using (var readerparent = cmd.ExecuteReader())
                                {
                                    while (readerparent.Read())
                                    {
                                        using (var addcom = NewliteDB.CreateCommand())
                                        {
                                            addcom.CommandText = string.Format("insert into catalog(id,name,parent) values('{0}','{1}','{2}')", readerparent.GetInt32(0), readerparent.GetString(1), readerparent.GetInt32(2));
                                            addcom.ExecuteScalar();
                                        }
                                    }
                                }

                                using (var updatecom = NewliteDB.CreateCommand())
                                {
                                    updatecom.CommandText = string.Format("UPDATE catalog set name='{0}',audit='{1}' where id={2}", list[j].Name, 1, list[j].Id);
                                    updatecom.ExecuteScalar();
                                }
                            }
                        }
                    }
                }
            }
            NewliteDB.Close();
        }
Exemplo n.º 12
0
        //读数据库树形节点
        private void LoadCatalog()
        {
            var dictPID = new Dictionary <int, int>();

            dictCatalog = new Dictionary <int, CataItem>();
            using (var cmd = m_liteDB.CreateCommand())
            {
                if (ServerManagement.id == 1)
                {
                    cmd.CommandText = "SELECT id,name,parent,newname,audit FROM catalog ";
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            //组装字典
                            CataItem item = new CataItem();
                            item.Id      = reader.GetInt32(0);
                            item.Name    = reader.GetString(1);
                            item.NewName = reader.GetString(3);
                            //item.Audit = reader.GetInt32(4).ToString();
                            if (reader.GetInt32(4) == 1)
                            {
                                item.Audit = "未审核";
                            }
                            else
                            {
                                item.Audit = "";
                            }
                            dictCatalog.Add(reader.GetInt32(0), item);
                            //0位当前id, 2位父节点id
                            dictPID.Add(item.Id, reader.GetInt32(2));
                        }
                    }
                }
                else
                {
                    cmd.CommandText = string.Format("SELECT id,name,parent,newname,NameID FROM catalog where NameID='{0}' or audit=0 ", ServerManagement.id);
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            CataItem item = new CataItem();
                            item.Id = reader.GetInt32(0);

                            if (reader.GetString(3) != "" && ServerManagement.id != 0)
                            {
                                item.Name = reader.GetString(3);
                            }
                            else
                            {
                                item.Name = reader.GetString(1);
                            }
                            //if (reader.GetInt32(4) != -1)
                            //{
                            item.NameId = reader.GetInt32(4);
                            //}

                            item.Audit = "";
                            dictCatalog.Add(reader.GetInt32(0), item);
                            //组装字典
                            //0位当前id, 2位父节点id
                            dictPID.Add(item.Id, reader.GetInt32(2));
                        }
                    }
                }

                //对 父子节点进行组装
                foreach (var key in dictCatalog.Keys)
                {
                    //找到当前节点
                    var c = dictCatalog[key];
                    //获取当前节点的父节点id
                    var parentID = dictPID[c.Id];
                    if (dictCatalog.ContainsKey(parentID))
                    {
                        //获取父节点对象
                        var parent = dictCatalog[parentID];
                        //指定当前节点的父节点
                        c.Parent = parent;
                        //给父节点的Children集合加入当前节点
                        parent.Children.Add(c);
                    }
                }
            }
        }