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

📄 filemain.aspx.cs

📁 OA系统源码 办公应用软件源码 asp.net 开发
💻 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 MyOffice.Models;
using MyOffice.BLL;
/// <summary>
/// 文件管理
/// </summary>
public partial class File_FileMain : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            int notid=0;
            if (Request.QueryString["Nodid"] == null)
            {
                notid = 3;
                FileInfoModel fim = FileBLL.SeleFileId(notid);
                txtFolderPath.Text = fim.FilePath;
                DataBindsGV(3);
            }
            else {
                string cid = Request.QueryString["Nodid"].ToString();
                notid = int.Parse(cid);
                if (notid == 0)
                {
                    notid = 0;
                }
                else
                {
                    FileInfoModel fim = FileBLL.SeleFileId(notid);
                    txtFolderPath.Text = fim.FilePath;
                }
                DataBindsGV(notid);
            }
            ViewState["Nods"] = notid;
            Session["PathUrl"] = notid;
        }
    }
    //查询数据并绑定到GridView
    public void DataBindsGV(int noid)
    {
 
        List<FileInfoModel> lifin = FileBLL.SeleFileidZi(noid); {
            if (lifin.Count != 0) {
                
                gvFileInfo.DataSource = lifin;
                gvFileInfo.DataBind();
            }
        }
    }

    protected void gvFileInfo_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string commandname = e.CommandName;
        int fileid = Convert.ToInt32(e.CommandArgument);
        FileInfoModel fin = FileBLL.SeleFileId(fileid);
        if (commandname.Trim().Equals("CH")) {  
            if (fin.Filtypemodel.FileTypeName.Trim().Equals("文件夹"))
            {
                FileInfoModel fim = FileBLL.SeleFileId(fileid);
                txtFolderPath.Text = fim.FilePath;
                gvFileInfo.DataSource = null;
                gvFileInfo.DataSource = FileBLL.SeleFileidZi(fileid);
                gvFileInfo.DataBind();
            }
            else {
                Response.Redirect("FileInManager.aspx?FileId="+fileid+"&Shuxing='up'");
            }
        }
        else if (commandname.Trim().Equals("SX")) {
            if (fin.Filtypemodel.FileTypeName.Trim().Equals("文件夹"))
            {
                Response.Redirect("FileUpIn.aspx?PageId=" + fileid + "&Shuxing='up'");
            }
            else {
                Response.Redirect("FileInManager.aspx?FileId=" + fileid + "&Shuxing='up'");
            }
        }
        else if (commandname.Trim().Equals("MO")) {

        }
        else if (commandname.Trim().Equals("DE")) {
            List<AccessoryFileModel> liaccess = FileBLL.SelectFileidAcc(fileid);
            if (liaccess.Count != 0) {
                foreach (AccessoryFileModel afm in liaccess) {
                    

                    Directory.Delete(afm.AccessoryPath);
                    int nu = FileBLL.DelectAccessId(afm.AccessoryId);
                }
            }
            FileInfoModel fi = FileBLL.SeleFileId(fileid);
            Directory.Delete(fi.FilePath);
            int number = FileBLL.FangBack(fileid);
            
            if (number == 0)
            {
                Response.Write("<script>alert('删除失败!!!');</script>");
            }
            else {
              
            }
            gvFileInfo.DataSource = null;
            gvFileInfo.DataSource = FileBLL.SeleFileidZi(fin.ParentId);
            gvFileInfo.DataBind();
        }
    }
    protected void imgbtnNewFile_Click(object sender, ImageClickEventArgs e)
    {
        Session["Path"] = txtFolderPath.Text;
        int fil = int.Parse(ViewState["Nods"].ToString());
        Response.Redirect("FileInManager.aspx?FileId=" + fil);
    }
    protected void imgbtnNewFolder_Click(object sender, ImageClickEventArgs e)
    {
        Session["Path"] = txtFolderPath.Text;
        int fil = int.Parse(ViewState["Nods"].ToString());
        Response.Redirect("FileUpIn.aspx?PageId=" + fil);
    }
    protected void gvFileInfo_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}

⌨️ 快捷键说明

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