📄 checkscore.aspx.cs
字号:
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.Linq;
using System.Collections.Generic;
public partial class DesktopModules_Score_CheckScore : System.Web.UI.Page
{
private int nScoreID = -1;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
///显示班级的数据
BindClassData();
BindCourseData();
if (ClassList.Items.Count > 0)
{
ClassList.SelectedIndex = 0;
BindStudentData(Int32.Parse(ClassList.Items[0].Value));
}
if (CourseList.Items.Count > 0)
{
CourseList.SelectedIndex = 0;
}
}
}
private void BindClassData()
{
///定义获取数据的类
ClassM gClass = new ClassM();
Table<Class> recg = gClass.GetClasss();
///设定控件的数据源
ClassList.DataSource = recg;
///设定控件的Text属性和Value属性
ClassList.DataTextField = "Desn";
ClassList.DataValueField = "ClassID";
///绑定控件的数据
ClassList.DataBind();
}
private void BindStudentData(int nClassID)
{
///定义获取数据的类
StudentM student = new StudentM();
IList<Student> recd = student.GetStudentByClass(nClassID);
///设定控件的数据源
StudentList.DataSource = recd;
///设定控件的Text属性和Value属性
StudentList.DataTextField = "Name";
StudentList.DataValueField = "StudentID";
///绑定控件的数据
StudentList.DataBind();
}
private void BindCourseData()
{
///定义获取数据的类
CourseM course = new CourseM();
Table<Course> recc = course.GetCourses();
///设定控件的数据源
CourseList.DataSource = recc;
///设定控件的Text属性和Value属性
CourseList.DataTextField = "Desn";
CourseList.DataValueField = "CourseID";
///绑定控件的数据
CourseList.DataBind();
}
private void BindScoreData(int nStudentID, int nCourseID)
{
///定义获取数据的类
ScoreM score = new ScoreM();
Score recs = score.GetScoreByStudentCourse(nStudentID,nCourseID);
if (recs!=null)
{
Mark.Text = recs.Mark.ToString();
}
else
{
Mark.Text = "无成绩";
}
}
protected void ClassList_SelectedIndexChanged(object sender, EventArgs e)
{
if (ClassList.SelectedIndex <= -1)
{
StudentList.Items.Clear();
///显示操作结果信息
Response.Write("<script>window.alert('" + ASPNET35System.OPERATIONNOSELECTMESSAGE + "')</script>");
return;
}
///重新显示学生信息
BindStudentData(Int32.Parse(ClassList.SelectedValue));
}
protected void AddStudent_Click(object sender, EventArgs e)
{
if (StudentList.SelectedIndex <= -1)
{
///显示操作结果信息
Response.Write("<script>window.alert('" + ASPNET35System.OPERATIONNOSELECTMESSAGE + "')</script>");
return;
}
Name.Text = StudentList.SelectedItem.Text;
if (CourseList.SelectedIndex > -1)
{
///显示学生的成绩
BindScoreData(Int32.Parse(StudentList.SelectedValue), Int32.Parse(CourseList.SelectedValue));
}
}
protected void CheckBtn_Click(object sender, EventArgs e)
{
if (StudentList.SelectedIndex <= -1)
{
///显示操作结果信息
Response.Write("<script>window.alert('" + ASPNET35System.OPERATIONNOSELECTMESSAGE + "')</script>");
return;
}
if (CourseList.SelectedIndex <= -1)
{
///显示操作结果信息
Response.Write("<script>window.alert('" + ASPNET35System.OPERATIONNOSELECTMESSAGE + "')</script>");
return;
}
///如果页面输入内容合法
if (Page.IsValid == true)
{
///定义类
ScoreM score = new ScoreM();
try
{
///修改成绩
score.CheckScore(Int32.Parse(StudentList.SelectedValue), Int32.Parse(CourseList.SelectedValue));
///显示操作结果信息
Response.Write("<script>window.alert('" + ASPNET35System.OPERATIONUPDATESUCCESSMESSAGE + "')</script>");
}
catch (Exception ex)
{
///显示修改操作中的失败、错误信息
Response.Redirect("~/DesktopModules/ErrorPage.aspx?ErrorUrl="
+ ASPNET35System.RedirectErrorUrl(Request.RawUrl)
+ "&ErrorMessage=" + ex.Message.Replace("\n", " "));
}
}
}
protected void ReturnBtn_Click(object sender, EventArgs e)
{
///返回管理页面
Response.Redirect("~/DesktopModules/Score/ScoreManage.aspx");
}
protected void CourseList_SelectedIndexChanged(object sender, EventArgs e)
{
if (StudentList.SelectedIndex <= -1)
{
///显示操作结果信息
Response.Write("<script>window.alert('" + ASPNET35System.OPERATIONNOSELECTMESSAGE + "')</script>");
return;
}
if (CourseList.SelectedIndex <= -1)
{
///显示操作结果信息
Response.Write("<script>window.alert('" + ASPNET35System.OPERATIONNOSELECTMESSAGE + "')</script>");
return;
}
///显示学生的成绩
BindScoreData(Int32.Parse(StudentList.SelectedValue), Int32.Parse(CourseList.SelectedValue));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -