protected void Button3_Click(object sender, EventArgs e) { int classId = 0; int score = 0; string remark = ""; try { classId = Convert.ToInt32(TextBox1.Text.Trim()); score = Convert.ToInt32(TextBox2.Text.Trim()); remark = Tools.safeUserInput(TextBox3.Text.Trim()); } catch { MessageBox.Show(this, "输入格式不对,请重新输入!"); } classdetailBLL ClassDetailBLL = new classdetailBLL(); if (!ClassDetailBLL.Exists(classId)) { MessageBox.Show(this, "课程不存在!"); return; } examrecord ExamRecord = new examrecord(); examrecordBLL ExamRecordBLL = new examrecordBLL(); ExamRecord.classId = classId.ToString(); ExamRecord.score = score.ToString(); ExamRecord.student = Session["StuId"].ToString().Trim(); ExamRecord.remark = remark; try { ExamRecordBLL.Add(ExamRecord); } catch { MessageBox.Show(this, "添加成绩失败!"); } MessageBox.Show(this, "添加" + ClassDetailBLL.GetModel(classId).teacher.Trim() + "的" + ClassDetailBLL.GetModel(classId).name + ",分数:"+score+"。"); GridView1.DataBind(); }
protected bool isClassIdExisted(int classId) { classdetailBLL ClassDetailBLL = new classdetailBLL(); return ClassDetailBLL.Exists(classId); }