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 TopWinCMS.BLL;
using TopWinCMS.Common;
namespace TopWinCMS.WebUI.Admin.Common
{
    public partial class Tags : System.Web.UI.Page
    {
        SQLModel s_model = new SQLModel();
        int ModelID;
        protected void Page_Load(object sender, EventArgs e)
        {
            ModelID =int.Parse(Request.QueryString["ModelID"]);
            if (!IsPostBack)
            {
                RightsCheck.CheckWorkRight("OP", true);
                BindList();
            }
        }

        public void BindList()
        {
            GV_List.EmptyDataTemplate = TopWinCMS.WebFactory.PageBase.GetTemplate(this);

            s_model.WHERE = "ModelID=" + ModelID;

            string strTitle = "Tags管理";
            if (TB_KeyWord.Text.Trim().Length > 0)
            {
                s_model.WHERE += string.Format(" and TagName like '%{0}%'", MyString.SQL_ESC(TB_KeyWord.Text));
                strTitle += string.Format(" → 搜索“{0}”", TB_KeyWord.Text.Trim());
                this.Title = strTitle;

                LB_Path.Text = string.Format("{0} → <a href='Tags.aspx?ModelID={1}'>Tags管理</a>→ 搜索“{2}”",
                ModelManage.GetModelName(ModelID),
                ModelID,
                TB_KeyWord.Text.Trim());
            }
            else
            {
                this.Title = strTitle;

                LB_Path.Text = string.Format("{0} → <a href='Tags.aspx?ModelID={1}'>Tags管理</a>",
                ModelManage.GetModelName(ModelID),
                 ModelID
                     );
            }
            s_model.PageSize = PageNavigation1.PageSize;

            new TopWinCMS.BLL.TagsManage().BindList(GV_List, PageNavigation1, s_model);
        }


        protected void PageNavigation1_PageChanging(object src, TopWinCMS.WebControls.PageChangingEventArgs e)
        {
            s_model.PageNo = e.NewPageIndex;
            BindList();
        }

        protected void BT_Search_Click(object sender, EventArgs e)
        {
            BindList();
        }
    }
}
