/// <summary> /// Loads all of the capacities per department from the database. /// </summary> /// <param name="weekShifts">A list of all of the shifts in this week</param> private void LoadAllCapacities(List <Shift> weekShifts) { shiftStorage = new ShiftMySQL(); Dictionary <int, Dictionary <int, int> > weekDepartments = new Dictionary <int, Dictionary <int, int> >(); foreach (Shift s in weekShifts) { Dictionary <int, int> temp = shiftStorage.GetCapacityPerDepartment(s.Id); if (temp.Count() > 0) { weekDepartments.Add(s.Id, temp); this.initialShiftIds.Add(s.Id); } } this.allDepartmentCapacityInWeek = weekDepartments; }
// Loads all of the department from the departmentStorage and sets them into the combobox private void LoadDepartments() { departmentStorage = new DepartmentMySQL(); shiftStorage = new ShiftMySQL(); allDepartments = departmentStorage.GetAll(); if (isEditing) { this.departmentCapacity = shiftStorage.GetCapacityPerDepartment(oldId); } foreach (Department d in allDepartments) { if (isEditing) { d.Employees = shiftStorage.GetDepartmentEmployees(oldId, d.Id); if (departmentCapacity.ContainsKey(d.Id)) { d.Capacity = departmentCapacity[d.Id]; } else { d.Capacity = 0; } } comboBoxSelectDepartments.DisplayMember = "Text"; comboBoxSelectDepartments.ValueMember = "Department"; comboBoxSelectDepartments.Items.Add(new { Text = d.Name, Department = d }); } if (previousSelectedDepartment != null) { foreach (dynamic depDynamic in comboBoxSelectDepartments.Items) { Department d = (depDynamic).Department; if (d.Name == previousSelectedDepartment.Name) { comboBoxSelectDepartments.SelectedItem = depDynamic; numericUpDownCapacity.Value = d.Capacity; break; } } } }