public static List <StudentDTO> GetStudentsByCouId(int CouId) { List <StudentDTO> stuList = new List <StudentDTO>(); List <AttendanceDTO> attList = AttendanceDAO.GetAttendancesByCouId(CouId); foreach (AttendanceDTO item in attList) { String sqlQuery = String.Format("Select * from Student where StuId={0}", item.StuId); using (DBHelper helper = new DBHelper()) { var reader = helper.ExecuteReader(sqlQuery); StudentDTO dto = null; if (reader.Read()) { dto = FillStudentDTO(reader); //AttendanceDTO attendance = AttendanceDAO.GetAttendanceByStuIdAndCouId(Id, CouId); dto.StuAttendance = item; stuList.Add(dto); } } } return(stuList); }
public static StudentDTO GetStudentByStuAndCouId(int Id, int CouId) { String sqlQuery = String.Format("Select * from Student where StuId={0}", Id); using (DBHelper helper = new DBHelper()) { var reader = helper.ExecuteReader(sqlQuery); StudentDTO dto = null; if (reader.Read()) { dto = FillStudentDTO(reader); AttendanceDTO attendance = AttendanceDAO.GetAttendanceByStuIdAndCouId(Id, CouId); dto.StuAttendance = attendance; } return(dto); } }