⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 std_findstudentbasicinforesult.aspx.cs

📁 该系统是一个集成多功能的信息管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
/// <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.Data.SqlClient;
using System.Text;
using System.IO;
using System.Drawing;

public partial class manager_sysManager_studentManage_std_findStudentBasicInfoResult : 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["StdBasicInfoSQL"]) == "")
        {
            Response.Write("<script language=javascript>location='../../../TS_ManagerLogin.aspx'</script>");
            return;
        }
        if (Session["StdBasicInfoSQL"].ToString() != "" && Session["StdBasicCurrentlyGrade"].ToString() != "")
        {

            string Sql = "select * from ts_xs_basicInfo where currentlyGrade ='" + (Session["StdBasicCurrentlyGrade"].ToString()) + "' " + Session["StdBasicInfoSQL"].ToString() + " order by id desc";
            DataSet ds = new DataSet();
            ds = bc.GetDataSet(Sql, "ts_xs_basicInfo");

            GridView1.DataSource = ds.Tables["ts_xs_basicInfo"];
            pageTotalNumber = ds.Tables["ts_xs_basicInfo"].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 <= GridView1.Rows.Count - 1; i++)
            {
                DataRowView rowview;
                string fromArea;
                if (GridView1.PageIndex == 0)
                {
                    rowview = ds.Tables["ts_xs_basicInfo"].DefaultView[i];
                    fromArea = Convert.ToString(rowview["fromArea"]);
                    GridView1.Rows[i].Cells[10].Text = bc.SubStr(fromArea, 15);
                }
                else
                {
                    rowview = ds.Tables["ts_xs_basicInfo"].DefaultView[i + (12 * GridView1.PageIndex)];
                    fromArea = Convert.ToString(rowview["fromArea"]);
                    GridView1.Rows[i].Cells[10].Text = bc.SubStr(fromArea, 15);
                }
            }

            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_basicInfo where currentlyGrade ='" + (Session["StdBasicCurrentlyGrade"].ToString()) + "' " + Session["StdBasicInfoSQL"].ToString() + " order by id desc";
        DataSet ds = new DataSet();
        ds = bc.GetDataSet(Sql, "ts_xs_basicInfo");
        DataTable dt = ds.Tables["ts_xs_basicInfo"];
        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["adminClass"].ToString());
            sb.Append("\t" + r["teachedClass"].ToString());
            sb.Append("\t" + r["fromArea"]).ToString();
            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 GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        this.Label1.Text = Convert.ToString(e.NewPageIndex + 1);
        this.bind();
        int pageSize = GridView1.PageCount;
        currentPageNumber = e.NewPageIndex + 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 GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        int i;
        //执行循环,保证每条数据都可以更新
        for (i = 0; i < GridView1.Rows.Count; i++)
        {
            //首先判断是否是数据行
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //当鼠标停留时更改背景色
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#dee9f9'");
                //当鼠标移开时还原背景色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            }
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
            {
                ((LinkButton)e.Row.Cells[12].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除学号为: \"" + e.Row.Cells[3].Text + "\" 姓名为 \"" + e.Row.Cells[4].Text + "\" 的学生基本信息吗?')");
            }
        }
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
        con.Open();
        string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
        SqlCommand scd = new SqlCommand("delete  from ts_xs_basicInfo where id='" + id + "'", con);
        scd.ExecuteNonQuery();
        con.Close();
        this.bind();
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
        Session["StdBasicInfoList"] = id.ToString();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -