📄 filemain.aspx.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 Office.Model;
using Office.BLL;
public partial class File_FileManage_FileMain : System.Web.UI.Page
{
private static String FileId = null;
protected void Page_Load(object sender, EventArgs e)
{
FileId = Request.QueryString["FID"];
if (FileId != null)
{
this.ImageButton6.Enabled = true;
this.txtPath.Text = (FileInfoManager.GetFileInfoByFileId(Int32.Parse(FileId))).FilePath;
}
if (!Page.IsPostBack)
{
this.ImageButton6.Enabled = false;
if(FileId != null)
Bind(Int32.Parse(FileId));
}
else
this.ImageButton6.Enabled = true;
this.ImageButton6.PostBackUrl = "~/File/FileManage/FilePropety.aspx?FID="+FileId+"&&TT=00";
}
//根所文件地址进行数据绑定
private void Bind(String path)
{
if (path != "")
{
IList<FileInfo> file = FileInfoManager.GetFileInfoByPath(path);
if (file.Count > 0)
{
IList<FileInfo> list = FileInfoManager.GetFileInfoByParentId(file[0].FileId);
if (list.Count > 0)
GridView1.DataSource = list;
else
GridView1.DataSource = file;
}
}
else
{
GridView1.DataSource = FileInfoManager.GetFileInfoFolder();
}
GridView1.DataBind();
}
//根据文件ID进行数据绑定
private void Bind(int FileId)
{
IList<FileInfo> list = FileInfoManager.GetFileInfoByParentId(FileId);
if (list.Count == 0)
list.Add(FileInfoManager.GetFileInfoByFileId(FileId));
GridView1.DataSource = list;
GridView1.DataBind();
}
//数据行绑定事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#FFFBD1'");
e.Row.Attributes.Add("onmouseout","this.style.backgroundColor=this.oldcolor");
ImageButton img = e.Row.FindControl("ibtn_delete") as ImageButton;
if (img != null)
{
img.Attributes.Add("onclick", "JavaScript:return confirm('你确定要删除吗?')");
}
}
}
//转到
protected void ImageButton7_Click(object sender, ImageClickEventArgs e)
{
String path = txtPath.Text;
Bind(path);
}
//根据文件类型设置不同的地址
public String SetURL(String type,String FID)
{
if (type == "1")
return "FileMain.aspx?FID=" + FID;
else
return "FilePropety.aspx?FID=" + FID;
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
}
//GridView命令行处理事件
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "link")
{
Response.Redirect("FileMain.aspx?FID="+e.CommandArgument.ToString());
}
if (e.CommandName == "del")
{
Int32 id = Int32.Parse(e.CommandArgument.ToString());
Office.Model.FileInfo f = FileInfoManager.GetFileInfoByFileId(id);
f.IfDelete = 1;
FileInfoManager.ModifyFileInfo(f);
Bind(id);
}
if (e.CommandName == "detail")
{
FileInfo file = FileInfoManager.GetFileInfoByFileId(Int32.Parse(e.CommandArgument.ToString()));
if(file.FileType.FileTypeId != 1)
Response.Redirect("FilePropety.aspx?FID="+e.CommandArgument.ToString());
else
Response.Redirect("FileAddFolder.aspx?FID=" + e.CommandArgument.ToString());
}
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
Response.Write("OK");
}
protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
{
String path = txtPath.Text;
Bind(path);
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
}
protected void ImageButton6_Click(object sender, ImageClickEventArgs e)
{
if (this.txtPath.Text != "")
{
Response.Redirect("~/File/FileManage/FilePropety.aspx?FID=00");
}
}
protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -