Ejemplo n.º 1
0
        protected void SaveRight(object sender, EventArgs e)
        {
            string result = "-1";
            string Permission = "";
            string SelectVaue = ListChoice.SelectedValue;
            string AllPermission = "";
            if (ckRead.Checked)
            {
                Permission = "1";  //可读
                AllPermission = AllPermission + Permission + ",";
            }
            if (ckWrite.Checked)
            {
                Permission = "2";  //可写
                AllPermission = AllPermission  + Permission + ",";

            }
            if (ckDelete.Checked)
            {
                Permission = "3";  //可删除
                AllPermission = AllPermission + Permission + ",";
            }

            if (ckCancel.Checked)  // 可作废
            {
                Permission = "4";
                AllPermission = AllPermission  + Permission + ",";
            }

            if (SelectVaue == "1")
            {
                DocUserRight _docUser = new DocUserRight();
                _docUser.UserID = Int32.Parse(MyList.SelectedValue);
                _docUser.FolderID = FolderId;
                _docUser.Permission = AllPermission;
                if (DbHelper.GetInstance().GetFolderPermissFromID(Int32.Parse(MyList.SelectedValue), FolderId).Rows.Count > 0)
                    result = DbHelper.GetInstance().UpDateFolderPermission(_docUser);
                else
                    result = DbHelper.GetInstance().AddNewsFolderPermission(_docUser);
            }
            else if (SelectVaue == "2")
            {
                DocDepartRight _docDepartRight = new DocDepartRight();
                _docDepartRight.DepartMentID = Int32.Parse(MyList.SelectedValue);
                _docDepartRight.FolderID = FolderId;
                _docDepartRight.Permission = AllPermission;
                if (DbHelper.GetInstance().GetFolderPermissFromDepart(Int32.Parse(MyList.SelectedValue), FolderId).Rows.Count > 0)
                    result = DbHelper.GetInstance().UpDateFolderPermissionByDepart(_docDepartRight);
                else
                    result = DbHelper.GetInstance().AddNewFolderPermissionByDepart(_docDepartRight);

            }
            else if (SelectVaue == "3")
            {
                DocSysRoleRight _docSysRoleRight = new DocSysRoleRight();
                _docSysRoleRight.SysRoldID = Int32.Parse(MyList.SelectedValue);
                _docSysRoleRight.FolderID = FolderId;
                _docSysRoleRight.Permission = AllPermission;
                if (DbHelper.GetInstance().GetFolderPermissFromSysRole(Int32.Parse(MyList.SelectedValue), FolderId).Rows.Count > 0)
                    result = DbHelper.GetInstance().UpDateFolderPermissionBySysRole(_docSysRoleRight);
                else
                    result = DbHelper.GetInstance().AddNewFolderPermissionBySysRole(_docSysRoleRight);

            }

             if (result != "-1")
             {
             lblMsg.Text = "数据保存成功";
             lblMsg.ForeColor = System.Drawing.Color.Blue;
             }
             else
             {
             lblMsg.Text = "数据保存失败";
             lblMsg.ForeColor = System.Drawing.Color.Red;
             }
        }
Ejemplo n.º 2
0
        public string AddNewsFolderPermission(DocUserRight _DocUserRight)
        {
            DbParameter[] pramsInsert = {

                                       MakeInParam("@UserSerialID",(DbType)SqlDbType.Int,4,_DocUserRight.UserID),
                                         MakeInParam("@FolderID",(DbType)SqlDbType.Int,4,_DocUserRight.FolderID),
                                           MakeInParam("@Permission",(DbType)SqlDbType.VarChar,50,_DocUserRight.Permission),
                                             };
            StringBuilder sb = new StringBuilder();
            sb.Append("INSERT INTO [dbo].[Doc_UserRight]");
            sb.Append("([UserSerialID]");
            sb.Append(",[FolderID]");
            sb.Append(",[Permission]");
            sb.Append(")");
            sb.Append("VALUES");
            sb.Append("(@UserSerialID");
            sb.Append(",@FolderID");
            sb.Append(",@Permission");
            sb.Append(")");
            sb.Append(" select @@identity;");

            return ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString();
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
 public string UpDateFolderPermission(DocUserRight _DocUserRight)
 {
     DbParameter[] pramsUpDate = {
                                MakeInParam("@UserSerialID",(DbType)SqlDbType.Int,4,_DocUserRight.UserID),
                                  MakeInParam("@FolderID",(DbType)SqlDbType.Int,4,_DocUserRight.FolderID),
                                    MakeInParam("@Permission",(DbType)SqlDbType.VarChar,50,_DocUserRight.Permission),
                 };
     StringBuilder sb = new StringBuilder();
     sb.Append("UpDate [dbo].[Doc_UserRight]");
     sb.Append(" set ");
     sb.Append(" [UserSerialID]=@UserSerialID,");
     sb.Append(" [FolderID]=@FolderID,");
     sb.Append(" [Permission]=@Permission");
     sb.Append(" where [UserSerialID]=@UserSerialID  and [FolderID]=@FolderID");
     sb.Append(" select @UserSerialID ");
     return ExecuteScalar(CommandType.Text, sb.ToString(), pramsUpDate).ToString();
 }