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.Data.SqlClient;

public partial class updateAlbum : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack )
        {
            DB db = new DB();
            int albumID = Convert.ToInt32(Request.QueryString["id"]);
            TextBox1.Text =
                    db.select_albumMore(albumID).Rows[0][0].ToString();
            TextBox2.Text =
                    db.select_albumMore(albumID).Rows[0][2].ToString();
            Image1.ImageUrl =
                    db.select_albumMore(albumID).Rows[0][1].ToString();
        }


    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DB db = new DB();
        int albumID = Convert.ToInt32(Request.QueryString["id"]);
        string albumDesc = TextBox2.Text.ToString();
        string albumName = TextBox1.Text.ToString();
        DateTime albumTime = DateTime.Now;
        string logourl = "image/" + FileUpload1.FileName;
        string exname = FileUpload1.FileName.Split('.')[1];
        if (exname.ToLower() == "jpg" || exname.ToLower() == "png" || 
             exname.ToLower() == "gif")
            {
                FileUpload1.SaveAs(Server.MapPath(logourl));
            }
       db.updateAlbum(albumID, albumDesc, albumName, albumTime, logourl);
       Response.Write("<script>alert('修改成功');location.href='default.aspx?';</script>");
                                 
    }
}
