/// <summary> /// Trả về Danh sách các Exercise thuộc exerciseSet cho trước. /// </summary> /// <param name="type"><see cref="ExerciseSetType"/></param> /// <returns>Danh sách các Exercise. Nếu có lỗi, trả về null.</returns> /// <remarks>LƯU Ý: Để tiết kiệm thời gian thì hàm này sẽ không trả về nội dung của các bài tập. /// Nghĩa là các <see cref="CExercise"/> trong này chỉ có ID và ExName là nên dùng.</remarks> public CExercise[] LoadExerciseList(ExerciseSetType type) { try { DataRow[] arrRows = m_dtExercise.Select("ExSetID = " + (int)type); List<CExercise> lsRet = new List<CExercise>(); foreach (DataRow dtRow in arrRows) { CExercise ex = new CExercise(); ex.ExID = (int)dtRow[0]; ex.ExName = (string)dtRow[2]; string sDataFile = (string)dtRow[3]; ex.BeginInstruction = (int)dtRow[4]; ex.EndInstruction = (int)dtRow[5]; //StreamReader streamFile = new StreamReader(CurrentPath + sDataFile); //while (!streamFile.EndOfStream) //{ // ex.AddString(streamFile.ReadLine()); //} lsRet.Add(ex); } return lsRet.ToArray(); } catch (System.Exception /*ex*/) { return null; } }
public CExercise LoadExercise(int iExID) { try { DataRow[] arrRows = m_dtExercise.Select("ID=" + iExID.ToString()); if (arrRows != null && arrRows.Length > 0) { CExercise ex = new CExercise(); DataRow dtRow = arrRows[0]; ex.ExID = (int)dtRow[0]; ex.ExName = (string)dtRow[2]; string sDataFile = (string)dtRow[3]; ex.BeginInstruction = (int)dtRow[4]; ex.EndInstruction = (int)dtRow[5]; /************************************************************/ /* CurrentPath: duong dan khong dung? /************************************************************/ StreamReader streamFile = new StreamReader(CurrentPath + sDataFile); while (!streamFile.EndOfStream) { ex.AddString(streamFile.ReadLine()); } return ex; } } catch { } return null; }