Example #1
0
        private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            //找到选定的节点
            TreeNodeEx theNode = (TreeNodeEx)e.Node;

            if (theNode == null)
            {
                return;
            }
            if (theNode.IsFirstExpand == false)
            {
                this.Cursor = Cursors.Default;
                return;
            }
            if (theNode.ImageIndex == 1)
            {
                treeFactory.RefreshNode(theNode, "", "", true, "", false);
            }

            theNode.IsFirstExpand = false;

            this.Cursor = Cursors.Default;
        }
Example #2
0
        /// <summary>
        /// 在TreeView控件上寻找到节点,然后选中该节点
        /// </summary>
        /// <param name="node">需要选中的节点</param>
        public void SelectNode(TreeNodeEx node)
        {
            try
            {
                TreeView tv     = node.TreeView;
                string   nodeID = node.Name;

                TreeNode[] nodes = tv.Nodes[0].Nodes.Find(nodeID, true);
                if (nodes != null && nodes.Length > 0)
                {
                    tv.Visible      = false;
                    tv.SelectedNode = tv.Nodes[0];  //先选定根节点,保证AfterSelect事件触发
                    tv.SelectedNode = nodes[0];
                    if (nodes[0].Nodes != null && nodes[0].Nodes.Count > 0)
                    {
                        nodes[0].Expand();
                    }
                    tv.Visible = true;

                    nodes[0].EnsureVisible();
                }
                tv.Focus();
            }
            catch { }
        }
Example #3
0
        public void RefreshNode(TreeNodeEx Node, string fileRecording_templet, string cell_tempet, bool withImage, string projectNo, bool IsAll)
        {
            //树
            TreeView treeView1 = Node.TreeView;

            //ds = DigiPower.ERM.CBLL.Vars.GetTrees();
            ////dsArchive = vars.GetArchives();
            //DataView dataView = new DataView(ds.Tables[0]);

            //DataView dataView = new DataView(ds.Tables[0]);

            //dataView.RowFilter = "ParentID='" + parentID + "'";

            //if (dataView.Count == 0)
            //{
            //    treeView1.Nodes.Clear();
            //    return;
            //}

            Node.Nodes.Clear();
            ds = vars.GetTrees(true, Globals.OpenedProjectNo);
            //dataView.RowFilter = "id='" + Node.Name + "'";

            //Node.NodeKey = dataView[0]["codeno"].ToString();    //表格代码
            //Node.NodeValue = dataView[0]["filepath"].ToString();    //华表路径
            //if (withImage)
            //{
            //    Node.ImageIndex = Convert.ToInt32(dataView[0]["imageindex"]);
            //    Node.SelectedImageIndex = Convert.ToInt32(dataView[0]["imageindex"]);
            //}

            //if (Node.ImageIndex == 2 &&IsCount)
            //{
            //    Node.Text = GetFileCount(Node.Name, Convert.ToInt32(Node.ImageIndex)) + dataView[0]["title"].ToString();           //标题
            //}
            //else
            //{
            //    Node.Text = dataView[0]["title"].ToString();           //标题
            //}

            //Node.Tag = new string[] { dataView[0]["examplepath"].ToString(), dataView[0]["codetype"].ToString(), dataView[0]["zrr"].ToString()
            //,dataView[0]["fbmc"].ToString(),dataView[0]["fxmc"].ToString(),dataView[0]["zfbmc"].ToString(),dataView[0]["orderindex"].ToString()};   //是否最后一个节点,范例路径,是否用户定义表格,附件
            //Node.Checked = dataView[0]["isvisible"].ToString() == "1" ? true : false;
            //添加节点
            //treeView1.BeginUpdate();

            //添加子节点
            LoadChildNodes(Node, Node.Name, withImage, IsAll);
            Node.IsFirstExpand = false;
            //treeView1.EndUpdate();


            //销毁
            //ds = null;
        }
Example #4
0
        /// 用递归的方法读取树
        /// </summary>
        /// <param name="treeView">需要把数据绑定到的TreeView控件</param>
        /// <param name="tableName">树的数据所在的表</param>
        public void GetFileTree(TreeView treeView, bool withImage, string projectNo, bool isAll)
        {
            treeView.Nodes.Clear();

            DigiPower.ERM.CBLL.FileRegist cbll = new DigiPower.ERM.CBLL.FileRegist();

            ds = cbll.GetNewFileRecording_Templet(projectNo);

            DataView dataView = new DataView(ds.Tables[0]);

            dataView.RowFilter = "id='01'";
            if (dataView.Count == 0)
            {
                return;
            }
            string     nodeID     = "";
            string     title      = "";
            int        imageindex = 0;
            string     tag        = "";
            TreeNodeEx node;

            //获取数据
            nodeID = dataView[0]["id"].ToString();    //节点唯一ID
            title  = dataView[0]["title"].ToString(); //标题
            tag    = dataView[0]["table_name"].ToString();
            //新建节点
            node = new TreeNodeEx();

            node.Name = nodeID;         //节点唯一ID,用来检索
            node.Text = title;          //标题
            node.Tag  = tag;
            if (withImage)
            {
                node.ImageIndex         = imageindex;
                node.SelectedImageIndex = imageindex;
            }

            //添加节点
            treeView.BeginUpdate();

            //添加子节点
            LoadFileChildNodes(node.Nodes, nodeID, withImage, isAll);


            treeView.Nodes.Add(node);

            treeView.EndUpdate();

            //展开根节点
            treeView.Nodes[0].Expand();

            //销毁
            ds = null;
        }
Example #5
0
        /// 用递归的方法读取树
        /// </summary>
        /// <param name="treeView">需要把数据绑定到的TreeView控件</param>
        /// <param name="tableName">树的数据所在的表</param>
        public void GetTree(TreeView treeView, string fileRecording_templet, string cell_tempet, bool withImage, string projectNo, bool IsAll)
        {
            treeView.Nodes.Clear();

            ds = vars.GetTrees(true, Globals.OpenedProjectNo);
            //DataColumn[] tColumns = new DataColumn[1];
            //tColumns[0] = ds.Tables[0].Columns["parentid"];
            //ds.Tables[0].PrimaryKey = tColumns;
            //dsArchive = vars.GetArchives();
            DataView dataView = new DataView(ds.Tables[0]);

            dataView.RowFilter = "id='01'";
            if (dataView.Count == 0)
            {
                return;
            }

            DataRowView tRow = dataView[0];

            DigiPower.ERM.Model.FileRecording_Templet M_FileRecording_Templet = this.Command_GetFile(tRow);//获取文件对象模型


            //新建节点
            TreeNodeEx node = new TreeNodeEx();


            node.Name    = M_FileRecording_Templet.id;                        //节点唯一ID,用来检索
            node.Text    = M_FileRecording_Templet.gdwj;                      //标题
            node.Tag     = M_FileRecording_Templet;                           //是否最后一个节点,范例路径,是否用户定义表格,附件
            node.Checked = M_FileRecording_Templet.isvisible == 1?true:false; //是否可见

            if (withImage)
            {
                node.ImageIndex         = 0; //0为根目录图片号
                node.SelectedImageIndex = 0; //0为根目录图片号
            }

            //添加节点
            treeView.BeginUpdate();

            treeView.Nodes.Add(node);

            //添加子节点
            LoadChildNodes(node, node.Name, withImage, IsAll);

            node.IsFirstExpand = false;
            treeView.EndUpdate();

            //展开根节点
            treeView.Nodes[0].Expand();

            //销毁
            //ds = null;
        }
Example #6
0
 /// <summary>
 /// 刷新节点
 /// </summary>
 /// <param name="node"></param>
 private void RefreshNode(TreeNodeEx NewNode)
 {
     //如果节点是第一次展开
     if (NewNode.IsFirstExpand)
     {
         //如果点击的不是模版也不是电子文件
         if (NewNode.ImageIndex == 1)
         {
             //刷新节点
             treeFactory.RefreshFileNode(NewNode, true, Globals.OpenedProjectNo, true);
         }
     }
 }
Example #7
0
        /// <summary>
        /// 获取树的节点,跟其他方法合用
        /// </summary>
        /// <param name="nodes">TreeNodeCollection</param>
        /// <param name="nodeID">要查询的节点</param>
        private void LoadFileChildNodes(TreeNodeCollection nodes, string parentID, bool withImage, bool isAll)
        {
            DigiPower.ERM.CBLL.FileRegist cbll = new FileRegist();

            if (ds == null)
            {
                return;
            }
            DataView dataView = new DataView(ds.Tables[0]);

            dataView.RowFilter = "parentid='" + parentID + "' and imageindex<>2";

            foreach (DataRowView drv in dataView)
            {
                TreeNodeEx node = new TreeNodeEx();

                node.Name = drv["id"].ToString();
                node.Tag  = drv["table_name"].ToString();

                if (withImage)
                {
                    node.ImageIndex         = Convert.ToInt32(drv["imageindex"]);
                    node.SelectedImageIndex = Convert.ToInt32(drv["imageindex"]);
                }

                node.Text = drv["title"].ToString();

                nodes.Add(node);

                if (isAll)
                {
                    LoadFileChildNodes(node.Nodes, node.Name, withImage, isAll);

                    node.IsFirstExpand = false;
                }
                else
                {
                    if (GetFileCount(drv["id"].ToString(), Convert.ToInt32(drv["imageindex"])) != "[0]")
                    {
                        if (cbll.GetNewFileRecording_TempletCountlist(node.FullPath))
                        {
                            TreeNodeEx node1 = new TreeNodeEx();

                            node1.Name = "临时数据";
                            node1.Text = "临时数据";
                            node.Nodes.Add(node1);
                        }
                    }
                }
            }
        }
Example #8
0
        public string GetFinal_fileCount(TreeNodeEx node)
        {
            DigiPower.ERM.CBLL.FileRegist cbll = new DigiPower.ERM.CBLL.FileRegist();

            string count = "[0]";

            string NUM = cbll.GetAttachmentListCount(OpeartPath(node), Globals.OpenedProjectNo);

            if (!String.IsNullOrEmpty(NUM))
            {
                count = "[" + NUM + "]";
            }

            return(count);
        }
Example #9
0
        /// <summary>
        /// 去掉路径中的[0],*
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private string OpeartPath(TreeNodeEx node)
        {
            if (node != null)
            {
                if (node.ImageIndex == 2 | node.ImageIndex == 4 | node.ImageIndex == 5)
                {
                    string treepath = null;

                    if (node.Text.LastIndexOf("]") > 0)
                    {
                        treepath = node.Parent.FullPath + "\\" + node.Text.Substring(node.Text.LastIndexOf("]") + 1);
                    }
                    else
                    {
                        treepath = node.Parent.FullPath + "\\" + node.Text;
                    }

                    treepath = treepath.Replace("*", "");

                    return(treepath);
                }
                if (node.ImageIndex == 3)
                {
                    string treepath = null;

                    if (node.Text.LastIndexOf("]") > 0)
                    {
                        treepath = node.Parent.FullPath + "\\" + node.Text.Substring(node.Text.LastIndexOf("]") + 1);
                    }
                    else
                    {
                        treepath = node.Parent.FullPath + "\\" + node.Text;
                    }

                    treepath = treepath.Replace("*", "");

                    return(treepath);
                }

                return(null);
            }
            else
            {
                return(null);
            }
        }
Example #10
0
        //08 08 26修改 删除附件
        private void DelNode(TreeNodeEx theNode, string tableName, string projectNo)
        {
            ////删除数据库中的记录
            //string sql = "delete from " + tableName + " where nodeid = " + theNode.Name;
            //if (projectNo != "")
            //{
            //    sql += " and projectno='" + projectNo + "'";
            //}
            ////DBFunc.ExecuteSql(sql);

            ////删除附件
            //if (projectNo != "")
            //{
            //    AttachData attachData = new AttachData();
            //    DataView dv = attachData.GetAttachment(projectNo, theNode.Name).Tables[0].DefaultView;
            //    if (dv.Count > 0)
            //    {
            //        foreach (DataRowView drv in dv)
            //        {
            //            if (File.Exists(Globals.ProjectPath + drv["filepath"].ToString()))
            //            {
            //                File.Delete(Globals.ProjectPath + drv["filepath"].ToString());
            //            }
            //        }
            //    }
            //    sql = "delete from Attachment where nodeid= " + theNode.Name + " and projectno='" + projectNo + "'";
            //    DBFunc.ExecuteSql(sql);
            //}

            //如果是表格的话,删除它
            //if (theNode.ImageIndex == ImageLists.Cell || theNode.ImageIndex == ImageLists.CellLock)
            //{
            //    if (File.Exists(Globals.ProjectPath + theNode.NodeValue))
            //    {
            //        File.Delete(Globals.ProjectPath + theNode.NodeValue);
            //    }
            //}


            ////递归
            //TreeNodeCollection nodes = theNode.Nodes;
            //for (int i = 0; i < nodes.Count; i++)
            //{
            //    DelNode((TreeNodeEx)nodes[i], tableName, projectNo);
            //}
        }
Example #11
0
        /// <summary>
        /// 删除某一节点及所有子节点,调用时请先使Cell控件打开的是空表,
        /// 而是不需要删除的节点中的某一表格,以防删除电子文件失败
        /// </summary>
        /// <param name="theNode"></param>
        /// <param name="tableName"></param>
        /// <param name="projectNo"></param>
        public void DelNodes(TreeNodeEx theNode, string tableName, string projectNo)
        {
            string sql = "";


            //如果是根节点,则全删后中止
            if (theNode.ImageIndex == ImageLists.Root)
            {
                //删除数据库中的记录
                sql = "delete from " + tableName;
                if (projectNo != "")
                {
                    sql += " where projectno='" + projectNo + "'";
                }
                //DBFunc.ExecuteSql(sql);

                //删除表格
                if (projectNo != "")
                {
                    Directory.Delete(Globals.ProjectPath + "\\" + projectNo);
                    Directory.CreateDirectory(Globals.ProjectPath + "\\" + projectNo);
                }

                return;
            }

            //开始删除
            this.DelNode(theNode, tableName, projectNo);


            //如果当前节点删除以后,其父节点下面就没节点了,则置父节点的lastleaf为true,提高树生成的速度
            if (theNode.Parent != null)
            {
                TreeNodeEx parentNode = (TreeNodeEx)theNode.Parent;
                if (parentNode.Nodes.Count == 1)
                {
                    sql = "update " + tableName + " set lastleaf=1 where nodeid=" + parentNode.Name;
                    if (projectNo != "")
                    {
                        sql += " and projectno='" + projectNo + "'";
                    }
                    //DBFunc.ExecuteSql(sql);
                }
            }
        }
Example #12
0
        private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            //获取点中的节点
            TreeNodeEx NewNode = (TreeNodeEx)(e.Node);

            if (NewNode.Parent != null)
            {
                //点击节点操作
                if (NewNode.IsFirstExpand)
                {
                    RefreshNode((TreeNodeEx)NewNode);
                }
            }

            this.Cursor = Cursors.Default;
        }
Example #13
0
        /// <summary>
        /// 刷新节点
        /// </summary>
        /// <param name="Node"></param>
        /// <param name="withImage"></param>
        /// <param name="projectNo"></param>
        /// <param name="IsCount"></param>
        /// <param name="isAll"></param>
        public void RefreshFileNode(TreeNode NodeNode, bool withImage, string projectNo, bool isAll)
        {
            TreeNodeEx Node = (TreeNodeEx)NodeNode;

            //树
            TreeView treeView1 = Node.TreeView;

            DigiPower.ERM.CBLL.FileRegist cbll = new DigiPower.ERM.CBLL.FileRegist();

            ds = cbll.RegistGetNewFileRecording_Templet(projectNo);

            DataView dataView = new DataView(ds.Tables[0]);

            if (dataView.Count == 0)
            {
                treeView1.Nodes.Clear();
                return;
            }

            Node.Nodes.Clear();

            dataView.RowFilter = "id='" + Node.Name + "'";

            if (dataView.Count > 0)
            {
                //添加节点
                treeView1.BeginUpdate();

                Node.Text = dataView[0]["title"].ToString();

                Node.Tag = dataView[0]["table_name"].ToString();

                //添加子节点
                LoadFileChildNodes(Node.Nodes, Node.Name, withImage, isAll);

                Node.IsFirstExpand = false;

                treeView1.EndUpdate();
            }
            //销毁
            // ds = null;
        }
Example #14
0
 private void GetChildNodes(TreeNodeEx child)
 {
     for (int i = 0; i < child.Nodes.Count; i++)
     {
         if (child.Nodes[i].ImageIndex == 1)
         {
             if (!(child.Tag as DigiPower.ERM.Model.FileRecording_Templet).zrr.StartsWith("系统管理员"))
             {
                 continue;
             }
             else
             {
                 AllPath.Add(child.Nodes[i].Name);
                 GetChildNodes((TreeNodeEx)child.Nodes[i]);
             }
         }
         else
         {
             AllPath.Add(child.Nodes[i].Name);
             archiveNodes.Add(child.Nodes[i].Name);
         }
     }
 }
Example #15
0
        //private ProjectFactory projectFactory;

        public frmExpData(TreeNodeEx theNode)
        {
            InitializeComponent();

            TheNode = theNode;
        }
Example #16
0
        /// <summary>
        /// 获取树的节点,跟其他方法合用
        /// </summary>
        /// <param name="nodes">TreeNodeCollection</param>
        /// <param name="nodeID">要查询的节点</param>
        private void LoadChildNodes(TreeNodeEx pParentNode, string parentID, bool withImage, bool IsAll)
        {
            if (ds == null)
            {
                return;
            }
            DataView dataView = new DataView(ds.Tables[0]);

            dataView.RowFilter = "ParentID='" + parentID + "'";

            TreeNodeEx[] tNodes      = new TreeNodeEx[dataView.Count];
            int          tNodesCount = 0;

            foreach (DataRowView drv in dataView)
            {
                TreeNodeEx node = new TreeNodeEx();
                if (this.Command_IsSelectFile(Convert.ToInt32(drv["imageindex"])))
                {
                    DigiPower.ERM.Model.FileRecording_Templet M_FileRecording_Templet = this.Command_GetFile(drv); //获取文件对象模型
                    node.Name    = M_FileRecording_Templet.id;                                                     //节点唯一ID,用来检索
                    node.Text    = M_FileRecording_Templet.gdwj;                                                   //标题
                    node.Tag     = M_FileRecording_Templet;                                                        //是否最后一个节点,范例路径,是否用户定义表格,附件
                    node.Checked = M_FileRecording_Templet.isvisible == 1 ? true : false;                          //是否可见
                }
                else if (this.Command_IsSelectModel(Convert.ToInt32(drv["imageindex"])))
                {
                    DigiPower.ERM.Model.Cell_Templet M_Cell_Templet = this.Command_GetModel(drv); //获取文件对象模型
                    node.Name      = M_Cell_Templet.id;                                           //节点唯一ID,用来检索
                    node.Text      = M_Cell_Templet.title;                                        //标题
                    node.Tag       = M_Cell_Templet;                                              //是否最后一个节点,范例路径,是否用户定义表格,附件
                    node.Checked   = M_Cell_Templet.isvisible == 1 ? true : false;                //是否可见
                    node.NodeKey   = M_Cell_Templet.codeno;
                    node.NodeValue = M_Cell_Templet.filepath;
                }
                else if (this.Command_IsSelectRoot(Convert.ToInt32(drv["imageindex"])))
                {
                    DigiPower.ERM.Model.FileRecording_Templet M_FileRecording_Templet = this.Command_GetFile(drv); //获取文件对象模型
                    node.Name    = M_FileRecording_Templet.id;                                                     //节点唯一ID,用来检索
                    node.Text    = M_FileRecording_Templet.gdwj;                                                   //标题
                    node.Tag     = M_FileRecording_Templet;                                                        //是否最后一个节点,范例路径,是否用户定义表格,附件
                    node.Checked = M_FileRecording_Templet.isvisible == 1 ? true : false;                          //是否可见
                }

                if (withImage)
                {
                    node.ImageIndex         = Convert.ToInt32(drv["imageindex"]);
                    node.SelectedImageIndex = Convert.ToInt32(drv["imageindex"]);
                }

                node.Text = drv["title"].ToString();
                if (node.ImageIndex != 2)
                {
                    if (IsAll)
                    {
                        LoadChildNodes(node, node.Name, true, true);
                        node.IsFirstExpand = false;
                    }
                    else
                    {
                        TreeNodeEx node1 = new TreeNodeEx();

                        node1.Name = "临时数据";
                        node1.Text = "临时数据";
                        node.Nodes.Add(node1);
                    }
                }
                tNodes.SetValue(node, tNodesCount++);
            }
            if (80 < tNodes.Length)  //如果其含有的子节点数大于80个,启动BeginUpdate方法
            {
                pParentNode.TreeView.BeginUpdate();
                pParentNode.Nodes.AddRange(tNodes);
                pParentNode.TreeView.EndUpdate();
            }
            else
            {
                pParentNode.Nodes.AddRange(tNodes);
            }
        }