Beispiel #1
0
        /// <summary>
        /// 根据题目ID获取题目信息
        /// </summary>
        /// <param name="titleID">题目ID</param>
        /// <returns></returns>
        public Title GetTiByTitleID(int titleID)
        {
            TeacherService teacherService = new TeacherService();
            string         sql            = string.Format("SELECT * FROM Title WHERE TitleID={0}", titleID);
            Title          title          = new Title();
            int            teacherID      = 0;

            title.Student = null;
            SqlDataReader reader = DBHelper.GetReader(sql);

            if (reader.Read())
            {
                title.TitleID      = Convert.ToInt32(reader["TitleID"]);
                title.TitleName    = reader["TitleName"].ToString();
                title.Counts       = Convert.ToInt32(reader["Counts"]);
                title.State        = Convert.ToInt32(reader["State"]);
                title.HasChooseNum = Convert.ToInt32(reader["HasChooseNum"]);
                try
                {
                    teacherID = Convert.ToInt32(reader["TeacherID"]);
                }
                catch (Exception)
                {
                }
                title.Description = reader["Description"].ToString();
                reader.Close();
                title.Teacher = teacherService.GetTeacherByID(teacherID);
            }
            reader.Close();
            return(title);
        }
Beispiel #2
0
        /// <summary>
        /// 获取题目列表
        /// </summary>
        /// <param name="teacherID">教师登录(工号)ID</param>
        /// <returns></returns>
        public List <Title> GetTitleListByTeacherId(int teacherID)
        {
            StudentService studentService = new StudentService();
            string         sql            = string.Format("SELECT * FROM Title WHERE TeacherID={0}", teacherID);
            TeacherService teacherService = new TeacherService();

            List <Title> list      = new List <Title>();
            int          teacherId = 0;
            int          studentId = 0;
            DataTable    table     = DBHelper.GetDataSet(sql);

            foreach (DataRow rows in table.Rows)
            {
                Title title = new Title();
                title.TitleID      = Convert.ToInt32(rows["TitleID"]);
                title.Counts       = Convert.ToInt32(rows["Counts"]);
                title.TitleName    = rows["TitleName"].ToString();
                title.State        = Convert.ToInt32(rows["State"]);
                title.HasChooseNum = Convert.ToInt32(rows["HasChooseNum"]);
                title.Description  = rows["Description"].ToString();
                try
                {
                    teacherId = Convert.ToInt32(rows["TeacherID"]);
                }
                catch (Exception)
                {
                }
                try
                {
                    studentId = Convert.ToInt32(rows["StudentID"]);
                }
                catch (Exception)
                {
                }
                title.Teacher = teacherService.GetTeacherByID(teacherId);
                title.Student = studentService.GetStudentBySID(studentId);
                list.Add(title);
            }
            return(list);
        }