public async Task LoadAsync() { var lookup = await carLookupDataService.GetCarLookupAsync(); Cars.Clear(); foreach (var item in lookup) { Cars.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, this.eventAggregator, nameof(CarDetailViewModel))); } lookup = await rentLookupService.GetRentLookupAsync(); Rents.Clear(); foreach (var item in lookup) { Rents.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, this.eventAggregator, nameof(RentDetailViewModel))); } }
public void FilterCars() { if (string.IsNullOrEmpty(SearchText)) { UpdateCar(); } else { Cars.Clear(); foreach (var item in CarStorage.Instance.Cars) { if (item.CarModel.CarNumber.IndexOf(SearchText) != -1) { Cars.Add(item); } } } }
public static void Stop() { Cars.Clear(); Peoples.Clear(); Deleter.Clear(); MoveTimer.Stop(); PMoveTimer.Stop(); LightsTimer.Stop(); GenCarTimer.Stop(); GenPeopleTimer.Stop(); WorkTimer.Stop(); CarCount.Text = "0"; CurrentlyCarCount.Text = "0"; WorkTime.Text = "0 c"; Cpm.Text = "0"; WorkTm = 0; UserPanel.ResetBackColor(); UserPanel.Invalidate(); }
public List <Car> GetCars(string model, string year, string engine) { string line = string.Empty; Car car = null; Cars.Clear(); using (streamReader = new System.IO.StreamReader(filePath)) while ((line = streamReader.ReadLine()) != null) { if (line.Contains(model) && line.Contains(year) && line.Contains(engine)) { car = ReadFromRow(line); if (car != null) { Cars.Add(car); } } } return(Cars); }
public override void Load() { Cars.Clear(); try { string carsOutput = File.ReadAllText(@"./Cars.xml"); XElement carsXElement = XElement.Parse(carsOutput); foreach (var item in carsXElement.Descendants("car")) { int tempParkingSpot = int.Parse(item.Element("parkingSpot").Value); string tempCarNumber = item.Element("carNumber").Value; string tempDriverName = item.Element("driverName").Value; string tempPhoneNumber = item.Element("phoneNumber").Value; DateTime tempParkingTime = item.Element("parkingTime").Value == "" ? DateTime.Now : DateTime.Parse(item.Element("parkingTime").Value); ParkingCar tempCar = new ParkingCar() { parkingSpot = tempParkingSpot, carNumber = tempCarNumber, driverName = tempDriverName, phoneNumber = tempPhoneNumber, parkingTime = tempParkingTime }; Cars.Add(tempCar); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); dataSource.PrintLog(ex.Message); dataSource.PrintLog(ex.StackTrace); //만약 파일이 없어서 여기로 진입한 경우라면 CreateFile(); //파일을 다시 만들고 Save(null); //그 파일을 저장한 다음 Load(); //다시 불러들여본다. //단, Load 함수 자체가 잘못된거라면 이 코드는 무한루프에 빠진다. } }
public List <Car> GetCars() { Car car = null; Cars.Clear(); using (Stream stream = new System.IO.FileStream(filePath, FileMode.Open)) { using (xmlStreamReader = new XmlStreamReader(stream)) { while (xmlStreamReader.Read()) { car = xmlStreamReader.Deserialize(); if (car != null) { Cars.Add(car); } } } } return(Cars); }
private void OnFindCar() { Cars.Clear(); Cars = new ObservableCollection <CarModel>(baseConverter.GetCars()); var count = Cars.Where(x => x.Name.Contains(_findCarText) || x.BrandCar.Contains(_findCarText) || x.FuelCar.Contains(_findCarText) || x.Capacity.ToString().Contains(_findCarText) || x.DateRelease.ToString().Contains(_findCarText) || x.TypeCar.Contains(_findCarText) || x.Available.Contains(_findCarText)).Count(); if (count != 0) { Cars = new ObservableCollection <CarModel>(Cars.Where(x => x.Name.Contains(_findCarText) || x.BrandCar.Contains(_findCarText) || x.FuelCar.Contains(_findCarText) || x.Capacity.ToString().Contains(_findCarText) || x.DateRelease.ToString().Contains(_findCarText) || x.TypeCar.Contains(_findCarText) || x.Available.Contains(_findCarText))); } else { Cars.Clear(); } OnPropertyChanged(nameof(Cars)); }
protected override void Load() { Reservations.Clear(); Customers.Clear(); Cars.Clear(); foreach (CustomerDto Customer in Service.Customers) { Customers.Add(Customer); } foreach (CarDto Car in Service.Cars) { Cars.Add(Car); } foreach (ReservationDto reservation in Service.Reservations) { Reservations.Add(reservation); } SelectedReservation = Reservations.FirstOrDefault(); }
public void Requery() { try { Cars.Clear(); using var conn = new SQLiteConnection(ConnectionString, true); conn.Open(); using var cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM Cars;"; var reader = cmd.ExecuteReader(); while (reader.Read()) { Cars.Add(new Car(reader)); } } catch (Exception e) { MessageBox.Show(e.Message, "Error"); } }
private async void ExecuteLoadCarsCommand(object obj) { IsBusy = true; try { Cars.Clear(); var task1 = CarsService.GetCarsAsync(); foreach (var car in await task1) { Cars.Add(car); } } catch (Exception ex) { Debug.WriteLine(ex); await Application.Current.MainPage.DisplayAlert("BŁĄD", "Nie udało się wczytać samochodów", "ANULUJ"); } finally { IsBusy = false; } }
public override void Load() { try { //select 문으로 해당 테이블의 전체 데이터들을 가져옴 ds = dbh.selectQuery(); Cars.Clear(); //새로 조회할 때마다 Clear 해줘야 함 foreach (DataRow item in ds.Tables[0].Rows) { ParkingCar car = new ParkingCar(); car.parkingSpot = int.Parse(item["ParkingSpot"].ToString()); car.carNumber = item["CarNumber"].ToString(); car.driverName = item["DriverName"].ToString(); car.phoneNumber = item["PhoneNumber"].ToString(); car.parkingTime = item["ParkingTime"].ToString() == "" ? new DateTime() : DateTime.Parse(item["ParkingTime"].ToString()); Cars.Add(car); //그 데이터들을 Cars에 넣음 } } catch (Exception exception) { dataSource.PrintLog(exception.Message); dataSource.PrintLog(exception.StackTrace); } }
private async Task UpdateAsync() { var res = await TcpConnection.Send("BA"); if (res.Px != 'B' || res.Fx != 'A') { return; } Cars.Clear(); try { foreach (var el in JsonConvert.DeserializeObject <List <CarListBaseDataModel> >(res.Msg)) { Cars.Add(el); } if (SelectedCar == null) { SelectedCar = Cars.FirstOrDefault(); } } catch (Exception e) { } }
public Task DeleteDatabaseIfExists() { Cameras.Clear(); Cars.Clear(); return(EmptyTask); }
public void FillTestData(int n) { //Admins for (int i = 1; i <= n; i++) { Admin newA = new Admin() { Name = $"Admin_{i}", Password = "******", }; Admins.Add(newA); } // Cars Cars.Clear(); for (int i = 0; i < n; i++) { Cars.Add(new Car() { Features = "nope", ID = i + 1, MaksSpeed = (i * 10) % 180 + 100 + 5 * (i % 2), Price = (i * 1000) % 20000 + 6000, ProdCountry = coun[i % coun.Length], Model = mar[i % mar.Length], TechState = (3 * i + 20) % 100 + 1, YearOfIssue = 2000 + i % 20 }); } // Buyers for (int i = 1; i <= n; i++) { int numb = 80042900 + i % 100000; Buyer newB = new Buyer() { Contacts = $"+{numb}", FinancialOpp = ((i * i + 1) * 1000) % 50000 + 7000, MaksSpeedRequired = (i * 10) % 140 + 60, ModelRequired = mar[(i + 3) % mar.Length], Name = $"Buyer_{i}", Password = "******", PerfomanceRequired = i % 100 + 1 }; if (i % 5 == 0) { newB.ModelRequired = "nope"; } Buyers.Add(newB); } // Reports int div = 2;//сколько в каждом отчете машин for (int t = 0; t < n / div; t++) { var ps = new List <Car>(); for (int j = 0; j < div; j++) { ps.Add(new Car { Features = Cars[t * div + j].Features, ID = Cars[t * div + j].ID, MaksSpeed = Cars[t * div + j].MaksSpeed, Model = Cars[t * div + j].Model, Price = Cars[t * div + j].Price, ProdCountry = Cars[t * div + j].ProdCountry, TechState = Cars[t * div + j].TechState, YearOfIssue = Cars[t * div + j].YearOfIssue }); } Reports.Add(new Report(ps, Buyers[t].Name, DateTime.Now + TimeSpan.FromDays(t))); } }
public void Clear() { Drivers.Clear(); Cars.Clear(); Addresses.Clear(); }