Beispiel #1
0
        public virtual void LoadDirectory(TreeNodeCollection objNodes, CUserEntity user, int resourceId)
        {
            objNodes.Clear();

            //insert the root node
            List <CResourceEntity> children = user.ListDescendants(resourceId);

            foreach (CResourceEntity res in children)
            {
                if (res.Res_Type != (int)RESOURCETYPE.FOLDERRESOURCE)
                {
                    continue;
                }

                bool blnHasNodes            = false;
                List <CResourceEntity> list = user.ListResources(res.Res_Id);
                foreach (CResourceEntity r in list)
                {
                    if (r.Res_Type == (int)RESOURCETYPE.FOLDERRESOURCE)
                    {
                        blnHasNodes = true;
                        break;
                    }
                }

                TreeNode objNode = new TreeNode(res.Res_Name);
                objNode.Tag = res.Res_Id;

                objNode.IsExpanded = !blnHasNodes;
                objNode.HasNodes   = blnHasNodes;

                objNode.Loaded = !blnHasNodes;
                objNodes.Add(objNode);
            }
        }
Beispiel #2
0
        public virtual void InitDirectory(TreeNodeCollection objNodes, CUserEntity user, int resourceId)
        {
            objNodes.Clear();
            CResourceEntity rootRes = new CResourceEntity(user.ConnString).Load(resourceId);

            if (rootRes.Res_Type != (int)RESOURCETYPE.FOLDERRESOURCE)
            {
                return;
            }

            List <CResourceEntity> children = user.ListDescendants(resourceId);

            bool blnHasNodes = false;

            foreach (CResourceEntity r in children)
            {
                if (r.Res_Type == (int)RESOURCETYPE.FOLDERRESOURCE)
                {
                    blnHasNodes = true;
                    break;
                }
            }

            TreeNode objNode = new TreeNode(rootRes.Res_Name);

            objNode.Tag = resourceId;

            objNode.IsExpanded = !blnHasNodes;
            objNode.HasNodes   = blnHasNodes;

            objNode.Loaded = !blnHasNodes;
            objNodes.Add(objNode);
        }
Beispiel #3
0
        private void writeBox_Click(object sender, EventArgs e)
        {
            if (shareList.SelectedItems.Count == 1)
            {
                ListViewItem item = shareList.SelectedItems[0];
                try
                {
                    CUserEntity user = (CUserEntity)(item.Tag);
                    if (writeBox.Checked)
                    {
                        _currentUser.Permit(user.Usr_Id, ACLROLETYPE.USERROLE, _resourceId, ACLOPERATION.WRITE);
                    }
                    else
                    {
                        _currentUser.Deny(user.Usr_Id, ACLROLETYPE.USERROLE, _resourceId, ACLOPERATION.WRITE);
                    }

                    if (!readBox.Checked && !writeBox.Checked)
                    {
                        FillUserLists();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("共享数据已发生变化:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #4
0
        private void btnSubmission_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtComment.Text == "")
                {
                    MessageBox.Show("请填写注解!", "文档管理系统", MessageBoxButtons.OK);
                }
                else
                {
                    this._CurrentUser = new CUserEntity();
                    _CurrentUser      = (CUserEntity)Context.Session["CurrentUser"];

                    bool CrAp = _CurrentUser.CreateApply(ResId, txtComment.Text.Trim());
                    if (CrAp == true)
                    {
                        MessageBox.Show("您已成功提交文件归档申请!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                        new EventHandler(onMsgBoxClose));
                    }
                    else
                    {
                        MessageBox.Show("您提交的归档申请已经存在!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("提交失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        public override void InitDirectory(TreeNodeCollection objNodes, CUserEntity user, int resourceId)
        {
            objNodes.Clear();
            // Add tree root
            TreeNode rootNode = new TreeNode("¹²ÏíĿ¼");

            objNodes.Add(rootNode);

            List <CResourceEntity> children = user.ListShareResources();
            bool blnHasNodes = false;

            foreach (CResourceEntity res in children)
            {
                if (res.Res_Type == (int)RESOURCETYPE.FOLDERRESOURCE)
                {
                    blnHasNodes = true;
                    break;
                }
            }

            rootNode.Tag = 0;

            rootNode.IsExpanded = !blnHasNodes;
            rootNode.HasNodes   = blnHasNodes;
            rootNode.Loaded     = false;
        }
Beispiel #6
0
        private void shareList_SelectedIndexChanged(object sender, EventArgs e)
        {
            readBox.Checked  = false;
            writeBox.Checked = false;
            if (shareList.SelectedItems.Count == 1)
            {
                ListViewItem item = shareList.SelectedItems[0];
                try
                {
                    CUserEntity       user = (CUserEntity)(item.Tag);
                    List <CACLEntity> acls = user.GetUserACLs();
                    foreach (CACLEntity acl in acls)
                    {
                        if (acl.Acl_Resource != _resourceId)
                        {
                            continue;
                        }

                        if (acl.Acl_Operation == (int)ACLOPERATION.READ)
                        {
                            readBox.Checked = true;
                        }
                        else if (acl.Acl_Operation == (int)ACLOPERATION.WRITE)
                        {
                            writeBox.Checked = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("共享数据已发生变化:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #7
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (shareList.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请选择要停止共享的用户!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (ListViewItem item in shareList.SelectedItems)
            {
                try
                {
                    if (item.Tag is CUserEntity)
                    {
                        CUserEntity user = (CUserEntity)(item.Tag);
                        _currentUser.Deny(user.Usr_Id, ACLROLETYPE.USERROLE, _resourceId);
                    }
                    else if (item.Tag is CGroupEntity)
                    {
                        CGroupEntity group = (CGroupEntity)(item.Tag);
                        _currentUser.Deny(group.Grp_Id, ACLROLETYPE.GROUPROLE, _resourceId);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("无法共享:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // refill user lists
            FillUserLists();
        }
Beispiel #8
0
        public override List <File> GetFiles(CUserEntity user, int parentId)
        {
            List <CResourceEntity> children;
            List <File>            ret = new List <File>();

            if (parentId == 0)
            {
                children = user.ListShareResources();
            }
            else
            {
                children = user.ListResources(parentId);
            }

            foreach (CResourceEntity res in children)
            {
                if (res.Res_Type != (int)RESOURCETYPE.FILERESOURCE)
                {
                    continue;
                }
                File f = new File(res.Res_Id, res.Res_Name);
                ret.Add(f);
            }

            return(ret);
        }
Beispiel #9
0
 public void Cut(CUserEntity user, int resourceId)
 {
     _currentUser = user;
     _clipMode    = ClipMode.CUTMODE;
     _resources.Clear();
     AddResource(resourceId);
 }
Beispiel #10
0
        protected CUserEntity CreateUser(CUserEntity newUser)
        {
            try
            {
                COrganizeEntity        organize    = new COrganizeEntity(_connString);
                List <COrganizeEntity> organizelst = new List <COrganizeEntity>();
                organizelst = organize.GetObjectList("this.Org_Name ='" + _orgName + "'");
                int orgRes = organizelst[0].Org_Resource;

                // create resource for user's folder
                CResourceEntity folderRes = new CResourceEntity(_connString);
                folderRes.Res_Name   = "";
                folderRes.Res_Parent = orgRes;
                folderRes.Res_Type   = (int)RESOURCETYPE.FOLDERRESOURCE;
                folderRes.Res_Id     = folderRes.Insert();

                folderRes.Res_Name = folderRes.Res_Id.ToString() + newUser.Usr_Member;
                folderRes.Update();

                // create user's folder
                //String userPath = folderRes.MakeFullPath();
                String userPath = _rootPath + "\\" + folderRes.Res_Name;
                Directory.CreateDirectory(userPath);

                // create user
                newUser.Usr_Resource = folderRes.Res_Id;
                newUser.ConnString   = _connString;
                newUser.Usr_Id       = newUser.Insert();
                return(newUser);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #11
0
        public virtual void DeleteFile(CUserEntity user, int resource)
        {
            CResourceEntity res      = new CResourceEntity(user.ConnString).Load(resource);
            String          filePath = res.MakeFullPath();

            user.DeleteResource(resource);
            System.IO.File.Delete(filePath);
        }
Beispiel #12
0
 public void Cut(CUserEntity user, List <int> resources)
 {
     _currentUser = user;
     _clipMode    = ClipMode.CUTMODE;
     _resources.Clear();
     foreach (int res in resources)
     {
         AddResource(res);
     }
 }
Beispiel #13
0
        private void mobjButtonLogon_Click(object sender, EventArgs e)
        {
            /* MD5 md5 = MD5.Create();
             * byte[] bytePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(this.mobjTextPassword.Text.Trim()));
             * string resultPwd = System.Text.UTF8Encoding.Unicode.GetString(bytePwd);
             */
            string resultPwd = CHelperClass.UserMd5(this.mobjTextPassword.Text.Trim());

            if (mobjCheckSavePassword.Checked)
            {
                Context.Cookies["Username"] = this.mobjTextUsername.Text;
                Context.Cookies["Password"] = this.mobjTextPassword.Text;

                //Context.Cookies["Password"] = this.mobjTextPassword.Text;
                //Context.Cookies["Lang"] = this.mobjComboLanguage.SelectedIndex.ToString();
            }
            else
            {
                Context.Cookies["Username"] = "";
                Context.Cookies["Password"] = "";
                //Context.Cookies["Lang"] = "0";
            }

            try
            {
                CUserEntity user = new CUserEntity(MidLayerSettings.ConnectionString);
                user = user.Login(mobjTextUsername.Text, resultPwd);
                Context.Session["CurrentUser"] = user;
                //  Context.CurrentUICulture = ((LanguageOption)mobjComboLanguage.SelectedItem).Culture;
                mobjLabelMessage.Text      = "";
                Context.Session.IsLoggedOn = true;
            }
            catch (Exception ex)
            {
                mobjLabelMessage.Text = "Invalid username or password.";
                MessageBox.Show("µÇ¼ʧ°Ü£º" + ex.ToString(), "Îĵµ¹ÜÀíϵͳ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Context.Session.IsLoggedOn = false;
            }

            /*
             *          if(this.mobjTextUsername.Text=="webgui" && this.mobjTextPassword.Text=="webgui")
             *          {
             *                  Context.Session.IsLoggedOn = true;
             *                  Context.CurrentUICulture = ((LanguageOption)mobjComboLanguage.SelectedItem).Culture;
             *                  mobjLabelMessage.Text="";
             *          }
             *          else
             *          {
             *                  mobjLabelMessage.Text = "Invalid username or password.";
             *                  Context.Session.IsLoggedOn = false;
             *          }
             */
        }
Beispiel #14
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (unshareList.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请选择要共享的用户!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!addReadBox.Checked && !addWriteBox.Checked)
            {
                MessageBox.Show("请选择共享权限!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (ListViewItem item in unshareList.SelectedItems)
            {
                try
                {
                    if (item.Tag is CUserEntity)
                    {
                        CUserEntity user = (CUserEntity)(item.Tag);
                        if (addReadBox.Checked)
                        {
                            _currentUser.Permit(user.Usr_Id, ACLROLETYPE.USERROLE, _resourceId, ACLOPERATION.READ);
                        }
                        if (addWriteBox.Checked)
                        {
                            _currentUser.Permit(user.Usr_Id, ACLROLETYPE.USERROLE, _resourceId, ACLOPERATION.WRITE);
                        }
                    }
                    else if (item.Tag is CGroupEntity)
                    {
                        CGroupEntity group = (CGroupEntity)(item.Tag);
                        if (addReadBox.Checked)
                        {
                            _currentUser.Permit(group.Grp_Id, ACLROLETYPE.GROUPROLE, _resourceId, ACLOPERATION.READ);
                        }
                        if (addWriteBox.Checked)
                        {
                            _currentUser.Permit(group.Grp_Id, ACLROLETYPE.GROUPROLE, _resourceId, ACLOPERATION.WRITE);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("无法共享:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // refill user lists
            FillUserLists();
        }
Beispiel #15
0
        public virtual void CreateFolder(CUserEntity user, int parentResource, String folderName)
        {
            CACLEntity acl = new CACLEntity(user.ConnString);

            acl.Acl_Resource  = parentResource;
            acl.Acl_Operation = (int)ACLOPERATION.WRITE;
            if (!user.CheckPrivilege(acl))
            {
                throw new Exception("没有写权限!");
            }

            user.CreateFolder(parentResource, folderName);
        }
Beispiel #16
0
        private void AddUser_Closed(object sender, EventArgs e)
        {
            UserForm userForm = (UserForm)sender;

            if (userForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                CUserEntity newUser = new CUserEntity(MidLayerSettings.ConnectionString);
                newUser.Usr_Member = userForm.Member;
                // newUser.Usr_Password = userForm.Password;

                /*MD5 md5 = MD5.Create();
                 * byte[] bytePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(userForm.Password));
                 * byte[] byteSurePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(userForm.Surepwd));
                 * string resultPwd = System.Text.UTF8Encoding.Unicode.GetString(bytePwd);
                 * string resultSurePwd = System.Text.UTF8Encoding.Unicode.GetString(byteSurePwd);
                 * if (resultPwd == resultSurePwd)
                 * {
                 *  newUser.Usr_Password = resultPwd;
                 * }
                 * else
                 * {
                 *  throw new Exception("密码与确认密码不相等!");
                 * }*/
                string pwd     = CHelperClass.UserMd5(userForm.Password);
                string surePwd = CHelperClass.UserMd5(userForm.Surepwd);
                if (pwd == surePwd)
                {
                    newUser.Usr_Password = pwd;
                }
                else
                {
                    MessageBox.Show("密码与确认密码不相等!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                newUser.Usr_Name     = userForm.UserName;
                newUser.Usr_Email    = userForm.Email;
                newUser.Usr_Organize = _currentUser.Usr_Organize;
                _currentUser.CreateNormalUser(newUser);
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建用户失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #17
0
        private void ModifyUser_Closed(object sender, EventArgs e)
        {
            UserForm userForm = (UserForm)sender;

            if (userForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                CUserEntity user = new CUserEntity(_currentUser.ConnString).Load((int)userListView.SelectedItems[0].Tag);
                user.Usr_Member = userForm.Member;
                //user.Usr_Password = userForm.Password;

                /* MD5 md5 = MD5.Create();
                 * byte[] bytePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(userForm.Password));
                 * byte[] byteSurePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(userForm.Surepwd));
                 * string resultPwd = System.Text.UTF8Encoding.Unicode.GetString(bytePwd);
                 * string resultSurePwd = System.Text.UTF8Encoding.Unicode.GetString(byteSurePwd);
                 * if (resultPwd == resultSurePwd)
                 * {
                 *   user.Usr_Password = resultPwd;
                 * }
                 * else
                 * {
                 *   throw new Exception("密码与确认密码不相等!");
                 * }*/
                string pwd     = CHelperClass.UserMd5(userForm.Password);
                string surePwd = CHelperClass.UserMd5(userForm.Surepwd);
                if (pwd == surePwd)
                {
                    user.Usr_Password = pwd;
                }
                else
                {
                    throw new Exception("密码与确认密码不相等!");
                }

                user.Usr_Name  = userForm.UserName;
                user.Usr_Email = userForm.Email;
                _currentUser.ModifyUser(user);
                this.LoadUsers();
            }
            catch (Exception ex)
            {
                MessageBox.Show("修改用户失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #18
0
        public virtual void ShareResource(CUserEntity user, int resource)
        {
            CResourceEntity res = new CResourceEntity(user.ConnString).Load(resource);
            COrganizeEntity org = new COrganizeEntity(user.ConnString).Load(user.Usr_Organize);

            if (res.IsChild(user.Usr_Resource) || (user.Usr_Type == (int)USERTYPE.ORGANIZEADMIN && res.IsChild(org.Org_ArchiveRes)))
            {
                ShareForm shareForm = new ShareForm();
                shareForm.CurrentUser = user;
                shareForm.ResourceId  = resource;
                shareForm.ShowDialog();
            }
            else
            {
                throw new Exception("不能共享此目录!");
            }
        }
Beispiel #19
0
        private void writeBox_Click(object sender, EventArgs e)
        {
            if (shareList.SelectedItems.Count == 1)
            {
                ListViewItem item     = shareList.SelectedItems[0];
                int          id       = 0;
                ACLROLETYPE  roleType = ACLROLETYPE.USERROLE;

                if (item.Tag is CUserEntity)
                {
                    CUserEntity user = (CUserEntity)(item.Tag);
                    id       = user.Usr_Id;
                    roleType = ACLROLETYPE.USERROLE;
                }
                else if (item.Tag is CGroupEntity)
                {
                    CGroupEntity group = (CGroupEntity)(item.Tag);
                    id       = group.Grp_Id;
                    roleType = ACLROLETYPE.GROUPROLE;
                }
                else
                {
                    throw new Exception("错误的数据类型: ");
                }
                try
                {
                    if (writeBox.Checked)
                    {
                        _currentUser.Permit(id, roleType, _resourceId, ACLOPERATION.WRITE);
                    }
                    else
                    {
                        _currentUser.Deny(id, roleType, _resourceId, ACLOPERATION.WRITE);
                    }

                    if (!readBox.Checked && !writeBox.Checked)
                    {
                        FillUserLists();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("共享数据已发生变化:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #20
0
 public override void FilterContextMenu(CUserEntity user, ContextMenu contextMenu)
 {
     foreach (MenuItem item in contextMenu.MenuItems)
     {
         if (item.Text == "ɾ³ýĿ¼")
         {
             item.Enabled = false;
         }
         if (item.Text == "¹²ÏíÉèÖÃ")
         {
             item.Enabled = false;
         }
         if (item.Text == "ÉêÇë¹éµµ")
         {
             item.Enabled = false;
         }
     }
 }
Beispiel #21
0
        public virtual List <File> GetFiles(CUserEntity user, int parentId)
        {
            //insert the root node
            List <CResourceEntity> children = user.ListResources(parentId);
            List <File>            ret      = new List <File>();

            foreach (CResourceEntity res in children)
            {
                if (res.Res_Type != (int)RESOURCETYPE.FILERESOURCE)
                {
                    continue;
                }
                File f = new File(res.Res_Id, res.Res_Name);
                ret.Add(f);
            }

            return(ret);
        }
Beispiel #22
0
        /// <summary>
        /// 更新文件——赵英武
        /// </summary>
        /// <param name="user"></param>
        /// <param name="resId"></param>
        /// <param name="objFileDialog"></param>
        public virtual void Update(CUserEntity user, int resId, OpenFileDialog objFileDialog)
        {
            CACLEntity acl = new CACLEntity(user.ConnString);

            acl.Acl_Resource  = resId;
            acl.Acl_Operation = (int)ACLOPERATION.WRITE;
            if (!user.CheckPrivilege(acl))
            {
                throw new Exception("没有写权限!");
            }

            String filePath;
            HttpPostedFileHandle hfh = (HttpPostedFileHandle)objFileDialog.Files[0];
            CResourceEntity      res = new CResourceEntity().Load(resId);

            user.UpdateFile(resId, hfh.PostedFileName, out filePath);
            hfh.SaveAs(filePath);
        }
Beispiel #23
0
        public virtual void DeleteFolder(CUserEntity user, int resource)
        {
            CACLEntity acl = new CACLEntity(user.ConnString);

            acl.Acl_Resource  = resource;
            acl.Acl_Operation = (int)ACLOPERATION.WRITE;
            if (!user.CheckPrivilege(acl))
            {
                throw new Exception("没有写权限!");
            }

            CResourceEntity res = new CResourceEntity(user.ConnString).Load(resource);

            String dirPath = res.MakeFullPath();

            user.DeleteResource(resource);
            System.IO.Directory.Delete(dirPath, true);
        }
Beispiel #24
0
        private void AddUser_Closed(object sender, EventArgs e)
        {
            UserForm userForm = (UserForm)sender;

            if (userForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                CUserEntity newUser = new CUserEntity(_currentUser.ConnString);
                newUser.Usr_Member = userForm.Member;
                // newUser.Usr_Password = userForm.Password;

                string pwd     = CHelperClass.UserMd5(userForm.Password);
                string surePwd = CHelperClass.UserMd5(userForm.Surepwd);
                if (pwd == surePwd)
                {
                    newUser.Usr_Password = pwd;
                }
                else
                {
                    throw new Exception("密码与确认密码不相等!");
                }

                newUser.Usr_Name     = userForm.UserName;
                newUser.Usr_Email    = userForm.Email;
                newUser.Usr_Organize = _currentUser.Usr_Organize;
                if (userForm.UserType == (int)USERTYPE.ORGANIZEADMIN)
                {
                    _currentUser.CreateAdminlUser(newUser);
                }
                else
                {
                    _currentUser.CreateNormalUser(newUser);
                }
                this.LoadUsers();
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建用户失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #25
0
        public virtual void UploadFile(CUserEntity user, int parentResource, OpenFileDialog objFileDialog)
        {
            CACLEntity acl = new CACLEntity(user.ConnString);

            acl.Acl_Resource  = parentResource;
            acl.Acl_Operation = (int)ACLOPERATION.WRITE;
            if (!user.CheckPrivilege(acl))
            {
                throw new Exception("没有写权限!");
            }

            for (int i = 0; i < objFileDialog.Files.Count; i++)
            {
                String filePath;
                HttpPostedFileHandle hfh = (HttpPostedFileHandle)objFileDialog.Files[i];;
                user.CreateFile(parentResource, hfh.PostedFileName, out filePath);
                hfh.SaveAs(filePath);
            }
        }
Beispiel #26
0
 public void Paste(CUserEntity user, int dstResid)
 {
     if (_currentUser == null || _currentUser.Usr_Id != user.Usr_Id)
     {
         throw new Exception("无法粘贴其他用户选择的资源!");
     }
     if (_clipMode == ClipMode.NONE || _resources.Count == 0)
     {
         throw new Exception("剪贴板中没有资源。");
     }
     foreach (int res in _resources)
     {
         if (_clipMode == ClipMode.COPYMODE)
         {
             _currentUser.CopyResource(res, dstResid);
         }
         else
         {
             _currentUser.CutResource(res, dstResid);
         }
     }
 }
Beispiel #27
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            if (otherUserList.SelectedItems.Count == 0)
            {
                MessageBox.Show("至少选择一个用户!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                foreach (ListViewItem lvi in otherUserList.SelectedItems)
                {
                    CUserEntity user = (CUserEntity)lvi.Tag;
                    _currentUser.AddUser2Group(_groupId, user.Usr_Id);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("修改用户组失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            FillUserLists();
        }
Beispiel #28
0
        private void DeleteFolder_Closed(object sender, EventArgs e)
        {
            if (((Form)sender).DialogResult != DialogResult.Yes)
            {
                return;
            }

            try
            {
                TreeNode node = mainTreeView.SelectedNode;
                if (node == null || (int)node.Tag <= 0)
                {
                    MessageBox.Show("选择的目录不存在", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                CUserEntity        user     = new CUserEntity();
                List <CUserEntity> userList = new List <CUserEntity>();
                userList = user.GetObjectList("this.Usr_Resource =" + (int)node.Tag);
                if (userList.Count > 0)
                {
                    MessageBox.Show("这是" + userList[0].Usr_Name + "的工作目录(根目录)!如果您想删除该目录,请直接删除该用户!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                helper.DeleteFolder(_currentUser, (int)node.Tag);

                node = node.Parent;
                if (node != null)
                {
                    ReloadTreeNode(node);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("删除目录失败!" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #29
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            if (memberBox.Text == "" || passwordBox.Text == "")
            {
                return;
            }

            try
            {
                _user = new CUserEntity(MidLayerSettings.ConnectionString);
                _user = _user.Login(memberBox.Text, passwordBox.Text);
                Context.Session["CurrentUser"] = _user;
                Context.Session.IsLoggedOn     = true;

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("登录失败:", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Context.Session.IsLoggedOn = false;
            }
        }
Beispiel #30
0
 private void menuModifyUser_Click(object sender, EventArgs e)
 {
     if (userListView.SelectedItems.Count != 1)
     {
         MessageBox.Show("必须选择一个用户!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     try
     {
         CUserEntity user     = new CUserEntity(_currentUser.ConnString).Load((int)userListView.SelectedItems[0].Tag);
         UserForm    userForm = new UserForm();
         userForm.Member   = user.Usr_Member;
         userForm.Password = user.Usr_Password;
         userForm.Surepwd  = user.Usr_Password;
         userForm.UserName = user.Usr_Name;
         userForm.Email    = user.Usr_Email;
         userForm.Closed  += new EventHandler(ModifyUser_Closed);
         userForm.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show("修改用户失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }