计算机毕业设计班级课程维护功能介绍:
(2)班级课程维护
在此页面根据班级,根据课程来维护班级课程,并显示班级课程列表信息。如图:
以下是引用片段:
其实现代码如下: protected void Page_Load(object sender, EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { //显示班级课程信息 this.GridView1.DataSource = Database.Get_Table("SELECT * FROM 班级 INNER JOIN 班级课程 ON 班级.班级代码 = 班级课程.班级代码 INNER JOIN 课程 ON 班级课程.课程代码 = 课程.课程代码 "); this.GridView1.DataBind(); } } protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { string Key = this.GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)]["班课代码"].ToString(); if (e.CommandName == "Del") { if (Database.Get_Table("select * from 学生成绩 where 班课代码=" + Key + "").Rows.Count > 0) { Page.alert(班级课程信息使用中');"); return; } //删除班级课程信息 Database.ExecSql("delete from 班级课程 where 班课代码=" + Key + ""); this.GridView1.DataSource = Database.Get_Table("SELECT * FROM 班级 INNER JOIN 班级课程 ON 班级.班级代码 = 班级课程.班级代码 INNER JOIN 课程 ON 班级课程.课程代码 = 课程.课程代码 "); this.GridView1.DataBind(); } } } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //绑定班级 绑定课程 DropDownList1.DataTextField = "班级名称"; DropDownList1.DataValueField = "班级代码"; DropDownList1.DataSource = Database.Get_Table("select * from 班级"); DropDownList1.DataBind(); DropDownList2.DataTextField = "课程名称"; DropDownList2.DataValueField = "课程代码"; DropDownList2.DataSource = Database.Get_Table("select * from 课程"); DropDownList2.DataBind(); } } protected void Button1_Click(object sender, EventArgs e) { //保存新的班级课程 if (Database.Get_Table("select * from 班级课程 where 班级代码="+ DropDownList1.SelectedValue +" and 课程代码="+ DropDownList2.SelectedValue +"").Rows.Count > 0) { Page.alert('信息重复');"); return; } Database.ExecSql("insert into 班级课程(班级代码,课程代码,任课教师) values(" + DropDownList1.SelectedValue + "," + DropDownList2.SelectedValue + ",'" + this.TextBox1.Text + "')");
|
〖资料来源:计算机毕业论文 www.xiaoniu168.com〗
第9页为计算机毕业论文班主任管理模块介绍......