예제 #1
0
        public AttendanceMaster ViewAttendance(int id)
        {
            AttendanceMaster attendanceMaster = new AttendanceMaster();
            string           qry = @"SELECT A.Id 
                                , M.Id as ModuleId, M.Name as ModuleName
                                , T.Id as TimetableId, concat(T.StartTime, ' - ', T.EndTime, ' (', T.Day, ')') as ClassInformation
                                , C.Id as CourseId, C.Name as CourseName
                                , S.Id as SemesterId, S.Name as SemesterName
                            FROM AttendanceMast A
                                INNER JOIN Timetable T on T.Id = A.TimetableId
                                INNER JOIN Module M on M.Id = T.ModuleId
                                INNER JOIN Course C on C.Id = T.CourseId
                                INNER JOIN Semester S on S.Id = T.SemesterId
                            WHERE A.Id = @id
                            
                            SELECT d.id, s.Id as StudentId, s.name as studentName, d.[status], d.remarks
                            FROM AttendanceDetl D
                                INNER JOIN STUDENT S ON d.StudentId = s.Id
                            WHERE D.MastId = @id";

            List <SqlParam> parameters = new List <SqlParam>()
            {
                new SqlParam("@id", SqlDbType.Int, id),
            };

            DataSet ds = _dao.ExecuteDataSet(qry, parameters);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                attendanceMaster         = ds.Tables[0].ToList <AttendanceMaster>().FirstOrDefault();
                attendanceMaster.details = ds.Tables[1].ToList <AttendanceDetail>();
            }

            return(attendanceMaster);
        }