⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recyclebin.aspx.cs

📁 办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using Office.BLL;
using Office.Model;

public partial class File_RecycleBin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
            Bind();
    }
    //数据绑定
    private void Bind()
    {
        this.GridView1.DataSource = FileInfoManager.GetFileInfoByDelete();
        this.GridView1.DataBind();
    }

    private string fileIds = "";
    private string accessoryIds = "";
    //GridView命令行处理事件
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //恢复
        if (e.CommandName == "restoration")
        {
            int fileid = Int32.Parse(e.CommandArgument.ToString());
            Office.Model.FileInfo file = FileInfoManager.GetFileInfoByFileId(fileid);
            file.IfDelete = 0;
            FileInfoManager.ModifyFileInfo(file);
            Bind();
            //操作日志
            OperateLog operate = new OperateLog();
            operate.ObjectId = file.FileId.ToString();
            operate.User = (UserInfo)Session["User"];
            operate.OperateName = "还原";
            operate.OperateDesc = "从回收站还原文件";
            operate.OperateTime = DateTime.Now;
            OperateLogManager.AddOperateLog(operate);
        }
        //删除
        if (e.CommandName == "dele")
        {
            int fileid = Int32.Parse(e.CommandArgument.ToString());
            fileIds = fileid + ",";
            FileInfoManager.DeleteFileInfoByIds(this.getFileIds(fileid));
            AccessoryFileManager.DeleteAccessoryFileByAccessoryIds(this.getAccessoryIds(fileid));
            Bind();
            //操作日志
            OperateLog operate = new OperateLog();
            operate.ObjectId = fileid.ToString();
            operate.User = (UserInfo)Session["User"];
            operate.OperateName = "彻底删除";
            operate.OperateDesc = "从回收站彻底删除文件";
            operate.OperateTime = DateTime.Now;
            OperateLogManager.AddOperateLog(operate);
        }
    }
    //得到文件IDs字符串
    private string getFileIds(Int32 fileId)
    {
        IList<Office.Model.FileInfo> list = FileInfoManager.GetFileInfosByParentId(fileId);
        foreach (Office.Model.FileInfo file in list)
        {
            fileIds += file.FileId.ToString() + ",";
            string path = file.FilePath;
            if (System.IO.File.Exists(path))
                File.Delete(path);
            getFileIds(file.FileId);
        }
        //去掉字符串最后面的一个字符
        return fileIds == "" ? "0" : fileIds.Substring(0, fileIds.Length - 1);
    }
    //得到附件Ids字符串
    private string getAccessoryIds(Int32 fileId)
    {
        IList<AccessoryFile> list = AccessoryFileManager.GetAllAccessoryFiles(fileId);
        foreach (AccessoryFile accessory in list)
        {
            accessoryIds += accessory.AccessoryId.ToString() + ",";
            string path = accessory.AccessoryPath;
            if (System.IO.File.Exists(path))
                File.Delete(path);
        }
        //去掉字符串最后面的一个字符
        return accessoryIds == "" ? "0" : accessoryIds.Substring(0, accessoryIds.Length - 1);
    }
    //数据行绑定事件
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "oldcolor=this.style.backgroundColor;this.style.backgroundColor='lightYellow'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=oldcolor");

            ImageButton ibn = e.Row.FindControl("ImageButton2") as ImageButton;
            if (ibn != null)
            {
                ibn.Attributes.Add("onclick", "return confirm('删除该文件,其对应的附件、包括的子文件都会被删除,你确定要删除吗?')");
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -