protected void addBtn_Click(object sender, EventArgs e)
 {
     examrecordBLL ExamRecordBLL = new examrecordBLL();
     examrecord ExamRecord = new examrecord();
     string stuIdStr = Tools.safeUserInput(stuIdTB.Text.ToString().Trim());
     if (stuIdStr.Length < 1)
     {
         MessageBox.Show(this, "学生学号不能为空!");
         return;
     }
     else
     {
         ExamRecord.student = stuIdStr;
     }
     string scoreStr = Tools.safeUserInput(scoreTB.Text.ToString().Trim());
     if (scoreStr.Length < 1)
     {
         MessageBox.Show(this, "学生成绩不能为空!");
         return;
     }
     else
     {
         int scoreInt = -1;
         try
         {
             scoreInt = Convert.ToInt32(scoreStr);
         }
         catch
         {
             MessageBox.Show(this, "学生成绩只能为数字!");
             return;
         }
         if (scoreInt != -1)
             ExamRecord.score = scoreInt.ToString();
         else MessageBox.Show(this, "学生成绩只能为数字!");
     }
     string remarkStr = Tools.safeUserInput(remarkTB.Text.ToString().Trim());
     ExamRecord.remark = remarkStr;
     ExamRecord.classId = id.ToString();
     if (ExamRecordBLL.Add(ExamRecord) != 0)
     {
         MessageBox.Show(this, "添加成功!");
         GV2DataBind();
     }
     else MessageBox.Show(this, "添加失败!");
 }
 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 void uploadBtn_Click(object sender, EventArgs e)
 {
     examrecordBLL ExamRecordBLL = new examrecordBLL();
     int result = ExamRecordBLL.Add(this, excelFU,id);
     if (result == 0) MessageBox.Show(this, "上传失败!");
     else
     {
         MessageBox.Show(this, "成功导入" + result + "条成绩信息");
         GV2DataBind();
     }
 }