public void Add() { if (SelectedClient != null && SelectedLimit != null) { Measurement mes = new Measurement(SelectedLimit, SelectedClient); MeasurementsWithoutDate.Add(mes); Measurement.AllMeasurements.Add(mes); SelectedLimit = null; SelectedClient = null; } }
public void RemoveWithDate(object obj) { if (SelectedMeasureWithDate != null) { if (SelectedMeasureWithDate.SetDateForMeasurement(null)) { MeasurementsWithoutDate.Add(SelectedMeasureWithDate); MeasurementsWithDate.Remove(SelectedMeasureWithDate); StayLimits = GetCountStayLimits(); } } 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; } }