using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KstCMS.KstCMS_Manager.WebSet.Template.tmp
{
    public partial class Template_Add : KstCmsBase.WebPage.ValidationPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            OkBtn.Click += new EventHandler(OkBtn_Click);
            if (!IsPostBack)
            {
                ShowSiteDrp();
            }
        }

        void OkBtn_Click(object sender, EventArgs e)
        {
            string[] data = new string[]{
                drp_SiteList.SelectedValue,
                txt_TempName.Text.Trim(),
                txt_TempContent.Value,
                Request.QueryString.Get("TypeId"),
                "0"
           };
            KstCmsBase.DAL.Templates.TempInsert(data, "SiteID", "TempName", "TempContent", "TempType", "DefaultAct");
            ShowMsgModle("增加成功！", "location.href='" + Get_TempUrl(Request.Url.PathAndQuery) + "';");
        }

        void ShowSiteDrp()
        {
            KstCmsBase.Collection.WebSite_Collection WebSiteItems = KstCmsBase.DAL.WebSite.Get_WebSiteList(1, "SiteID", "SiteName");
            for (int i = 0; i < WebSiteItems.Count; i++)
            {
                ListItem item = new ListItem();
                item.Value = ((KstCmsBase.Entities.WebSite_ent)WebSiteItems[i]).SiteID.ToString();
                item.Text = ((KstCmsBase.Entities.WebSite_ent)WebSiteItems[i]).SiteName;
                drp_SiteList.Items.Add(item);

            }
            drp_SiteList.Items.Insert(0, new ListItem("请选择站点", "0"));
           // drp_SiteList.SelectedValue = base.DefaultSite.SiteID.ToString();
        }
    }
}