using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.IO;
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 MySql.Data.MySqlClient;

using Security;
namespace Security
{
    public partial class DeepSoonTheme : PageBase
    {
		protected void Page_Load(object sender, EventArgs e)
        {
			///创建数据连接对象：
			MysqlHelp mh = new MysqlHelp();
				
			string themeNameReq = Request.QueryString["themeName"];
			if(themeNameReq != null){			
				mh.Runsql("Update Theme4DeepSoon Set ThemeName='"+themeNameReq+"'");				
			}
			
			if (!IsPostBack) 
			{ 
				DataTable dt=new DataTable();
				dt = mh.GetDatabysql("Select * From Theme4DeepSoon");
				string currThemeName = "";
				if (dt.Rows.Count>0){
					currThemeName = dt.Rows[0]["ThemeName"].ToString();
				}
				else{
					mh.Runsql("insert into Theme4DeepSoon(ThemeName) Values('Default')");
					currThemeName = "Default";
				}
				
				System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(Server.MapPath("../Theme"));
				System.IO.DirectoryInfo []dirs = dirInfo.GetDirectories();
				string themeStr = "";
				string themeName = "";
				for(int i=0;i<dirs.Length;i++){
					themeName = dirs[i].Name.ToString();
					
					themeStr += "<div class='themeBox'>";
					themeStr += "<img src='../Theme/"+themeName+"/screenshot.png' class='themeImg'>";
					themeStr += "<div class='themeBanner'>";
					themeStr += "名称："+themeName+" <br>";
					if(currThemeName != themeName)
						themeStr += "<span class='themeTool'><a href='deepSoonTheme.aspx?themeName="+themeName+"'>使用该皮肤</a></span>";
					else themeStr += "<span class='themeTool'>正在使用</span>";
					themeStr += "</div>";
					themeStr += "</div>";
				}
				this.labelTheme.Text = themeStr;
			}///end if isPostBack
			
        }

    }
}