示例#1
0
        private void GenerateRightTree()
        {
            string path = "J:\\RD";
            RightTree.Nodes.Clear();
            RightTree.Nodes.Add(new TreeNode());
            DocFolderRight _docFolder = new DocFolderRight();
            _docFolder.FolderName = "RD";
            _docFolder.FullFolderName = path;
            _docFolder.FatherID = 0;
              DataTable dtt = DbHelper.GetInstance().GetFolderFromName(path);
              if (dtt.Rows.Count == 0)
              {
                  DbHelper.GetInstance().AddNewsFolder(_docFolder);
              }

            string[] pathinfo = Path.GetFullPath(path.Trim()).Split(char.Parse("\\")); //得到文件路径数组
            RightTree.Nodes[0].Text = pathinfo[pathinfo.Length - 1];
            RightTree.Nodes[0].Value = path;
            RightTree.Nodes[0].PopulateOnDemand = true;
        }
示例#2
0
        public bool LoadChildNode(TreeNode node, string path)
        {
            if (Directory.Exists(path) == false)
            {
                return false;
            }

            DirectoryInfo dirInfo = new DirectoryInfo(path);
            int allNum = dirInfo.GetDirectories().Length + dirInfo.GetFiles("*.*").Length;
            if (allNum == 0)
            {
                TreeNode empty = new TreeNode();
                empty.Text = "(空白)";
                empty.Value = "";
                empty.ImageUrl = "";
                node.ChildNodes.Add(empty);
                return false;
            }
            foreach (DirectoryInfo folder in dirInfo.GetDirectories())
            {
                if (folder.Name != "FileTemp")
                {
                    int FolderId = 0;
                    TreeNode folderNode = new TreeNode();

                    DocFolderRight _docFolder = new DocFolderRight();
                    _docFolder.FolderName = folder.Name;
                    _docFolder.FullFolderName = folder.FullName;
                    DataTable dtt = DbHelper.GetInstance().GetFolderFromName(folder.FullName);
                    if (dtt.Rows.Count == 0)
                    {
                        //if (RootID == 0)
                        //    _docFolder.FatherID = RootID;
                        //else
                        //{
                        //int iLast = path.LastIndexOf('\\')+1;
                        //path = path.Substring(iLast);

                        DataTable dt = DbHelper.GetInstance().GetFolderFromName(path);
                        if (dt.Rows.Count > 0)
                        {
                            for (int i = 0; i < dt.Rows.Count; i++)
                                _docFolder.FatherID = Int16.Parse(dt.Rows[i]["FolderSerialID"].ToString());
                        }

                        //  }

                        FolderId = DbHelper.GetInstance().AddNewsFolder(_docFolder);

                        ArrayList arylst = GetSearchParameter();
                        DataTable dtUser = DbHelper.GetInstance().sp_userList_1(arylst, 200, 1);

                        for (int i = 0; i < dtUser.Rows.Count; i++)
                        {
                            // UserList.Items.Add(new ListItem(dt.Rows[i]["UserID"].ToString() + "--" + dt.Rows[i]["UserName"].ToString(), dt.Rows[i]["UserSerialID"].ToString()));
                            DocUserRight _docUser = new DocUserRight();
                            _docUser.FolderID = FolderId;
                            _docUser.UserID = Int16.Parse(dtUser.Rows[i]["UserSerialID"].ToString());
                            _docUser.Permission = "0";
                            DbHelper.GetInstance().AddNewsFolderPermission(_docUser);
                        }

                    }
                    else
                    {
                        FolderId = Int16.Parse(dtt.Rows[0]["FolderSerialID"].ToString());
                    }
                    folderNode.Text = folder.Name;
                    folderNode.Value = folder.FullName;
                    folderNode.ToolTip = folder.Name;
                    folderNode.PopulateOnDemand = true;
                    folderNode.NavigateUrl = "javascript:SetPermission('" + FolderId + "')";
                    node.ChildNodes.Add(folderNode);
                }
             // TraversingCatalog(tn.ChildNodes[folderIndex], path + "/" + folder.Name); //递归遍历其它文件夹
            }
            //foreach (FileInfo file in dirInfo.GetFiles("*.*"))
            //{
            //    TreeNode fileNode = new TreeNode();
            //    fileNode.Text = file.Name;
            //    fileNode.Value = file.FullName;
            //    string pathName = file.FullName.Replace("\\", "/");
            //    fileNode.ToolTip = file.Name;
            //    fileNode.Expanded = false;
            //    fileNode.NavigateUrl = "javascript:GetValue('" + pathName + "')";
            //    node.ChildNodes.Add(fileNode);
            //}

            return true;
        }
示例#3
0
文件: DbHelperHR.cs 项目: pcstx/OA
        public int AddNewsFolder(DocFolderRight _DocFolder)
        {
            DbParameter[] pramsInsert = {

                                       MakeInParam("@FolderName",(DbType)SqlDbType.VarChar,50,_DocFolder.FolderName),
                                         MakeInParam("@FolderFullName",(DbType)SqlDbType.VarChar,50,_DocFolder.FullFolderName),
                                           MakeInParam("@FatherID",(DbType)SqlDbType.Int,4,_DocFolder.FatherID),
                                             };
            StringBuilder sb = new StringBuilder();
            sb.Append("INSERT INTO [dbo].[Doc_FolderRight]");
            sb.Append("([FolderName]");
            sb.Append(",[FolderFullName]");
            sb.Append(",[FatherID]");
            sb.Append(")");
            sb.Append("VALUES");
            sb.Append("(@FolderName");
            sb.Append(",@FolderFullName");
            sb.Append(",@FatherID");
            sb.Append(")");
            sb.Append(" select @@identity;");

            return Int16.Parse(ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString());
        }