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 System.Xml;
using TopWinCMS.BLL;
using TopWinCMS.Common;
using TopWinCMS.Model;
namespace TopWinCMS.WebUI.Admin.ControlPanel
{
    public partial class TopWinCMSSetting : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RightsCheck.CheckWorkPower("S_1");
                if (Config.DAL == "TopWinCMS.AccessDAL")
                {
                    if (RightsCheck.HasRight("S_9"))
                    {
                        Access.Visible = true;
                    }
                    else
                    {
                        Access.Visible = false;
                    }
                    SqlServer.Visible = false;
                }
                else
                {
                    Access.Visible = false;
                    if (RightsCheck.HasRight("S_9"))
                    {
                        SqlServer.Visible = true;
                    }
                    else
                    {
                        SqlServer.Visible = false;
                    }
                }

                try
                {
                    TB_ConnectionAccess.Text = Config.ConnectionAccess;

                    TB_ConnectionSqlServer.Text = Config.ConnectionSqlServer;

                    TB_SiteName.Text = Config.SiteName;
                    TB_UP.Text = Config.UP;
                    TB_WebSiteDomainName.Text = Config.DomainName;
                    TB_WatherMakePath.Text = Config.DrawingWaterPath;
                    NTB_transparent.Text = Config.DWPtransparent.ToString();
                    NTB_right.Text = Config.DWPright.ToString();
                    NTB_bottom.Text = Config.DWPbottom.ToString();
                    CB_Static.Checked = Config.Static;
                    CB_UrlRewrite.Checked = Config.UrlRewrite;

                }
                catch (Exception ex)
                {
                    MsgBox.Alert(ex.Message.Replace(@"\", @"\\"), UpdatePanel1);
                }
            }
        }

        protected void BT_OK_Click(object sender, EventArgs e)
        {
            try
            {
                if (RightsCheck.HasRight("S_9"))
                {
                    if (Config.DAL == "TopWinCMS.AccessDAL")
                    {
                        Config.ConnectionAccess = TB_ConnectionAccess.Text;
                    }
                    else
                    {
                        Config.ConnectionSqlServer = TB_ConnectionSqlServer.Text;
                    }
                }

                Config.SiteName = TB_SiteName.Text;
                Config.UP = TB_UP.Text;
                Config.DomainName = TB_WebSiteDomainName.Text.Trim();

                Config.DrawingWaterPath = TB_WatherMakePath.Text;
                Config.DWPtransparent = Convert.ToInt32(NTB_transparent.Text);
                Config.DWPright = Convert.ToInt32(NTB_right.Text);
                Config.DWPbottom = Convert.ToInt32(NTB_bottom.Text);
                Config.Static = CB_Static.Checked ;
                Config.UrlRewrite = CB_UrlRewrite.Checked;

                MsgBox.Alert("保存成功!", UpdatePanel1);
            }
            catch (Exception Ex)
            {
                MsgBox.Alert(Ex.Message.Replace(@"\", @"\\"), UpdatePanel1);
            }
        }
    }
}