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 Spaces;
public partial class Admin_PhotoClassEdit : System.Web.UI.Page
{
    int categoryID = -1;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            categoryID = Convert.ToInt32(Request.QueryString["ID"]);
        }
        catch
        {
            categoryID = -1;
        }
        if (categoryID>0&&!IsPostBack)
            BindCategory();
        
    }
    void BindCategory()
    {
        PhotoCategory c = Photos.GetCategory(categoryID);
        albumTitle.Text = c.Name;
        albumDesc.Text = c.Description;
        albumBtn.Text = "更新";
    
    }
    protected void albumBtn_Click(object sender, EventArgs e)
    {


        string title = albumTitle.Text;
        string desc = albumDesc.Text;
        PhotoCategory c = new PhotoCategory();
        if (categoryID >0)
        {
            c = Photos.GetCategory(categoryID);
            if (c.Account == User.Identity.Name)
            {
                c.Name = title;
                c.Description = desc;
                Photos.UpdateCategory(c);
             
            }
           
        }
        else
        {
            c.Account = User.Identity.Name;
            c.Created = DateTime.Now;
            c.Description = desc;
            c.Limits = "L";
            c.MainPhotoID = -1;
            c.Name = title;
            c.NumPhotos = -1;
            c.Password = string.Empty;

            Photos.CreateCategory(c);
            
        }
        Response.Redirect("AlbumList.aspx");
    
    }
}
