public void SetDate(bool showMessage = true) { if (SelectedDate != null && SelectedMeasureWithoutDate != null) { if (SelectedMeasureWithoutDate.SetDateForMeasurement(SelectedDate, showMessage)) { MeasurementsWithDate.Add(SelectedMeasureWithoutDate); MeasurementsWithoutDate.Remove(SelectedMeasureWithoutDate); StayLimits = GetCountStayLimits(); } } else { if (showMessage) { MessageBox.Show("Для установки даты замера нужно выбрать дату и заявку на замер."); } } }
public void FindReadyData() { if (SelectedBeginDate != null && SelectedEndDate != null) { if (CityForFind != null && CityForFind?.Id != AllCity.Id) { var list = Measurement.AllMeasurements .Where(m => m.MeasurementLimit.City.Id == CityForFind.Id && m.MeasurementDate >= SelectedBeginDate && m.MeasurementDate <= SelectedEndDate).ToList(); MeasurementsWithDate.Clear(); foreach (var m in list) { MeasurementsWithDate.Add(m); } } else { var list = Measurement.AllMeasurements .Where(m => m.MeasurementDate >= SelectedBeginDate && m.MeasurementDate <= SelectedEndDate).ToList(); MeasurementsWithDate.Clear(); foreach (var m in list) { MeasurementsWithDate.Add(m); } } SelectedLimit = null; } else { MessageBox.Show("Выберите город, начальную и конечную даты для поиска назначенных замеров."); } }
public void Find() { //если выбран определенный город, то фильтрую лимиты и клиентов if (CityForFind != null && CityForFind?.Id != AllCity.Id) { Clients.Clear(); var listClients = Client.AllClients .Where(c => string.IsNullOrEmpty(LastName) || c.LastName.Contains(LastName, StringComparison.InvariantCultureIgnoreCase)) .Where(c => CityForFind == null || CityForFind.Id == AllCity.Id || c.City.Id == CityForFind.Id).ToList(); foreach (var c in listClients) { Clients.Add(c); } SelectedClient = null; Limits.Clear(); var listLimits = MeasurementLimit.AllMeasurementLimits .Where(m => CityForFind == null || CityForFind.Id == AllCity.Id || m.City.Id == CityForFind.Id).ToList(); foreach (var m in listLimits) { Limits.Add(m); } SelectedLimit = null; MeasurementsWithoutDate.Clear(); MeasurementsWithDate.Clear(); var listMeasure = Measurement.AllMeasurements .Where(m => CityForFind == null || CityForFind.Id == AllCity.Id || m.MeasurementLimit.City.Id == CityForFind.Id).ToList(); foreach (var m in listMeasure) { //формирую списки для показа с назначенными замерами датам и без дат if (m.MeasurementDate == null || DateTime.Equals(m.MeasurementDate, DateTime.MinValue)) { MeasurementsWithoutDate.Add(m); } else { MeasurementsWithDate.Add(m); } } StayLimits = GetCountStayLimits(); } //если не выбран определенный город else { MeasurementsWithoutDate.Clear(); MeasurementsWithDate.Clear(); Clients.Clear(); foreach (var c in Client.AllClients) { Clients.Add(c); } SelectedClient = null; Limits.Clear(); foreach (var m in MeasurementLimit.AllMeasurementLimits) { Limits.Add(m); } SelectedLimit = null; foreach (var m in Measurement.AllMeasurements) { //формирую списки для показа с назначенными замерами датам и без дат if (m.MeasurementDate == null || DateTime.Equals(m.MeasurementDate, DateTime.MinValue)) { MeasurementsWithoutDate.Add(m); } else { MeasurementsWithDate.Add(m); } } StayLimits = null; } }