private void btnViewClassresult_Click(object sender, RoutedEventArgs e) { if (SelectedClassID > 0 && SelectedSectionID > 0 && SelectedExamID > 0) { ClassResultCard = null; SubjectList = ClassSubjectRepo.GetSelectedSubjects(SelectedClassID); int count = 2; for (int i = count; i < 20; i++) { grid.Columns[i].Visibility = System.Windows.Visibility.Collapsed; grid.Columns[i].Header = ""; } foreach (var subject in SubjectList) { grid.Columns[count].Visibility = System.Windows.Visibility.Visible; grid.Columns[count].Header = subject.Description; count++; } IEnumerable <StudentSubjectMarks> results = StudentSubjectMarksRepo.GetClassResult(SelectedExamID, SessionID, SelectedSectionID, SelectedClassID); IEnumerable <Student> studentsList = StudentRepo.GetAll().Where(p => p.ClassID == SelectedClassID && p.SectionID == SelectedSectionID); foreach (var student in studentsList) { IEnumerable <StudentSubjectMarks> subjectResult = results.Where(p => p.StudentID == student.StudentID); ClassResult classResult = new ClassResult(); classResult.StudentName = student.FullName; classResult.RoleNumber = student.StudentID.ToString(); count = 1; foreach (var item in SubjectList) { StudentSubjectMarks rs = subjectResult.Where(p => p.SubjectID == item.SubjectID).FirstOrDefault(); PropertyInfo propertyInfo = classResult.GetType().GetProperty("Subject" + count); if (rs != null) { propertyInfo.SetValue(classResult, Convert.ChangeType(rs.ObtainedMarks, propertyInfo.PropertyType), null); } else { propertyInfo.SetValue(classResult, Convert.ChangeType(0, propertyInfo.PropertyType), null); } count++; } ClassResultCard = ClassResultCard.Add(classResult); } } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (FormMode == FormModes.Edit || FormMode == FormModes.View) { ClassDetail = ClassRepo.FindByID(_classid); SelectedSubjectList = ClassSubjectRepo.GetSelectedSubjects(_classid); UnSelectedSubjectList = ClassSubjectRepo.GetUnSelectedSubjects(_classid); } if (FormMode == FormModes.New) { UnSelectedSubjectList = SubjectRepo.GetAll(); } }
public void SetSubjectList(int classID) { var subjects = ClassSubjectRepo.GetSelectedSubjects(classID); if (subjects != null) { List <CustomDropDownValues> _list = new List <CustomDropDownValues>(); foreach (var item in subjects) { CustomDropDownValues _temp = new CustomDropDownValues { DisplayName = item.Description, DisplayID = item.SubjectID.ToString() }; _list.Add(_temp); } SubjectDropDown = _list; } else { SubjectDropDown = null; } }
private void btnViewClassMarks_Click(object sender, RoutedEventArgs e) { if (SelectedClassID > 0 && SelectedSectionID > 0 && SelectedStudenID > 0) { IEnumerable <StudentSubjectMarks> results = StudentSubjectMarksRepo.GetSingleStudentResult(SelectedStudenID, SessionID, SelectedSectionID, SelectedClassID); IEnumerable <Subject> subjectList = ClassSubjectRepo.GetSelectedSubjects(SelectedClassID); foreach (var subject in subjectList) { IEnumerable <StudentSubjectMarks> subjectResult = results.Where(p => p.SubjectID == subject.SubjectID); StudentResultCard resultCard = new StudentResultCard(); int count = 1; foreach (var item in ExamList) { StudentSubjectMarks rs = subjectResult.Where(p => p.ExamID == item.ExamID).FirstOrDefault(); resultCard.SubjectName = rs.SubjectName; PropertyInfo propertyInfo = resultCard.GetType().GetProperty("Exam" + count); if (rs != null) { propertyInfo.SetValue(resultCard, Convert.ChangeType(rs.ObtainedMarks, propertyInfo.PropertyType), null); } else { propertyInfo.SetValue(resultCard, Convert.ChangeType(0, propertyInfo.PropertyType), null); } count++; } ResultCardList = ResultCardList.Add(resultCard); } } }