/// <summary> /// Return which service users are in a rota period /// </summary> /// <param name="date"></param> /// <returns></returns> public IEnumerable <ServiceUser> ServiceUsersInRotaPeriod(DateTime date) { DateTime rotaPeriodStart = DateCalculations.GetStartOfRotaPeriod(date); DateTime rotaPeriodEnd = DateCalculations.GetEndOfRotaPeriod(date); return(ServiceUsers.Where(s => s.ServiceEnds > rotaPeriodStart && s.ServiceBegins < rotaPeriodEnd)); }
/// <summary> /// Refresh the dates in the period selection combo /// </summary> private void RefreshDateWeekCombo() { weekSelectionCombo.Items.Clear(); DateTime currentPeriodStart = DateCalculations.GetStartOfRotaPeriod(DateTime.Now); Color pastCol = ColorTranslator.FromHtml("#FFA8A8"); Color currCol = ColorTranslator.FromHtml("#72FE95"); Color futrCol = ColorTranslator.FromHtml("#75ECFD"); int range = Settings.Instance.rotarange; DateTime dateFrom = currentPeriodStart.AddDays(-(7 * Settings.Instance.rotaweekcount * range)); DateTime dateTo = dateFrom.AddDays((Settings.Instance.rotaweekcount * 7) - 1); for (int i = 0; i < (range * 2) + 1; i++) { Color col = currCol; if (i < range) { col = pastCol; } else if (i > range) { col = futrCol; } weekSelectionCombo.Items.Add(new ComboItem() { obj = new RotaPeriod() { dateFrom = dateFrom, dateTo = dateTo }, color = col }); dateFrom = dateFrom.AddDays(7 * Settings.Instance.rotaweekcount); dateTo = dateTo.AddDays(7 * Settings.Instance.rotaweekcount); } //select the current period as being start one weekSelectionCombo.SelectedIndex = range; //also select current week tab int weeksgone = (int)((DateTime.Now - currentPeriodStart).TotalDays / 7); KRBTabControl.TabPageEx tab = weekctrls[weeksgone].Parent as KRBTabControl.TabPageEx; tabcontrl.SelectedTab = tab; }