public string Validate(DataRecord record) { List <SHCourseRecord> courses = new List <SHCourseRecord>(); foreach (SHCourseRecord course in _studentCourseInfo.GetCourses(record.StudentNumber)) { if (record.Subjects.Contains(course.Subject)) { courses.Add(course); } } StringBuilder builder = new StringBuilder(""); foreach (SHCourseRecord course in courses) { if (string.IsNullOrEmpty(course.RefAssessmentSetupID)) { builder.AppendLine(string.Format("課程「{0}」沒有評量設定。", course.Name)); } else if (!_aeTable.ContainsKey(course.RefAssessmentSetupID)) { builder.AppendLine(string.Format("課程「{0}」評量設定有誤。", course.Name)); } else { bool found = false; foreach (string examName in _aeTable[course.RefAssessmentSetupID]) { if (examName == record.Exam) { found = true; break; } } if (!found) { builder.AppendLine(string.Format("課程「{0}」沒有試別「{1}」。", course.Name, record.Exam)); } } } return(builder.ToString()); }
public string Validate(DataRecord record) { string studentNumber = record.StudentNumber; List <string> subjects = new List <string>(record.Subjects); foreach (SHCourseRecord course in _studentCourseInfo.GetCourses(record.StudentNumber)) { subjects.Remove(course.Subject); } if (subjects.Count > 0) { StringBuilder builder = new StringBuilder(""); foreach (string s in subjects) { builder.Append(s + "、"); } string result = builder.ToString(); if (result.EndsWith("、")) { result = result.Substring(0, result.Length - 1); } if (_studentCourseInfo.ContainsStudentNumber(record.StudentNumber)) { return(string.Format("學生「{0}」並沒有修習科目「{1}」。", _studentCourseInfo.GetStudentName(record.StudentNumber), result)); } else { return(string.Empty); } } else { return(string.Empty); } }