using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TopWinCMS.BLL;
using TopWinCMS.Model;
using TopWinCMS.Common;

namespace TopWinCMS.WebUI.Admin
{
    public partial class Admin_Member_Message : System.Web.UI.Page
    {
        SQLModel s_model = new SQLModel();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
             

                Bind();
            }
        }
        private void Bind()
        {
            GV_List.EmptyDataTemplate = TopWinCMS.WebFactory.PageBase.GetTemplate(this);
            if (Request["Action"] == null)
            {
                L_Path.Text = Config.SiteName + " → <a href=\"Member.aspx\">会员中心</a> → <a href=\"Message.aspx\">短消息管理</a>";
                
            }
            else
            {
                DDL_Sort.SelectedValue = Request["Sort"];
                TB_KeyWord.Text = Request["Keyword"];
                L_Path.Text = Config.SiteName + " → <a href=\"Member.aspx\">会员中心</a> → <a href=\"Message.aspx\">短消息管理</a> → 短信搜索";

                s_model.WHERE = " " + Request["Sort"] + " like '%" + MyString.SQL_ESC(Request["Keyword"]) + "%'";
            }

            new MessageManage().BindList(GV_List, PageNavigation1, s_model);
            
        }
        protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                TableCell myTableCell= e.Row.Cells[7];//删除
                LinkButton btnDel = (LinkButton)myTableCell.Controls[0];
                btnDel.Attributes.Add("onclick", "return confirm('您确定要删除？');");
            }
        }
        protected void GV_List_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int index = Convert.ToInt32(e.CommandArgument);
            string ID = GV_List.DataKeys[index].Value.ToString();
            if (e.CommandName == "Delete")
            {
                new MessageManage().Delete(ID,UpdatePanel1);
                Bind();
            }

        }
        protected void BT_Search_Click(object sender, EventArgs e)
        {
            Response.Redirect("Message.aspx?Action=Search&Sort=" + DDL_Sort.SelectedValue + "&Keyword=" + TB_KeyWord.Text.Trim());
        }
        protected void BT_OK_Click(object sender, EventArgs e)
        {
            new MessageManage().BatchToDo(GV_List, DDL_BatchToDo, UpdatePanel1);
            Bind();

        }
        protected void GV_List_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

        }

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

            Bind();
        }
    }

}