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.Model;
using TopWinCMS.Common;
using TopWinCMS.BLL;
namespace TopWinCMS.WebUI.Admin.Field
{
    public partial class Field_Manage : System.Web.UI.Page
    {
        FieldManage MyClassBLL = new FieldManage();

        SQLModel s_model = new SQLModel();
        int ModelID;
        protected void Page_Load(object sender, EventArgs e)
        {
            ModelID =int.Parse( Request.QueryString["ModelID"]);
            if (!IsPostBack)
            {
                RightsCheck.CheckWorkPower("M_5");

                string strPath = string.Format("{0} → 自定义字段管理", ModelManage.GetModelName(ModelID));
                LB_Path.Text = strPath;

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

            s_model.WHERE = " ModelID=" + ModelID;

            MyClassBLL.BindList(this.GV_List, PageNavigation1, s_model);

            MyJavascript.RegJS(UpdatePanel1, "attachMouseEvent('" + this.GV_List.ClientID + "');");
        }
        protected void PageNavigation1_PageChanging(object src, TopWinCMS.WebControls.PageChangingEventArgs e)
        {
            s_model.PageNo = e.NewPageIndex;
            BindList();
        }

        protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                TableCell myTableCell = e.Row.Cells[GV_List.Columns.Count - 1];
                if (myTableCell.Controls.Count > 0)
                {
                    LinkButton btnDel = (LinkButton)myTableCell.Controls[0];

                    btnDel.Attributes.Add("onclick", "return confirm('您确定要删除？');");
                }
            }
        }
        protected void GV_List_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string ID =  GV_List.DataKeys[e.RowIndex].Value.ToString() ;

            MyClassBLL.Delete(ModelID,ID,UpdatePanel1);


            BindList();
        }

    }
}