commonaddfile.aspx.cs

来自「很好的啊!中小型企业用的」· CS 代码 · 共 46 行

CS
46
字号
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;

public partial class Common_CommonAddFile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        tbName.Text = "";
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        FileManage Myfile = new FileManage();
        string fileName = tbName.Text;
        string fileAddress = FileAddress.PostedFile.FileName;
        string path = "",savePath="",filename,Timestr;
        if (fileAddress != "")
        {
            filename = fileAddress.Substring(fileAddress.LastIndexOf("\\") + 1);
            Timestr = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            Timestr = Timestr + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString();
            savePath = savePath + Server.MapPath(Request.ApplicationPath) + "/File/" + filename;// 
            FileAddress.PostedFile.SaveAs(savePath);
            path = "/File/" +Timestr+ filename;
        }       
        int userID = int.Parse(Session["Userid"].ToString()); 
        int departId = int.Parse(Session["DepartId"].ToString());
        string Ftype;
        Ftype = rbtnFileType.SelectedItem.Value.ToString();
        Myfile.CommentAddFile(fileName, path,userID,0,departId,Ftype);
        lbMessage.Text = "添加成功!";
    }
}

⌨️ 快捷键说明

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