//退课
 public bool DropCourse(int studentId, int courseId)
 {
     ICourseDao courseDao = new CourseDao(sessionFactory);
     Course selectedCourse = courseDao.Get(courseId);
     ISelectionDao selectionDao = new SelectionDao(sessionFactory);
     SelectionID selectionID = new SelectionID {
         selectionStudentID=studentId,
         selectionCourseID=courseId,
         selectionStudyYear=selectedCourse.courseStudyYear,
          selectionTerm=selectedCourse.courseTerm
     };
     Selection selection=selectionDao.Get(selectionID);
     if (null != selection)
     {
         try
         {
             selectionDao.Delete(selection);
             return true;
         }
         catch (Exception e) {
             return false;
         }
     }
     else {
         return false;
     }
 }
 public bool GetSaveName(object studentID)
 {
     TeacherController teacherController = (TeacherController)Session["teacherController"];
     string studyYear = Session["courseStudyYear"].ToString();
     string term = Session["courseTerm"].ToString();
     int courseId = Int32.Parse(Session["courseID"].ToString());
     int studentId = (Int32)studentID;
     SelectionID selectionId = new SelectionID
     {
         selectionCourseID = courseId,
         selectionStudyYear = studyYear,
         selectionTerm = term,
         selectionStudentID = studentId
     };
     Selection selection = teacherController.GetSelectionByID(selectionId);
     bool permit = (Boolean)selection.selectionScorePermit;
     return permit;
 }
 public string GetStudentScore(object studentID)
 {
     int selectionStudentScore=-1;
     if (Session["teacherController"] != null)
     {
         TeacherController teacherController = (TeacherController)Session["teacherController"];
         string studyYear = Session["courseStudyYear"].ToString();
         string term = Session["courseTerm"].ToString();
         int courseId =Int32.Parse(Session["courseID"].ToString());
         int studentId = (Int32)studentID;
         SelectionID selectionId = new SelectionID {
             selectionCourseID = courseId,
             selectionStudyYear = studyYear,
             selectionTerm = term,
             selectionStudentID = studentId
         };
         selectionStudentScore = teacherController.GetStudentScore(selectionId);
     }
     return selectionStudentScore.ToString();
 }
        public Selection GetSelectionByID(SelectionID selectionId)
        {
            ISelectionDao selectionDao = new SelectionDao(sessionFactory);
            try
            {
                return selectionDao.Get(selectionId);

            }
            catch (Exception e)
            {
                return null;
            }
        }
 public void ScoreAStudent()
 {
     int score = 60;
     string studyYear = "2012~2013";
     string term = "上";
     int courseId =1000;
     int studentId = 10000002;
     ISelectionDao selectionDao = new SelectionDao(sessionFactory);
     SelectionID seletionID = new SelectionID {
          selectionStudentID=studentId,
          selectionCourseID= courseId,
          selectionStudyYear=studyYear,
          selectionTerm=term
     };
     Selection selectedSelection = selectionDao.Get(seletionID);
     bool success;
     if (true == selectedSelection.selectionScorePermit)
     {
         selectedSelection.selectionScore = score;
         success = teacherController.ScoreStudentCourse(selectedSelection);
     }
     else {
         success=false;
     }
     Assert.AreEqual(true, success);
 }
        protected void courseStudentGridViewCommandClick(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = Int32.Parse((string)e.CommandArgument);
            if (e.CommandName == "ScoreStudent") {

                string studentID = courseStudentGridView.Rows[rowIndex].Cells[0].Text;
                int studentId = Int32.Parse(studentID);
                string editScore = ((TextBox)courseStudentGridView.Rows[rowIndex].FindControl("scoreTextBox")).Text;
                int score = Int32.Parse(editScore);
                string studyYear = Session["courseStudyYear"].ToString();
                string term = Session["courseTerm"].ToString();
                int courseId = Int32.Parse(Session["courseID"].ToString());
                SelectionID selectionId = new SelectionID
                {
                    selectionCourseID = courseId,
                    selectionStudentID = studentId,
                    selectionStudyYear = studyYear,
                    selectionTerm = term
                };

                TeacherController teacherController = (TeacherController)Session["teacherController"];
                Selection updateSelection = teacherController.GetSelectionByID(selectionId);
                updateSelection.selectionScore = score;
                teacherController.ScoreStudentCourse(updateSelection);
                //更新一次数据表
                SetBind();

            }else if(e.CommandName=="EditStudentScore"){

                TextBox scoretxb=(TextBox)courseStudentGridView.Rows[rowIndex].FindControl("scoreTextBox");
                Label scoreLab=(Label)courseStudentGridView.Rows[rowIndex].FindControl("scoreLabel");
                scoreLab.Visible=false;
                scoretxb.Visible=true;
            }
        }