myexampredict.ascx.cs

来自「学生成绩管理系统」· CS 代码 · 共 80 行

CS
80
字号
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 TeachHelper.BusinessLogicLayer;

public partial class TeachHelper_Controls_MyExamPredict : System.Web.UI.UserControl
{
    int departmentId;
    int grade;
    int majorId;
    int classes;
    DateTime beginDate;
    DateTime endDate;
    Student my;

    protected void Page_Load(object sender, EventArgs e)
    {       

        //对于没有数字的内容,下面这行完全满足要求,但加了数字就不行,必须调用OnItemDataBound
        this.GridViewExamPredict.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");

        if (!IsPostBack)
        {
            InitDate();
            BindData();
        }
    }

    protected void ButtonSubmite_Click(object sender, EventArgs e)
    {
        BindData();
    }

    private void BindData()
    {
        if (!Roles.IsUserInRole("学生"))
        {
            return;
        }

        my = new Student();

        departmentId = my.DepartmentId;
        grade = my.Grade;
        majorId = my.MajorId;
        classes = my.Classes;
        beginDate = Convert.ToDateTime(this.TextBoxBeginDate.Text);
        endDate = Convert.ToDateTime(this.TextBoxEndDate.Text);

        DataSet ds = Exam.GetCollectByDepartmentIdGradeMajorIdClassTime(departmentId, grade, majorId, classes, beginDate, endDate);

        if (ds.Tables[0].Rows.Count == 0)
        {
            this.LabelMessage.Text = "没有您要查询的数据";
            this.LabelMessage.Visible = true;
            this.GridViewExamPredict.Visible = false;
        }
        else
        {
            this.GridViewExamPredict.DataSource = ds;
            this.GridViewExamPredict.DataBind();
            this.LabelMessage.Visible = false;
            this.GridViewExamPredict.Visible = true;
        }
    }

    private void InitDate()
    {
        this.TextBoxBeginDate.Text = DateTime.Today.ToShortDateString();
        this.TextBoxEndDate.Text = DateTime.Today.AddMonths(1).ToShortDateString();
    }
}

⌨️ 快捷键说明

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