예제 #1
0
        public static ArrayList getPdfSharpReportDataTablesList(ArrayList listForPrint, int reportType)
        {
            Cursor.Current = Cursors.WaitCursor;

            ArrayList reportTablesList = new ArrayList();

            ///
            int rowCount = AppForm.CURR_OCTT_DOC.IncludedTerms.Count;

            int columnCount = AppForm.CURR_OCTT_DOC.getNumberOfDays();


            foreach (Object obj in listForPrint)
            {
                Object [] reportGroupAndTable = new object[2];

                DataTable gdt = new DataTable();
                for (int dd = 0; dd < columnCount; dd++)
                {
                    gdt.Columns.Add("Day" + (dd + 1));
                }


                ArrayList [,] mytt = null;
                Teacher teacher = null;
                Room    room    = null;
                string  grName  = null;

                if (obj is EduProgram)
                {
                    EduProgram ep = (EduProgram)obj;
                    mytt   = ep.getTimetable();
                    grName = ep.getReportTitle();
                }
                else if (obj is Teacher)
                {
                    teacher = (Teacher)obj;
                    grName  = teacher.getReportTitle();
                }
                else if (obj is Room)
                {
                    room   = (Room)obj;
                    grName = room.getReportTitle();
                }

                reportGroupAndTable[0] = grName;

                int foundInOneTSForTeacherAndRoom;

                for (int j = 0; j < rowCount; j++)
                {
                    DataRow dr = gdt.NewRow();

                    for (int k = 0; k < columnCount; k++)
                    {
                        string timeSlotText = "";
                        dr["Day" + (k + 1)] = timeSlotText;

                        foundInOneTSForTeacherAndRoom = 1;

                        if (reportType == 1)
                        {
                            ArrayList lessonsInOneTimeSlot = mytt[j, k];
                            if (lessonsInOneTimeSlot != null && lessonsInOneTimeSlot.Count != 0)
                            {
                                int helpCounter = 1;
                                foreach (Object [] courseAndRoomPair in lessonsInOneTimeSlot)
                                {
                                    Room room11 = (Room)courseAndRoomPair[1];

                                    Course  course      = (Course)courseAndRoomPair[0];
                                    Teacher tcr         = course.getTeacher();
                                    string  teacherText = tcr.getName().Substring(0, 1) + ". " + tcr.getLastName();

                                    //string courseName=course.getReportName();

                                    string courseName;
                                    if (Settings.TTREP_COURSE_FORMAT == 1)
                                    {
                                        courseName = course.getFullName();
                                    }
                                    else
                                    {
                                        courseName = course.getReportName();
                                    }

                                    string roomName = room11.getName();

                                    if (helpCounter == 1)
                                    {
                                        timeSlotText += courseName + " @ " + roomName;
                                    }
                                    else
                                    {
                                        timeSlotText += "\n" + courseName + " @ " + roomName;
                                    }

                                    if (Settings.TTREP_PRINT_TEACHER_IN_TS == 1)
                                    {
                                        timeSlotText += " (" + teacherText + ")";
                                    }

                                    helpCounter++;
                                }

                                dr["Day" + (k + 1)] = timeSlotText;
                            }
                        }
                        else if (reportType == 2)
                        {
                            string lastUsedCourseName2 = null;

                            foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
                            {
                                foreach (EduProgram ep in epg.Nodes)
                                {
                                    ArrayList [,] myttT = ep.getTimetable();
                                    ArrayList lessonsInOneTimeSlot = myttT[j, k];
                                    if (lessonsInOneTimeSlot != null && lessonsInOneTimeSlot.Count != 0)
                                    {
                                        foreach (Object [] courseAndRoomPair in lessonsInOneTimeSlot)
                                        {
                                            Course  course           = (Course)courseAndRoomPair[0];
                                            Teacher teacherFromModel = course.getTeacher();
                                            if (teacherFromModel == teacher)
                                            {
                                                Room room2 = (Room)courseAndRoomPair[1];
                                                //string courseName=course.getReportName();
                                                string courseName;
                                                if (Settings.TTREP_COURSE_FORMAT == 1)
                                                {
                                                    courseName = course.getFullName();
                                                }
                                                else
                                                {
                                                    courseName = course.getReportName();
                                                }


                                                string roomName = room2.getName();

                                                if (foundInOneTSForTeacherAndRoom == 1)
                                                {
                                                    timeSlotText += courseName + " @ " + roomName;
                                                }
                                                else
                                                {
                                                    if (courseName != lastUsedCourseName2)
                                                    {
                                                        timeSlotText += "\n" + courseName + " @ " + roomName;
                                                    }
                                                }

                                                lastUsedCourseName2 = courseName;

                                                foundInOneTSForTeacherAndRoom++;
                                            }
                                        }

                                        dr["Day" + (k + 1)] = timeSlotText;
                                    }
                                }
                            }
                        }
                        else if (reportType == 3)
                        {
                            string lastUsedCourseName3 = null;

                            foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
                            {
                                foreach (EduProgram ep in epg.Nodes)
                                {
                                    ArrayList [,] myttR = ep.getTimetable();
                                    ArrayList lessonsInOneTimeSlot = myttR[j, k];
                                    if (lessonsInOneTimeSlot != null && lessonsInOneTimeSlot.Count != 0)
                                    {
                                        foreach (Object [] courseAndRoomPair in lessonsInOneTimeSlot)
                                        {
                                            Room roomFromModel = (Room)courseAndRoomPair[1];

                                            if (roomFromModel == room)
                                            {
                                                Course  course      = (Course)courseAndRoomPair[0];
                                                Teacher tcr         = course.getTeacher();
                                                string  teacherText = tcr.getName().Substring(0, 1) + ". " + tcr.getLastName();

                                                EduProgram ep3        = (EduProgram)course.Parent;
                                                string     codeAndSem = ep3.getCode() + "/" + ep3.getSemester();

                                                //string courseName=course.getReportName();
                                                string courseName;
                                                if (Settings.TTREP_COURSE_FORMAT == 1)
                                                {
                                                    courseName = course.getFullName();
                                                }
                                                else
                                                {
                                                    courseName = course.getReportName();
                                                }

                                                if (foundInOneTSForTeacherAndRoom == 1)
                                                {
                                                    timeSlotText += courseName + " @ " + codeAndSem;
                                                }
                                                else
                                                {
                                                    if (courseName == lastUsedCourseName3)
                                                    {
                                                        timeSlotText += ", " + codeAndSem;
                                                    }
                                                    else
                                                    {
                                                        timeSlotText += "\n" + courseName + " @ " + codeAndSem;
                                                    }
                                                }

                                                if (Settings.TTREP_PRINT_TEACHER_IN_TS == 1)
                                                {
                                                    timeSlotText += " (" + teacherText + ")";
                                                }

                                                lastUsedCourseName3 = courseName;

                                                foundInOneTSForTeacherAndRoom++;
                                            }
                                        }

                                        dr["Day" + (k + 1)] = timeSlotText;
                                    }
                                }
                            }
                        }
                    }

                    gdt.Rows.Add(dr);
                }

                reportGroupAndTable[1] = gdt;

                reportTablesList.Add(reportGroupAndTable);
            }


            return(reportTablesList);
        }