Пример #1
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);
            }
        }