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.systag
{
    public partial class EditSysTAG : KstCmsBase.WebPage.FrmControl
    {
        string TagID = System.Web.HttpContext.Current.Request.QueryString.Get("TagID");
        protected void Page_Load(object sender, EventArgs e)
        {
            OkBtn.Click += new EventHandler(OkBtn_Click);
            if (!IsPostBack)
            {
                GetSysTAG();
                SetControl();
            }
        }

        void OkBtn_Click(object sender, EventArgs e)
        {
            string[] data = new string[]{
                drp_Lblist.SelectedValue,
                txt_TagName.Text.Trim(),
                txt_SysTAG.Text.Trim(),
                txt_TagContent.Value
           };
            KstCmsBase.DAL.Tag.SysTAG.SysTAG_Update(Convert.ToInt32(TagID), data, "TagLBID", "TagName", "SysTAG", "TagDESC");
            Response.Redirect("SystagList.aspx?lbid=" + drp_Lblist.SelectedValue);
        }

        void GetSysTAG()
        {
            KstCmsBase.Entities.Tag.SysTAG_ent SysTAG = KstCmsBase.DAL.Tag.SysTAG.GetSystagInfo(Convert.ToInt32(TagID));
            ShowDrpLB();
            drp_Lblist.SelectedValue = SysTAG.TagLBID.ToString();
            txt_TagName.Text = SysTAG.TagName;
            txt_SysTAG.Text = SysTAG.SysTAG;
            txt_TagContent.Value = SysTAG.TagDESC;
        }

        void ShowDrpLB()
        {
            KstCmsBase.Collection.Tag.SysTAGLBCollection SysTAGLBS = KstCmsBase.DAL.Tag.SysTAG.GetSysTAGLB_Items();
            foreach (KstCmsBase.Entities.Tag.SysTAGLB_ent SysTAGLB in SysTAGLBS)
            {
                ListItem item = new ListItem();
                item.Value = SysTAGLB.SysLBID.ToString();
                item.Text = SysTAGLB.LbNAME;
                drp_Lblist.Items.Add(item);
            }
            drp_Lblist.Items.Insert(0, new ListItem("所属分类", "0"));
        }

        void SetControl()
        {
            string[] Cons = new string[]{
                "所属分类~!",
                "标签标识~!",
                "系统标签~!"
            };
            base.Set_Control(Cons, drp_Lblist, txt_TagName, txt_SysTAG);
            OkBtn.Enabled = isAdmin;
        }
    }
}