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;

public partial class ModuleManage_ModuleInfo : System.Web.UI.Page
{
    ModuleManage modulemanage = new ModuleManage();
    HostManage hostmanage = new HostManage();
    protected void Page_Load(object sender, EventArgs e)
    {
        dlBind();
    }
    protected void lnkbtnOne_Click(object sender, EventArgs e)
    {
        labPage.Text = "1";
        dlBind();
    }
    protected void lnkbtnUp_Click(object sender, EventArgs e)
    {
        labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) - 1);
        dlBind();
    }
    protected void lnkbtnNext_Click(object sender, EventArgs e)
    {
        labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) + 1);
        dlBind();
    }
    protected void lnkbtnBack_Click(object sender, EventArgs e)
    {
        labPage.Text = labBackPage.Text;
        dlBind();
    }
    public void dlBind()
    {
        int curpage = Convert.ToInt32(labPage.Text);
        PagedDataSource ps = new PagedDataSource();
        ps.DataSource = modulemanage.GetAllModule("tb_Module").Tables[0].DefaultView;
        ps.AllowPaging = true; //是否可以分页
        ps.PageSize = 8; //显示的数量
        ps.CurrentPageIndex = curpage - 1; //取得当前页的页码
        lnkbtnUp.Enabled = true;
        lnkbtnNext.Enabled = true;
        lnkbtnBack.Enabled = true;
        lnkbtnOne.Enabled = true;
        if (curpage == 1)
        {
            lnkbtnOne.Enabled = false;//不显示第一页按钮
            lnkbtnUp.Enabled = false;//不显示上一页按钮
        }
        if (curpage == ps.PageCount)
        {
            lnkbtnNext.Enabled = false;//不显示下一页
            lnkbtnBack.Enabled = false;//不显示最后一页
        }
        this.labBackPage.Text = Convert.ToString(ps.PageCount);
        dlInfo.DataSource = ps;
        dlInfo.DataKeyField = "版块编号";
        dlInfo.DataBind();
    }
    public string getHost(string str)
    {
        hostmanage.ModuleID = str;
        if (hostmanage.FindHostByMID(hostmanage, "tb_Host").Tables[0].Rows.Count > 0)
        {
            string host = hostmanage.FindHostByMID(hostmanage, "tb_Host").Tables[0].Rows[0][0].ToString();
            return host;
        }
        else
            return null;
    }
}
