int pc = 2;
protected void Page_Load(object sender, EventArgs e)
{
//控制菜单
object obj = Request.QueryString["temp"];
if (obj == null)
{
ViewState["temp"] = 1;
}
else
{
ViewState["temp"] = obj;
}
Page.RegisterStartupScript("", "<script>yangshi(" + Convert.ToInt32(ViewState["temp"]) + ");</script>");
//注册ajaxPro,括号中的参数是当前的类名
AjaxPro.Utility.RegisterTypeForAjax(typeof(WXContract));
if (!IsPostBack)
{
Server.Execute("LoginAPI.aspx");
string Cookie = Request.Cookies["username"].Value;
string[] Cookies = Cookie.Split(',');
//a1,userid=54,departid=39,username1=a1,chakanlist=False,TouXiang=,depname=��Ӫ��
ViewState["uid"] = Cookies[1].Split('=')[1];
ViewState["did"] = Cookies[2].Split('=')[1];
ViewState["PageIndex"] = 0;
ViewState["PageCount"] = ContractManageBLL.GetContractInfoList(pc, 0, Convert.ToInt32(ViewState["uid"]), Convert.ToInt32(ViewState["temp"]), Convert.ToInt32(ViewState["did"])).Tables[0].Rows[0][0];
ShowDataSource( Convert.ToInt32(ViewState["PageCount"]),Convert.ToInt32(ViewState["PageIndex"]));
}
}
//窗体加载时显示合同列表
public void ShowDataSource(int zs, int ys)
{
lblShow.Text = "总共<font color='red'>" + zs + "</font>条记录 第<font color='red'>" + (ys+1) + "</font>页";
zs = (int)System.Math.Ceiling(Convert.ToDouble(zs) / pc);
lblShow.Text += "/共<font color='red'>" + zs + "</font>页";
dlHTList.DataSource = ContractManageBLL.GetContractInfoList(pc, ys, Convert.ToInt32(ViewState["uid"]), Convert.ToInt32(ViewState["temp"]), Convert.ToInt32(ViewState["did"])).Tables[1];
dlHTList.DataBind();
}
//首页
protected void LinkButton1_Click(object sender, EventArgs e)
{
ViewState["PageIndex"] = 0;
ShowDataSource(Convert.ToInt32(ViewState["PageCount"]), 0);
}
//末页
protected void LinkButton4_Click(object sender, EventArgs e)
{
int res = Convert.ToInt32(ViewState["PageCount"]);
int last = (int)System.Math.Ceiling(Convert.ToDouble(res) / pc);
ViewState["PageIndex"] = (last - 1);
ShowDataSource(res, (last-1));
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
//上一页
if ((int)ViewState["PageIndex"]>0)
{
ViewState["PageIndex"] = (int)ViewState["PageIndex"] - 1;
ShowDataSource(Convert.ToInt32(ViewState["PageCount"]), Convert.ToInt32(ViewState["PageIndex"]));
}
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
int res = Convert.ToInt32(ViewState["PageCount"]);
int last = (int)System.Math.Ceiling(Convert.ToDouble(res) / pc);
//下一页
if ((int)ViewState["PageIndex"]<last-1)
{
ViewState["PageIndex"] = (int)ViewState["PageIndex"] + 1;
ShowDataSource((int)ViewState["PageCount"], (int)ViewState["PageIndex"]);
}
}