public void InitList() { if (SchoolYearList == null) { SchoolYearList = new ObservableCollection <string>(); } if (TermList == null) { TermList = new ObservableCollection <string>(); } foreach (var item in this) { MainList.Add(item); if (!SchoolYearList.Contains(item.SchoolYear)) { SchoolYearList.Add(item.SchoolYear); } //过滤出所有的学年和学期 if (!TermList.Contains(item.Term)) { TermList.Add(item.Term); } } }
public void AddRecord(string schoolYear, string term, string subject, string credit, string score, string reScore, string secondFlag, string reLearnScore, string _subjectType) { var temp = new TRData() { SchoolYear = schoolYear, Term = term, Subject = subject, Credit = credit, Score = score, SecondFlag = secondFlag, ReScore = reScore, ReLearnScore = reLearnScore, SubjectType = _subjectType }; Add(temp); //向主表添加成绩 MainList.Add(temp); if (!SchoolYearList.Contains(schoolYear)) { SchoolYearList.Add(schoolYear); } //过滤出所有的学年和学期 if (!TermList.Contains(term)) { TermList.Add(term); } }