📄 fileupin.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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.BLL;
using MyOffice.Models;
public partial class File_FileUpIn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//取出文件Id的值
int filed = int.Parse(Request.QueryString["PageId"].ToString());
//根据文件Id取出文件信息
FileInfoModel fim = FileBLL.SeleFileId(filed);
//判断是否是修改
if (Request.QueryString["Shuxing"] != null)
{
txtFolderName.Text = fim.FileName;
lblFileLocation.Text = fim.FilePath;
txtRemark.Text = fim.Remark;
lblCreateDate.Text = fim.CreateDate + "";
lblFileOwner.Text = fim.Userinmo.UserName;
}
//判断是否是添加
else {
lblFileLocation.Text = fim.FilePath;
lblCreateDate.Text = DateTime.Now.ToString();
UserInfoModel ui = (UserInfoModel)Session["User"];
lblFileOwner.Text = ui.UserName;
}
}
}
protected void imgbtnExit_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("FileMain.aspx");
}
protected void imgbtnSaveExit_Click(object sender, ImageClickEventArgs e)
{
//取出文件Id的值
int filed = int.Parse(Request.QueryString["PageId"].ToString());
//根据文件Id取出文件信息
FileInfoModel fim = FileBLL.SeleFileId(filed);
//判断是否是修改
if (Request.QueryString["Shuxing"] != null)
{
FileInfoModel newFile = new FileInfoModel();
newFile.FileId = fim.FileId;
newFile.FileName = txtFolderName.Text;
newFile.FileType = fim.FileType;
newFile.Remark = txtRemark.Text;
newFile.FileOwner = fim.FileOwner;
newFile.CreateDate = DateTime.Now;
newFile.ParentId = fim.ParentId;
newFile.IfDelete = fim.IfDelete;
FileInfoModel fimfo = FileBLL.SeleFileId(fim.ParentId);
//修改文件夹路径
string path = fimfo.FilePath + "\\" + txtFolderName.Text;
newFile.FilePath = path;
int number = FileBLL.UpdatePage(newFile);
if (number != 0)
{
Directory.Move(fim.FilePath, path);
Response.Redirect("FileMain.aspx");
}
else
{
Response.Write("<script>alert('文件修改失败!!!');</script>");
}
}
else {
string path = lblFileLocation.Text + "\\" + txtFolderName.Text;
//判断文件夹是否存在
if (!File.Exists(path))
{
Directory.CreateDirectory(path);
FileInfoModel newfiles = new FileInfoModel();
newfiles.FileName = txtFolderName.Text;
newfiles.FileType = 1;
newfiles.Remark = txtRemark.Text;
newfiles.FileOwner = lblFileOwner.Text;
newfiles.CreateDate = DateTime.Now;
newfiles.ParentId = int.Parse(Request.QueryString["PageId"].ToString());
newfiles.IfDelete = 0;
newfiles.FilePath = path;
int number = FileBLL.InsertPage(newfiles);
if (number != 0)
{
Response.Redirect("FileMain.aspx");
}
else {
Response.Write("<script>alert('文件添加失败');</script>");
}
}
else {
Response.Write("<script>alert('此文件夹已存在');</script>");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -