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;

public partial class Bloger_BlogManage_UpLoad : System.Web.UI.Page
{
    private string name;
    protected void Page_Load(object sender, EventArgs e)
    {
        
        this.name = User.Identity.Name;
        this.TextBox1.Text = this.name;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string path = @"D:\homework2_beta1\UpFile\" + this.name + FileUpload1.FileName;
        string fileName = this.name + this.FileUpload1.FileName;

        if (File.Exists(path))
        {
            Response.Write("<script>alert('文件已存在')</script>");
        }
        else
        {
            this.FileUpload1.SaveAs(path);
            SqlDataSource1.Insert();
        }
    }
    protected void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e)
    {
        e.Command.Parameters["@bloger_name"].Value = this.name;
        e.Command.Parameters["@pub_date"].Value = DateTime.Now;
        e.Command.Parameters["@file_name"].Value = this.name + this.FileUpload1.FileName;
        e.Command.Parameters["@description"].Value = this.TextBox2.Text;
    }
}
