using System;
using System.Data;
using System.Configuration;
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.OleDb;

/// <summary>
/// BasePage 的摘要说明
/// </summary>
public partial class BasePage : System.Web.UI.Page
{
    public BasePage()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }
    public SiteInfo getSiteInfo()
    {
        string sql = "SELECT*FROM SITEINFO WHERE ID=1";
        SiteInfo s = null;
        if (WebClass.GetCache("SITEINFO") == null)
        {
            OleDbDataReader dr = SqlHelper.ExecuteReader(sql);
            
            if (dr.Read())
            {
                s = new SiteInfo(dr["siteName"].ToString(), dr["siteKeys"].ToString(), dr["siteDesc"].ToString(), dr["SiteBeiAn"].ToString(),dr["tname"].ToString(),dr["tUrl"].ToString());
                WebClass.SetCache("SITEINFO", s);
            }
        }
        else 
        {
            s =(SiteInfo) WebClass.GetCache("SITEINFO");
        }


        return s;
        
    }

    public bool CheckLogin()
    {
        if (Session["admin"] == null) 
        {
            this.Page.ClientScript.RegisterStartupScript(typeof(string),Guid.NewGuid().ToString(),"<script>parent.location.href='login.aspx';</script>");
            //this.Response.Redirect("Login.aspx"); 
            return false;
        } else  return true; 
    }

    public bool CheckIsLogin()
    {
        if (Session["admin"] == null)
            return false;
        else
            return true;
    }

}

public class SiteInfo
{
    public SiteInfo(string siteName,string siteKey,string siteDesc,string siteBeiAn,string tname,string tUrl)
    {
        this._siteName = siteName;
        this._siteKey = siteKey;
        this._siteDesc = siteDesc;
        this._siteBeiAn = siteBeiAn;
        this._tName = tname;
        this._tUrl = tUrl;
    }
    private string _siteBeiAn;
    private string _siteName;
    private string _siteKey;
    private string _siteDesc;
    private string _tName;
    private string _tUrl;
    public string SiteName
    {
        get { return this._siteName; }
        set { this._siteName = value; }
    }
    public string SiteKey
    {
        get { return this._siteKey; }
        set { this._siteKey = value; }
    }
    public string SiteDesc
    {
        get { return this._siteDesc; }
        set { this._siteDesc = value; }
    }
    public string SiteBeiAn
    {
        get { return this._siteBeiAn; }
        set { this._siteBeiAn = value; }
    }
    public string TName
    {
        get { return this._tName; }
        set { this._tName = value; }
    }
    public string TUrl
    {
        get { return this._tUrl; }
        set { this._tUrl = value; }
    }
}
