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 JuSNS.UI.Control;
using JuSNS.Model;

namespace JuSNS.Web.system.help
{
    public partial class index : JuSNS.UI.Page.ManagePage
    {
        protected string sort = "help";
        JuSNS.Home.Help help = new JuSNS.Home.Help();
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string type = Request.QueryString["Type"];

                if (type == "del")
                {
                    if (help.DeleteHelp(int.Parse(Request.QueryString["id"])) == 1)
                    {
                        Response.Redirect("index.aspx");
                    }
                    else
                    {
                        PageError("删除帮助信息失败!", "index.aspx");
                    }
                }
                else
                {
                    if (!IsPostBack)
                    {
                        LoadList();
                    }
                }
            }
            catch { }
        }

        /// <summary>
        /// 加载分页
        /// </summary>
        /// <param name="PageIndex">当前页数</param>
        protected void LoadList()
        {
            int r, p, PageIndex = 0;
            PageIndex = Convert.ToInt32(Request.QueryString["Page"]);
            DataTable dt = null;

            if (Key.Text.Trim() != "")
            {
                SqlConditionInfo st = new SqlConditionInfo("@SN", Key.Text, TypeCode.String);
                st.Blur = 3;
                dt = JuSNS.Home.UtilPage.GetPage("Search_HelpList_aspx", PageIndex, 20, out r, out p, st);
            }
            else
            {
                dt = JuSNS.Home.UtilPage.GetPage("HelpList_aspx", PageIndex, 20, out r, out p, null);
            }
            if (dt != null)
            {
                Rpt_UserList.DataSource = dt;
                Rpt_UserList.DataBind();
            }
            //判断是否调用分页
            if (r > 20)
            {
                DivPage.InnerHtml = PageNavigator.Pagination(PageIndex, p, "index.aspx");
            }
        }

        /// <summary>
        /// 执行搜索过程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
                LoadList();
        }
    }
}

