//It creates the ListView Report for the Week private void createListViewDayReport(DateTime myDate) { //It gets the usernames of the Instructors and creates the columns of the ListView ControlFunctions.createListViewColumns(listViewDay, "Time", instructorsUserNames, "Total", 60, 65, 55); //It gets the times of the day and creates the Items of the ListView timesOfDate = DBData.getTimesOfDay(dateTimePickerWeek.Value); //It adds the total per Instructor timesOfDate.Add("Total"); //It creates the ListView Items ControlFunctions.createListViewItems(listViewDay, timesOfDate); //It creates the array of arrays of hours scheduled per Time and Instructor plus one for the Totals string[][] hoursScheduledMatrix = new string[timesOfDate.Count][]; for (int j = 0; j < timesOfDate.Count; j++) { hoursScheduledMatrix[j] = new string[instructorsUserNames.Count + 1]; } //It initializes the arrays to zeros for (int j = 0; j < instructorsUserNames.Count; j++) { for (int i = 0; i < timesOfDate.Count; i++) { hoursScheduledMatrix[i][j] = "0"; } } //It fills in the arrays for (int j = 0; j < instructorsUserNames.Count; j++) { List <string> timesScheduled = new List <string>(); //It gets the Schedule for each Instructor for the selected Date timesScheduled = DBData.getInstructorScheduleForDate(instructorsUserNames[j], myDate); for (int i = 0; i < timesOfDate.Count; i++) { foreach (string time in timesScheduled) { if (timesOfDate[i] == time) { hoursScheduledMatrix[i][j] = "1"; break; } else { hoursScheduledMatrix[i][j] = "0"; } } } } //It adds the Totals per Time for (int i = 0; i < timesOfDate.Count; i++) { hoursScheduledMatrix[i][instructorsUserNames.Count] = "0"; for (int j = 0; j < instructorsUserNames.Count; j++) { hoursScheduledMatrix[i][instructorsUserNames.Count] = (int.Parse(hoursScheduledMatrix[i][instructorsUserNames.Count]) + int.Parse(hoursScheduledMatrix[i][j])).ToString(); } } //It adds the Totals per Instructor for (int j = 0; j < instructorsUserNames.Count; j++) { hoursScheduledMatrix[timesOfDate.Count - 1][j] = "0"; for (int i = 0; i < timesOfDate.Count - 1; i++) { hoursScheduledMatrix[timesOfDate.Count - 1][j] = (int.Parse(hoursScheduledMatrix[timesOfDate.Count - 1][j]) + int.Parse(hoursScheduledMatrix[i][j])).ToString(); } } //It copies all the data to the listView in the Subitems ControlFunctions.createListViewSubitems(listViewDay, hoursScheduledMatrix); }