public List<Exercise> SelectExercise()
        {
            using (SqlConnection con = DBHelp.GetConnection())
            {
                string sql = "select * from Exercise";
                SqlCommand cmd = new SqlCommand(sql, con);
                con.Open();
                List<Exercise> list = new List<Exercise>();
                SqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    Exercise p = new Exercise();
                    p.ExerciseID = Convert.ToInt32(dr["ExerciseID"].ToString());
                    p.CourseID = Convert.ToInt32(dr["CourseID"].ToString());
                    p.ExerciseName = dr["ExerciseName"].ToString();
                    list.Add(p);
                }
                dr.Close();
                con.Close();
                return list;
            }
        }
 public List<Exercise> selectSingQuestion(int ExerciseId)
 {
     using (SqlConnection con = DBHelp.GetConnection())
     {
         string sql = @"SELECT  SingleProblem.Answer FROM SingleProblem,ExerciseDetail where ExerciseDetail.TitleID=SingleProblem.ID and ExerciseDetail.Type = '单选题'and ExerciseDetail.ExerciseID='" + ExerciseId + "'";
         SqlCommand cmd = new SqlCommand(sql, con);
         con.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         List<Exercise> list = new List<Exercise>();
         while (dr.Read())
         {
             Exercise Sing = new Exercise();
             Sing.SingleAnswer = dr["Answer"].ToString();
             list.Add(Sing);
         }
         return list;
     }
 }
        public Exercise GetExercise(int exerciseID)
        {
            using (SqlConnection con = DBHelp.GetConnection())
            {
                string sql = "select * from Exercise where ExerciseID = " + exerciseID.ToString();
                SqlCommand cmd = new SqlCommand(sql, con);
                con.Open();
                Exercise e = new Exercise();
                SqlDataReader dr = cmd.ExecuteReader();

                if (dr.Read())
                {
                    e.ExerciseID = Convert.ToInt32(dr["ExerciseID"].ToString());
                    e.CourseID = Convert.ToInt32(dr["CourseID"].ToString());
                    e.ExerciseName = dr["ExerciseName"].ToString();
                }
                dr.Close();
                con.Close();
                return e;
            }
        }