using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using TopWinCMS.BLL;
using TopWinCMS.Common;
namespace TopWinCMS.WebUI.Admin.Window
{
    public partial class UpPic1 : System.Web.UI.UserControl
    {
        public TextBox _PicURL;
        public DropDownList _Class;

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BT_openWindow_Click(object sender, EventArgs e)
        {
            if (_Class.SelectedValue == "0")
            {
                MsgBox.Alert("请先选择栏目");
            }

            TopWinCMS.Model.ClassInfo model = new ClassManage().EditLoad(int.Parse( _Class.SelectedValue));

            string strSaveFile = model.PicPath;

            if (string.IsNullOrEmpty(strSaveFile) == true)
            {
                strSaveFile = Config.UP;
            }

            this.FileUploader1.TempDirectory = strSaveFile;

            BT_openWindow.Visible = !BT_openWindow.Visible;
            Panel1.Visible = !Panel1.Visible;
        }

        protected void FileUploader1_FileUploaded(object sender, CuteEditor.UploaderEventArgs args)
        {
            TopWinCMS.Model.ClassInfo model = new ClassManage().EditLoad(int.Parse(_Class.SelectedValue));
            string strSaveFile = model.PicPath;

            if (string.IsNullOrEmpty(strSaveFile) == true || model == null)
            {
                strSaveFile = Config.UP;
            }
            strSaveFile += System.DateTime.Now.ToString("yyyyMMddHHmmss");

            strSaveFile += args.FileName;
            args.CopyTo(Server.MapPath(strSaveFile));
            args.Delete();
            _PicURL.Text = Server.MapPath(strSaveFile);


            BT_openWindow.Visible = !BT_openWindow.Visible;
            Panel1.Visible = !Panel1.Visible;
        }
    }
}