Пример #1
0
        //It creates the ListView Report for the Week
        private void createListViewWeekReport()
        {
            //It creates the columns of the ListView
            ControlFunctions.createListViewColumns(listViewWeek, "Date", instructorsUserNames, "", 80, 68, 0);
            //It calculates the first and last date of the week
            int dayOfWeekSelected = (int)dateTimePickerWeek.Value.DayOfWeek;

            firstDayOfWeek = dateTimePickerWeek.Value.Date.AddDays(-dayOfWeekSelected + 1);
            lastDayOfWeek  = firstDayOfWeek.Date.AddDays(daysOfWeek - 1);

            //It creates a list of the dates of the week
            List <String> datesList = new List <string>();

            for (int j = 0; j < daysOfWeek; j++)
            {
                datesList.Add(firstDayOfWeek.AddDays(j).ToString("d"));
            }
            //It adds the total per Instructor
            datesList.Add("Total");
            //It creates the items of the ListView
            ControlFunctions.createListViewItems(listViewWeek, datesList);

            //It creates the array of arrays of hours scheduled per day and instructor and one more for the totals
            string[][] hoursScheduledMatrix = new string[daysOfWeek + 1][];
            for (int j = 0; j < daysOfWeek + 1; j++)
            {
                hoursScheduledMatrix[j] = new string[instructorsUserNames.Count];
            }
            //It fills in the arrays
            for (int i = 0; i < daysOfWeek; i++)
            {
                for (int j = 0; j < instructorsUserNames.Count; j++)
                {
                    //It obtains the list of hours scheduled for the Instructors and Dates
                    hoursScheduledMatrix[i][j] = DBData.getInstructorHoursScheduledForDate(instructorsUserNames[j], firstDayOfWeek.AddDays(i));
                }
            }
            //It adds the total per Instructor and week summing all the days
            for (int j = 0; j < instructorsUserNames.Count; j++)
            {
                hoursScheduledMatrix[daysOfWeek][j] = "0";
                for (int i = 0; i < daysOfWeek; i++)
                {
                    hoursScheduledMatrix[daysOfWeek][j] = (int.Parse(hoursScheduledMatrix[daysOfWeek][j]) + int.Parse(hoursScheduledMatrix[i][j])).ToString();
                }
            }
            //It copies all the data to the listView creating the Subitems
            ControlFunctions.createListViewSubitems(listViewWeek, hoursScheduledMatrix);
        }
Пример #2
0
        //It creates the ListView Report for the Week
        private void createListViewAppointmentSelectionReport()
        {
            //It gets the usernames of the Instructors and creates the columns of the ListView
            ControlFunctions.createListViewColumns(listViewAppointmentSelection, "Time", instructorsUserNames, "", 60, 65, 0);
            //It creates the ListView Items
            ControlFunctions.createListViewItems(listViewAppointmentSelection, timesOfDate);

            //It creates the array of arrays of hours scheduled per Time and Instructor
            string[][] hoursScheduledMatrix = new string[timesOfDate.Count][];
            for (int j = 0; j < timesOfDate.Count; j++)
            {
                hoursScheduledMatrix[j] = new string[instructorsUserNames.Count];
            }
            //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] = "";
                }
            }
            //It fills in the arrays
            for (int j = 0; j < instructorsUserNames.Count; j++)
            {
                List <string> timeScheduled = new List <string>();
                //It gets the Schedule for each Instructor for the selected Date excluding already existing Appointments
                timeScheduled = DBData.getInstructorFreeScheduleForDate(instructorsUserNames[j], selectedDate);
                for (int i = 0; i < timesOfDate.Count; i++)
                {
                    foreach (string time in timeScheduled)
                    {
                        if (timesOfDate[i] == time)
                        {
                            hoursScheduledMatrix[i][j] = "available";
                            break;
                        }
                        else
                        {
                            hoursScheduledMatrix[i][j] = "";
                        }
                    }
                }
            }
            //It copies all the data to the listView in the Subitems
            ControlFunctions.createListViewSubitems(listViewAppointmentSelection, hoursScheduledMatrix);
        }
Пример #3
0
        private void createListViewAssignedCarsReport()
        {
            //It creates the columns of the ListView
            ControlFunctions.createListViewColumns(listViewCarsAssigned, "Instructor", instructorsUserNames, "", 80, 68, 0);
            //It creates the items of the ListView
            List <string> carsTitle = new List <string>();

            carsTitle.Add("Assigned");
            ControlFunctions.createListViewItems(listViewCarsAssigned, carsTitle);
            //It creates the Subitems of the ListView
            //It creates the array of arrays of hours scheduled per day and instructor and one more for the totals
            string[][] carsAssigned = new string[1][];
            carsAssigned[0] = new string[instructorsUserNames.Count];

            //List<string> carsAssigned = new List<string>();
            for (int i = 0; i < instructorsUserNames.Count; i++)
            {
                carsAssigned[0][i] = getCarsAssignedToInstructor(instructorsUserNames[i], firstDayOfWeek, lastDayOfWeek);
            }
            //It copies all the data to the listView creating the Subitems
            ControlFunctions.createListViewSubitems(listViewCarsAssigned, carsAssigned);
        }
Пример #4
0
        //It creates the ListView Report for the Week
        private void createlistViewWeekReport(DateTime myDate)
        {
            //It creates a list of the dates of the week
            List <String> weekDatesList = new List <string>(createDaysOfWeekList());

            //It gets the usernames of the Instructors and creates the columns of the ListView
            ControlFunctions.createListViewColumns(listViewWeek, "Time", weekDatesList, "Total", 60, 75, 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(listViewWeek, 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[weekDatesList.Count + 1];
            }
            //It initializes the arrays to zeros
            for (int j = 0; j < weekDatesList.Count; j++)
            {
                for (int i = 0; i < timesOfDate.Count; i++)
                {
                    hoursScheduledMatrix[i][j] = "0";
                }
            }
            //It fills in the arrays
            for (int j = 0; j < weekDatesList.Count - 1; j++)
            {
                List <string> timesScheduled = new List <string>();
                //It gets the Schedule for each Instructor for the selected Date
                timesScheduled = DBData.getInstructorScheduleForDate(instructorUserName, DateTime.Parse(weekDatesList[j]));
                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][weekDatesList.Count] = "0";
                for (int j = 0; j < weekDatesList.Count; j++)
                {
                    hoursScheduledMatrix[i][weekDatesList.Count] = (int.Parse(hoursScheduledMatrix[i][weekDatesList.Count]) + int.Parse(hoursScheduledMatrix[i][j])).ToString();
                }
            }
            //It adds the Totals per Day
            for (int j = 0; j < weekDatesList.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 adds the Total per Week
            hoursScheduledMatrix[timesOfDate.Count - 1][weekDatesList.Count] = "0";
            for (int i = 0; i < timesOfDate.Count - 1; i++)
            {
                hoursScheduledMatrix[timesOfDate.Count - 1][weekDatesList.Count] = (int.Parse(hoursScheduledMatrix[timesOfDate.Count - 1][weekDatesList.Count]) + int.Parse(hoursScheduledMatrix[i][weekDatesList.Count])).ToString();
            }

            //It copies all the data to the listView in the Subitems
            ControlFunctions.createListViewSubitems(listViewWeek, hoursScheduledMatrix);
        }