using System;
using System.IO;
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 NickLee.Common.Providers;
using NickLee.Common;

namespace MYAPP.Manage.CustomMAP.Project
{
    public partial class List_Accessories_Info : MyApp.Web.UI.UserPage
    {
        string _Root_Dir = "/map/Project/";
        public string _File_Dir = "";

        public string _Info_ID = "";
        public string _Str_Dir = "accessories";
        override protected void AppInit()//程序基本信息初始化
        {
            try
            {
                _Str_Dir = Request.QueryString["dir"];
                _Info_ID = Request.QueryString["Info_ID"];
            }
            catch (Exception)
            {

            }

            if (_Info_ID != "")
            {

            }
            else
            {
                this.ButFileUpload.Enabled = false;
            }

            _File_Dir = String.Format("{0}{1}/{2}/", _Root_Dir, _Info_ID, _Str_Dir);
        }

        override protected void DataInit()//数据初始化
        {
            MyApp.Components.Accessories acc = new MyApp.Components.Accessories();
            DataTable dt = acc.GetFiles(Server.MapPath(_File_Dir));
            rp_list.DataSource = dt;
            rp_list.DataBind();
        }

        override protected void pl_del()
        {
            try
            {
                string fileurl = Server.MapPath(_File_Dir + "/" + COE.Components.Encrypt.DecryptString(Request.QueryString["file_name"].Trim()));
                File.Delete(fileurl);
            }
            catch (Exception) { }
            Response.Redirect(String.Format("List_Accessories_Info.aspx?curl={0}&dir={1}&Info_ID={2}", Request["curl"], _Str_Dir, _Info_ID));
        }

        protected void ButFileUpload_Click(object sender, EventArgs e)
        {
            MyApp.Components.Accessories.UploadFile(_File_Dir);
            Response.Redirect(String.Format("List_Accessories_Info.aspx?curl={0}&dir={1}&Info_ID={2}", Request["curl"], _Str_Dir, _Info_ID));
        }
    }
}