private void UpdateWorkPeriods() { if (SelectedEmployee == null || DateTimeEditStart == null || DateTimeEditFinish == null) { return; } List <ItemWorkPeriod> workPeriods = mySqlClient.GetWorkPeriods( SelectedEmployee.ID, DateTimeEditStart, DateTimeEditFinish); WorkPeriods.Clear(); if (workPeriods.Count == 0) { WorkPeriods.Add(new ItemWorkPeriod(new DateTime())); ButtonAdd.IsEnabled = true; return; } workPeriods.Sort((x, y) => DateTime.Compare(x.Date, y.Date)); foreach (ItemWorkPeriod item in workPeriods) { WorkPeriods.Add(item); } ListViewWorkTimes.SelectedItem = ListViewWorkTimes.Items[0]; }
public static IEnumerable <WorkPeriod> GetWorkPeriods(DateTime startDate, DateTime endDate) { var wp = WorkPeriods.Where(x => x.EndDate >= endDate && x.StartDate < startDate); if (!wp.Any()) { wp = WorkPeriods.Where(x => x.StartDate >= startDate && x.StartDate < endDate); } if (!wp.Any()) { wp = WorkPeriods.Where(x => x.EndDate >= startDate && x.EndDate < endDate); } if (!wp.Any() && ApplicationState.CurrentWorkPeriod.StartDate < startDate) { wp = new List <WorkPeriod> { ApplicationState.CurrentWorkPeriod } } ; return(wp.OrderBy(x => x.StartDate)); }
public static IEnumerable <WorkPeriod> GetWorkPeriods(DateTime startDate, DateTime endDate) { var wp = WorkPeriods.Where(x => x.EndDate >= endDate && x.StartDate < startDate); if (wp.Count() == 0) { wp = WorkPeriods.Where(x => x.StartDate >= startDate && x.StartDate < endDate); } if (wp.Count() == 0) { wp = WorkPeriods.Where(x => x.EndDate >= startDate && x.EndDate < endDate); } if (wp.Count() == 0 && AppServices.MainDataContext.CurrentWorkPeriod.StartDate < startDate) { wp = new List <WorkPeriod> { AppServices.MainDataContext.CurrentWorkPeriod } } ; return(wp.OrderBy(x => x.StartDate)); }