static int FirstSxNum = 0;/*声明变量,初始化为0,用于判断筛选条件是否改变*/ /// <summary> /// 加载科目列表信息 /// </summary> /// <param name="apge">当前页面</param> public void Load_Student() { string Bj_Name = txtClassName.Value.Trim() == "按姓名,学号,班级,用户名模糊查询" ? "" : txtClassName.Value.Trim(); if (Bj_Name != "按姓名,学号,班级,用户名模糊查询" && Bj_Name != "" && FirstSxNum == 0) { page = 1; FirstSxNum = 1; } studentList = TbStudentManager.GetAllStuInfo(len, page, Bj_Name); Count = TbStudentManager.GetAllStuInfo(Bj_Name).Rows.Count; if (Count == 0) { Maxapge = 1; } else { if (Count % len == 0) //当数据库数据能整除10,最大页面数取Count/len的商 { Maxapge = Count / len; } else { Maxapge = Count / len + 1;//当数据库数据不能整除10,最大页面数取Count/len的商+1. } } }
/// <summary> /// 导出学生信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnExport_Click(object sender, EventArgs e) { string path = Server.MapPath("file") + "\\studentinfo.xls"; if (File.Exists(path)) { File.Delete(path); } DataTable dt = TbStudentManager.GetAllStuInfo(); PublicClass.SaveToFile(PublicClass.GetTable(dt, "学员信息"), Server.MapPath("file") + "\\studentinfo.xls"); Response.Redirect("file/studentinfo.xls"); }