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 admin_addpic : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int id = int.Parse(Request.QueryString["id"]);
        DataTable dt = DAL.DataProvider.ExecuteSql(string.Format("select top 1 picture from flash where id={0}", id));

        string pic = "";
        if (dt.Rows.Count > 0)
        {
            pic = dt.Rows[0][0].ToString();
        }

        string file = "/" + DateTime.Now.ToString("yyyyMMddHHmmss") + FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf('.'));
        FileUpload1.SaveAs(ConfigurationManager.AppSettings["pic_path"] + file);
        pic += pic.Length>0? ",":"" + file;
        DAL.DataProvider.ExecuteSql(string.Format("update flash set picture='{0}' where id={1}", pic, id));

        Response.Redirect("flash.aspx");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        int id = int.Parse(Request.QueryString["id"]);

        string swf = "/" + DateTime.Now.ToString("yyyyMMddHHmmss") + FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf('.'));
        FileUpload1.SaveAs(ConfigurationManager.AppSettings["swf_path"] + swf);

        DAL.DataProvider.ExecuteSql(string.Format("update flash set swf='{0}' where id={1}", swf, id));

        Response.Redirect("flash.aspx");
    }
}
