📄 std_findpoorstdinforesult.aspx.cs
字号:
/// <summary>
/// 哈尔滨师范大学教务系统开发
/// 作者:易继勇
/// 邮箱:yijiyong100@163.com
/// qq:610068468
/// 哈尔滨师范大学教务平台图片展示地址:http://photo.sina.com.cn/yijiyong100
/// 如果您有什么问题,将您的问题发送至邮箱yijiyong100@163.com,欢迎大家和我交流讨论,多多希望您提出您宝贵的意见!
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 System.IO;
using System.Text;
using System.Data.SqlClient;
using System.Drawing;
public partial class manager_sysManager_studentManage_std_findPoorStdInfoResult : System.Web.UI.Page
{
BaseClass bc = new BaseClass();
int currentPageNumber;
int pageTotalNumber = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (Convert.ToString(Session["manName"]) == "")
{
Response.Write("<script language=javascript>location='../../../TS_ManagerLogin.aspx'</script>");
return;
}
if (!IsPostBack)
{
this.bind();
if (pageTotalNumber != 0)
{
int pageSize = GridView1.PageCount;
this.totalNumber.Text = Convert.ToString(pageSize);
for (int i = 0; i < pageSize; i++)
{
this.pageNumber.Items.Add(new ListItem(Convert.ToString(i + 1)));
}
this.Label1.Text = "1";
currentPageNumber = 1;
if (pageSize == 1)
{
this.firstPage.Enabled = false;
this.upPage.Enabled = false;
this.lastPage.Enabled = false;
this.downPage.Enabled = false;
}
else if (pageSize > 1)
{
if (currentPageNumber == 1)
{
this.firstPage.Enabled = false;
this.upPage.Enabled = false;
this.lastPage.Enabled = true;
this.downPage.Enabled = true;
}
else if (currentPageNumber == pageSize)
{
this.lastPage.Enabled = false;
this.downPage.Enabled = false;
this.upPage.Enabled = true;
this.firstPage.Enabled = true;
}
else
{
this.lastPage.Enabled = true;
this.upPage.Enabled = true;
this.downPage.Enabled = true;
this.firstPage.Enabled = true;
}
}
}
}
}
protected void bind()
{
if (Convert.ToString(Session["poorStdInfoSQL"]) == "")
{
Response.Write("<script language=javascript>location='../../../TS_ManagerLogin.aspx'</script>");
return;
}
if (Session["poorStdInfoSQL"].ToString() != "" && Session["poorStdGrade"].ToString() !="")
{
string Sql = "select * from ts_xs_poorStdInfo where grade ='" + Math.Abs(Convert.ToInt32(Session["poorStdGrade"].ToString())) + "' " + Session["poorStdInfoSQL"].ToString() + " order by id desc";
DataSet ds = new DataSet();
ds = bc.GetDataSet(Sql, "ts_xs_poorStdInfo");
GridView1.DataSource = ds.Tables["ts_xs_poorStdInfo"];
pageTotalNumber = ds.Tables["ts_xs_poorStdInfo"].Rows.Count;
GridView1.DataKeyNames = new string[] { "id" };
GridView1.DataBind();
int pageSize = GridView1.PageCount;
this.totalNumber.Text = Convert.ToString(pageSize);
this.pageNumber.Items.Clear();
for (int i = 0; i < pageSize; i++)
{
this.pageNumber.Items.Add(new ListItem(Convert.ToString(i + 1)));
}
//this.pageNumber.Text = Convert.ToString(currentPageNumber);
}
if (GridView1.Rows.Count > 0)
{
int pageSize = GridView1.PageCount;
this.search.Text = "一共搜索到" + pageTotalNumber + "条等级考试成绩信息. 共" + pageSize + "页";
}
else
{
this.Label1.Text = "0";
this.lastPage.Enabled = false;
this.upPage.Enabled = false;
this.downPage.Enabled = false;
this.firstPage.Enabled = false;
this.jump.Enabled = false;
this.export.Enabled = false;
this.selectAll.Enabled = false;
this.delete.Enabled = false;
}
}
protected void export_Click(object sender, EventArgs e)
{
Export("application/ms-excel", "贫困生信息报表.xls");
}
private void Export(string FileType, string FileName)
{
this.bind();
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["strcon"]);
con.Open();
string Sql = "select * from ts_xs_poorStdInfo where grade ='" + Math.Abs(Convert.ToInt32(Session["poorStdGrade"].ToString())) + "' " + Session["poorStdInfoSQL"].ToString() + " order by id desc";
DataSet ds = new DataSet();
ds = bc.GetDataSet(Sql, "ts_xs_poorStdInfo");
DataTable dt = ds.Tables["ts_xs_poorStdInfo"];
StringBuilder sb = new StringBuilder();
sb.Append("学号\t身份证号\t姓名\t学院\t专业\t家庭人口\t年收入\t人均收入");
StringWriter sw = new StringWriter();
sw.WriteLine(sb.ToString());
foreach (DataRow r in dt.Rows)
{
sb = new StringBuilder();
sb.Append(r["studyNumber"].ToString());
sb.Append("\t" + r["IDcardNumber"].ToString());
sb.Append("\t" + r["studentName"].ToString());
sb.Append("\t" + r["college"].ToString());
sb.Append("\t" + r["speciality"].ToString());
sb.Append("\t" + r["totalPopulation"].ToString());
sb.Append("\t" + r["yearIncome"].ToString());
sb.Append("\t" + r["averageIncome"]);
sw.WriteLine(sb.ToString());
}
sw.Close();
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;// 指定返回的是一个不能被客户端读取的流,必须被下载
Response.ContentEncoding = System.Text.Encoding.Default;//.GetEncoding("GB2312");
Response.Write(sw);// 把流发送到客户端
Response.End();
con.Close();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
protected void selectAll_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
if (this.selectAll.Checked == true)
{
cbox.Checked = true;
}
else
{
cbox.Checked = false;
}
}
}
protected void delete_Click(object sender, EventArgs e)
{
int number = 0;
ArrayList AL = new ArrayList();
for (int i = 0; i <= GridView1.Rows.Count -1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
if (cbox.Checked == true)
{
AL.Add(i);
}
}
if (AL.Count > 0)
{
for (int i = 0; i < AL.Count - 1; i++)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["strcon"]);
con.Open();
string id = GridView1.DataKeys[(int)AL[i]].Value.ToString();
string SQL = "delete from ts_xs_poorStdInfo where id ='" + id + "'";
bool ss = bc.ExecSQL(SQL);
if (bc.ExecSQL(SQL))
{
number++;
}
else
{
Response.Write(bc.MessageBox("数据提交失败,网络忙!请稍后再试!"));
}
con.Close();
}
this.bind();
if (number == AL.Count)
{
Response.Write(bc.MessageBox("数据删除成功!"));
}
}
else
{
Response.Write(bc.MessageBox("请您选择要删除的项!"));
}
}
protected void firstPage_Click(object sender, EventArgs e)
{
this.GridView1.PageIndex = 0;
this.Label1.Text = "1";
this.bind();
this.pageNumber.Text = "1";
currentPageNumber = 1;
int pageSize = GridView1.PageCount;
if (pageSize == 1)
{
this.firstPage.Enabled = false;
this.upPage.Enabled = false;
this.lastPage.Enabled = false;
this.downPage.Enabled = false;
}
else if (pageSize > 1)
{
if (currentPageNumber == 1)
{
this.firstPage.Enabled = false;
this.upPage.Enabled = false;
this.lastPage.Enabled = true;
this.downPage.Enabled = true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -