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.mytag
{
    public partial class EditVarTAG :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)
            {
                SetControl();
                Get_VarTag();
            }
        }

        void OkBtn_Click(object sender, EventArgs e)
        {
            string[] data = new string[]{
                drp_Lblist.SelectedValue,
                txt_TagName.Text.Trim(),
                "<!-kst."+txt_VarTAG.Text.Trim()+"-!>",
                txt_TagContent.Value
            };
            KstCmsBase.DAL.Tag.TagTEMP.VarTAG_Update(Convert.ToInt32(TagID), data, "TagLBID", "TagName", "VarTAG", "TagContent");
            ShowMsgModle("修改成功！", "location.href='VarTAGLIST.aspx?lbid" + drp_Lblist.SelectedValue + "';");
        }

        void Get_VarTag()
        {
            KstCmsBase.Entities.Tag.VarTAG_ent VarTAG = KstCmsBase.DAL.Tag.TagTEMP.GetVarTAG(Convert.ToInt32(TagID));
            ShowdrpVarlblist();
            drp_Lblist.SelectedValue = VarTAG.TagLBID.ToString();
            txt_TagName.Text = VarTAG.TagName;
            txt_VarTAG.Text = VarTAG.VarTAG.Replace("<!-kst.", "").Replace("-!>", "");
            txt_TagContent.Value = VarTAG.TagContent;
        }

        void ShowdrpVarlblist()
        {
            KstCmsBase.Collection.Tag.VarLBTAGCollection VarLBTAG_ITEMS = KstCmsBase.DAL.Tag.TagTEMP.GetVarLBTAGCollection();
            foreach (KstCmsBase.Entities.Tag.VarLBTAG lbitem in VarLBTAG_ITEMS)
            {
                ListItem item = new ListItem();
                item.Value = lbitem.VarLBID.ToString();
                item.Text = lbitem.VarNAME;
                drp_Lblist.Items.Add(item);
            }
            drp_Lblist.Items.Insert(0, new ListItem("请选择所属类别！", "0"));

        }
        void SetControl()
        {
            string[] Cons = new string[] { "选择所属分类~!", "变量标识~!", "变量标签~noChinese!", "标签内容~!" };
            base.Set_Control(Cons, drp_Lblist, txt_TagName, txt_VarTAG, txt_TagContent);

        }
    }
}