protected void LinkButton4_Click(object sender, EventArgs e)//将某作业布置给某学生 { Label1.Text = ""; if (ListBoxzuoye.SelectedIndex >= 0 & ListBoxstu.SelectedIndex >= 0 && ListBoxbanji.SelectedIndex >= 0) { string zuoyeid = ListBoxzuoye.SelectedValue; string stuusername = ListBoxstu.SelectedValue; string kechengid = Session["kechengid"].ToString(); string banjiid = ListBoxbanji.SelectedValue; if (StudentInfo.IsStuHaveZuoye(int.Parse(zuoyeid), stuusername))//判断作业是否已布置给学生 { ScriptManager.RegisterClientScriptBlock(this, typeof(string), "", "<script language='javascript'>alert('该作业在该学生作业表中已存在,无须重新布置!');</script>", false); } else { try { ZuoyeInfo.ZuoyeFenfaToStudent(zuoyeid, stuusername, kechengid, banjiid); ScriptManager.RegisterClientScriptBlock(this, typeof(string), "", "<script language='javascript'>alert('作业分发成功!');</script>", false); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this, typeof(string), "", "<script language='javascript'>alert('作业分发失败!');</script>", false); Label1.Text = ex.Message; } } } else { ScriptManager.RegisterClientScriptBlock(this, typeof(string), "", "<script language='javascript'>alert('请选择课程、班级、作业、学生!');</script>", false); } }