//********************************************* Event Methods ***************************************************************** //It creates the ListView for the instructor to create his Schedule private void dateTimePickerWeek_ValueChanged(object sender, EventArgs e) { listViewWeek.Visible = true; //clearVariables(); //It loads the Times of the selected Date timesOfDate = DBData.getTimesOfDay(dateTimePickerWeek.Value); //It creates the Day ListView ControlFunctions.clearListViewReport(listViewWeek); createlistViewWeekReport(dateTimePickerWeek.Value); }
//********************************************* Event Methods ***************************************************************** private void dateTimePickerDate_ValueChanged(object sender, EventArgs e) { //It loads the Times of the selected Date selectedDate = dateTimePickerDate.Value; timesOfDate = DBData.getTimesOfDay(selectedDate); //It makes the ListViews visibles listViewAppointmentSelection.Visible = true; listViewAppointments.Visible = true; //It creates the Appointment Selection ListView ControlFunctions.clearListViewReport(listViewAppointmentSelection); createListViewAppointmentSelectionReport(); //It loads the Appointments for the Client clientAppointments = getClientAppointments(userName, DateTime.Today); }
private void dateTimePickerWeek_ValueChanged(object sender, EventArgs e) { listViewDay.Visible = true; listViewWeek.Visible = true; listViewCarsAssigned.Visible = true; comboBoxInstructor.SelectedItem = -1; comboBoxInstructor.Text = ""; comboBoxCar.SelectedItem = -1; comboBoxCar.Text = ""; populateCarCombo(); timesOfDate = DBData.getTimesOfDay(dateTimePickerWeek.Value); ControlFunctions.clearListViewReport(listViewWeek); createListViewWeekReport(); ControlFunctions.clearListViewReport(listViewCarsAssigned); createListViewAssignedCarsReport(); labelDate.Text = dateTimePickerWeek.Value.ToString("d"); ControlFunctions.clearListViewReport(listViewDay); createListViewDayReport(dateTimePickerWeek.Value); }
//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); }