subject.aspx.cs

来自「本在线考试系统采用了面向对象的分析和设计」· CS 代码 · 共 54 行

CS
54
字号
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 ExaminationSystem.BLL.Service;
using ExaminationSystem.BLL.Domain;

public partial class Teacher_Subject : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        GridView1.DataSource = new SubjectService().GetAll();
        GridView1.DataBind();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        long subjectId = long.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
        try
        {
            new SubjectService().DeleteById(subjectId);
        }
        catch (Exception ex)
        {
            Label1.Text = ex.Message;
        }
        BindData();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string subjectName = TextBox1.Text;
        Subject subject = new Subject(subjectName);
        new SubjectService().Save(subject);
        BindData();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        new QuestionContentService().ClearUselessQuestionContent();
    }
}

⌨️ 快捷键说明

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