public static List<Car> HaeAutot() { CarList autot = new CarList(); List<Car> autoLista = new List<Car>(); Serialisointi.DeSerialisoiXml(HttpContext.Current.Server.MapPath("~/App_Data/WanhatAutot.xml"), ref autot); for (int i = 0; i < autot.Cars.Count; i++) { autoLista.Add(autot.Cars[i]); } return autoLista; }
public static void SerialisoiXml(string tiedosto, CarList autot) { XmlSerializer xs = new XmlSerializer(autot.GetType()); TextWriter tw = new StreamWriter(tiedosto); try { xs.Serialize(tw, autot); } catch (Exception e) { throw e; } finally { tw.Close(); } }
public static void DeSerialisoiXml(string filePath, ref CarList autot) { XmlSerializer deserializer = new XmlSerializer(typeof(CarList)); try { FileStream xmlFile = new FileStream(filePath, FileMode.Open); autot = (CarList)deserializer.Deserialize(xmlFile); xmlFile.Close(); } catch (Exception ex) { throw ex; } finally { } }
private void fillFields(DataRow row) { int id; int.TryParse(row.ItemArray[0].ToString(), out id); ID = id; int idCar; int.TryParse(row.ItemArray[1].ToString(), out idCar); Car = CarList.getInstance().getItem(idCar); int.TryParse(row.ItemArray[2].ToString(), out _idPolicyType); IdOwner = row.ItemArray[3].ToString(); IdComp = row.ItemArray[4].ToString(); _number = row.ItemArray[5].ToString(); DateTime.TryParse(row.ItemArray[6].ToString(), out _dateBegin); DateTime.TryParse(row.ItemArray[7].ToString(), out _dateEnd); Pay = row.ItemArray[8].ToString(); File = row.ItemArray[9].ToString(); _fileBegin = File; LimitCost = row.ItemArray[10].ToString(); Pay2 = row.ItemArray[11].ToString(); DateTime datePay2; DateTime.TryParse(row.ItemArray[12].ToString(), out datePay2); DatePay2 = datePay2; int.TryParse(row.ItemArray[13].ToString(), out _idAccount); int.TryParse(row.ItemArray[14].ToString(), out _idAccount2); int.TryParse(row.ItemArray[15].ToString(), out _notifacationSent); Comment = row.ItemArray[16].ToString(); DateTime dateCreate; DateTime.TryParse(row.ItemArray[17].ToString(), out dateCreate); DateCreate = new DateTime(dateCreate.Year, dateCreate.Month, dateCreate.Day); }
public WayBillDay(DataRow row) { ID = Convert.ToInt32(row[0]); int idCar; int.TryParse(row[1].ToString(), out idCar); CarList carList = CarList.getInstance(); _car = carList.getItem(idCar); int idDriver; int.TryParse(row[2].ToString(), out idDriver); DriverList driverList = DriverList.getInstance(); _driver = driverList.getItem(idDriver); DateTime.TryParse(row[3].ToString(), out _date); }
private void btnSave_Click(object sender, EventArgs e) { if (_workWithForm.IsEditMode()) { _shipPart.Car = CarList.getInstance().getItem(Convert.ToInt32(cbCar.SelectedValue)); _shipPart.Driver = DriverList.getInstance().getItem(Convert.ToInt32(cbDriver.SelectedValue)); _shipPart.Number = tbNumber.Text; _shipPart.DateRequest = mtbDateRequest.Text; _shipPart.DateSent = mtbDateSent.Text; TextBox tbFile = ucFile.Controls["tbFile"] as TextBox; _shipPart.File = tbFile.Text; _shipPart.Save(); } else { _workWithForm.SetEditMode(true); } }
static void Load() { CarList list = new CarList { Cars = new List <Car>() }; ReadCars(list, "Cars.csv"); foreach (string csvPath in Directory.EnumerateFiles(".\\", "Cars_*.csv")) { ReadCars(list, csvPath); } ReadColours(list, "Colours.csv"); foreach (string csvPath in Directory.EnumerateFiles(".\\", "Colours_*.csv")) { ReadColours(list, csvPath); } list.SaveToFiles(); }
private void loadDictionary() { CarList carList = CarList.getInstance(); cbCar.DataSource = carList.ToDataTable(Status.Actual); cbCar.ValueMember = "id"; cbCar.DisplayMember = "Бортовой номер"; RepairTypes repairTypes = RepairTypes.getInstance(); cbRepairType.DataSource = repairTypes.ToDataTable(); cbRepairType.ValueMember = "id"; cbRepairType.DisplayMember = "Название"; ServiceStantions serviceStantions = ServiceStantions.getInstance(); cbServiceStantion.DataSource = serviceStantions.ToDataTable(); cbServiceStantion.ValueMember = "id"; cbServiceStantion.DisplayMember = "Название"; }
public void deleteVehicleTest() { CarList carList = new CarList(); Vehicle vehicle = new Vehicle(); Guid id = new Guid(); // this is just a sample data vehicle.Id = id; vehicle.RegistrationID = "21HSK1"; vehicle.CarManufacture = "Ford"; vehicle.CarModel = "LOL"; vehicle.CarYear = 2019; vehicle.FuelType = "Petrol"; vehicle.TankCapacity = 20; vehicle.VehicleOdometer = 1000; CarList.vehicles.Add(vehicle); // check if its deleted or not Assert.IsTrue(CarList.deleteVehicle(vehicle)); }
public void deleteJourneyTest() { CarList car = new CarList(); Journey journey = new Journey(); // this is just a sample data journey.id = Guid.NewGuid(); journey.BookingID = Guid.NewGuid(); journey.vehicleID = Guid.NewGuid(); journey.JourneyStartAt = DateTime.Parse("2019-11-27"); journey.JourneyEndedAt = DateTime.Parse("2019-11-28"); journey.StartOdometer = 100; journey.EndOdometer = 126; journey.JourneyFrom = "Perth"; journey.JourneyTo = "Midlands"; CarList.journeys.Add(journey); // check if its deleted or not Assert.IsTrue(ViewJourneys.deleteJourney(journey)); }
/// <summary> /// Displays program's execution results on the webpage /// </summary> /// <param name="cars">new list of cars (sorted, correct age cars)</param> /// <param name="minAge">minimum age of the car</param> /// <param name="maxAge">maximum age of the car</param> /// <param name="mostDrivenModel">most driven model(-s)</param> private void DisplayResults(CarList cars, int minAge, int maxAge, string mostDrivenModel) { if (mostDrivenModel != null) { MostDrivenCar.Text = "Labiausiai eksploatuojamo(-ų) automobilio(-ių) markė(-ės): " + mostDrivenModel; } if (cars.Count == 0) { ResultsLabel.Text = string.Format("Nėra mašinų, kurių amžius yra tarp {0} ir {1} metų", minAge, maxAge); ResultsTable.Visible = false; } else { ResultsLabel.Text = string.Format("Mašinos, kurių amžius yra tarp {0} ir {1} metų:", minAge, maxAge);; ResultsTable.Visible = true; AddCarsToTable(ResultsTable, cars); } }
public void deleteBookingTest() { CarList carList = new CarList(); Booking booking = new Booking(); Guid id = new Guid(); Guid vehicleId = new Guid(); // this is just a sample data booking.id = id; booking.Vehicleid = vehicleId; booking.CustomerName = "Kopal"; booking.StartOdometer = 100; booking.SelectedVehicle = "BMW Z4"; booking.StartRentDate = DateTime.Now; booking.EndRentDate = DateTime.Now; booking.RentalType = (BookingType)Enum.Parse(typeof(BookingType), "Day"); CarList.bookings.Add(booking); // check if its deleted or not by this method Assert.IsTrue(BookingList.deleteBooking(booking)); }
public static void SpawnPlayer(CarList carList, int carNum, CarType carType, Transform SpawnPoint, VehicleFollow cam) { cam_ = cam; GameObject newCar = (GameObject)Network.Instantiate(carList.cars [carNum].gameObject, SpawnPoint.position, SpawnPoint.rotation, 0); playerList_.Add(newCar.GetComponent <CarInfo> ()); if (carType == CarType.self) { currentCar = newCar.GetComponent <CarInfo> (); cam.target = currentCar.follow; newCar.gameObject.AddComponent <CarPlayer> (); } else if (carType == CarType.other) { //newCar.gameObject.AddComponent<CarPlayer>(); } else if (carType == CarType.aI) { newCar.gameObject.AddComponent <CarAI> (); } }
public MainForm(ICarForm carForm) { _carForm = carForm; InitializeComponent(); _carList = CarList.getInstance(); _mainStatus = MainStatus.getInstance(); _mainStatus.StatusChanged += statusChanged; _mainStatus.StatusChanged += SetWindowHeaderText; _mainStatus.StatusChanged += ConfigContextMenu; _dgvMain = new MainDGV(_dgvCar); _seacher = new SearchInDgv(_dgvCar); _myStatusStrip = new MyStatusStrip(_dgvCar, statusStrip1); _myFilter = MyFilter.GetInstanceCars(); _myFilter.Fill(_dgvCar, _myStatusStrip, this); }
public void UpdateCarList() { CarList.Clear(); var results = _gameDB.ExecuteQuery( "SELECT " + "V.VehicleName " + "FROM Vehicles V " + "INNER JOIN Manufacturers M " + "ON M.ManufacturerID = V.VehicleManufacturerID " + "WHERE " + $"M.ManufacturerName = '{cb_Manufacturers.SelectedItem.ToString()}' " + "ORDER BY VehicleName "); while (results.Read()) { CarList.Add(results.GetString(0)); } lv_CarList.ItemsSource = null; lv_CarList.ItemsSource = CarList; }
private void fillFields(DataRow row) { int id; int.TryParse(row.ItemArray[0].ToString(), out id); Id = id; int idCar; int.TryParse(row.ItemArray[1].ToString(), out idCar); Car = CarList.getInstance().getItem(idCar); int idDriver; int.TryParse(row.ItemArray[2].ToString(), out idDriver); Driver = DriverList.getInstance().getItem(idDriver); Number = row.ItemArray[3].ToString(); DateRequest = row.ItemArray[4].ToString(); DateSent = row.ItemArray[5].ToString(); File = row.ItemArray[6].ToString(); FileBegin = File; }
// Listener for car item purchase. public void OnCarStoreItemClicked(int carIndex) { _carToPurchaseObj = CarList.GetCarByCarIndex(carIndex); if (_carToPurchaseObj.IsRealMoneyPurchase) { BuyCar(); } else // if the item sells in coins. { var gameData = GameDataController.GetGameData(); // Players can purchase the coin item only it they have enough coin. if (gameData.coinsOwned >= _carToPurchaseObj.Price * gameData.Discount) { BuyCar(); } else { coinsNotEnoughReminder.SetActive(true); Invoke(nameof(HideCoinsNotEnoughReminder), HideCoinsNotEnoughReminderTimeOutSec); } } }
/// <summary> /// Finds the most driven car model (all models if there are more which are equaly driven) /// </summary> /// <param name="cars">list containing cars which will be searched</param> /// <returns>string containing the most driven model (or models)</returns> private string GetMostDrivenCarModel(CarList cars) { string model = null; int mostKmDriven = 0; while (cars.MoveToNextElement()) { CarData currentCar = cars.GetCurrentElement(); if (currentCar.KmPerYear > mostKmDriven) { mostKmDriven = currentCar.KmPerYear; model = currentCar.Model; } else if (currentCar.KmPerYear == mostKmDriven) { mostKmDriven = currentCar.KmPerYear; model += ", " + currentCar.Model; } } return(model); }
private List <Driver> GetDrivers() { List <Driver> drivers = new List <Driver>(); DriverCarList driverCarList = DriverCarList.getInstance(); CarList carList = CarList.getInstance(); foreach (DataGridViewCell cell in _dgvMain.SelectedCells) { if (cell.Visible) { Car car = carList.getItem(_dgvMain.GetCarID(cell.RowIndex)); Driver driver = driverCarList.GetDriver(car); if (CanAddToList(drivers, driver.email)) { drivers.Add(driver); } } } return(drivers); }
private void fillFields(DataRow row) { int id; int.TryParse(row.ItemArray[0].ToString(), out id); ID = id; int idCar; int.TryParse(row.ItemArray[1].ToString(), out idCar); Car = CarList.getInstance().getItem(idCar); Number = row.ItemArray[2].ToString(); DateTime date; DateTime.TryParse(row.ItemArray[3].ToString(), out date); Date = date; File = row.ItemArray[4].ToString(); _fileBegin = File; int.TryParse(row.ItemArray[5].ToString(), out _notifacationSent); }
private void fillFields(DataRow row) { int id; int.TryParse(row.ItemArray[0].ToString(), out id); ID = id; int idCar; int.TryParse(row.ItemArray[1].ToString(), out idCar); Car = CarList.getInstance().getItem(idCar); int.TryParse(row.ItemArray[2].ToString(), out _idRepairType); int.TryParse(row.ItemArray[3].ToString(), out _idServiceStantion); DateTime date; DateTime.TryParse(row.ItemArray[4].ToString(), out date); Date = date; Cost = row.ItemArray[5].ToString(); File = row.ItemArray[6].ToString(); _fileBegin = File; }
private void fillFields(DataRow row) { Id = Convert.ToInt32(row.ItemArray[0]); int idCar; int.TryParse(row.ItemArray[1].ToString(), out idCar); Car = CarList.getInstance().getItem(idCar); Number = row.ItemArray[2].ToString(); int.TryParse(row.ItemArray[3].ToString(), out _idDriverFrom); int.TryParse(row.ItemArray[4].ToString(), out _idDriverTo); DateTime date; DateTime.TryParse(row.ItemArray[5].ToString(), out date); Date = date; DateMove = row.ItemArray[6].ToString(); int.TryParse(row.ItemArray[7].ToString(), out _idRegionFrom); int.TryParse(row.ItemArray[8].ToString(), out _idRegionTo); File = row.ItemArray[9].ToString(); FileBegin = File; }
private CreateDocument createDocument(DataGridViewCell cell) { int carID = _dgvMain.GetCarID(cell.RowIndex); if (carID == 0) { return(null); } CarList carList = CarList.getInstance(); Car car = carList.getItem(carID); Invoice invoice = null; if (_mainStatus.Get() == Status.Invoice) { int invoiceID = _dgvMain.GetID(cell.RowIndex); InvoiceList invoiceList = InvoiceList.getInstance(); invoice = invoiceList.getItem(invoiceID); } return(new CreateDocument(car, invoice)); }
internal static string CheckLongOfInsertedData(CarList carToValidate) { string message = ""; bool IsVinValid = LenghtOfData(carToValidate.Vin, 17); bool IsRegisterNumberValid = LenghtOfData(carToValidate.RegistrationNumber, 7); if (!IsVinValid && !IsRegisterNumberValid) { carToValidate.RegistrationNumber = ""; carToValidate.Vin = ""; return("Vin number requires 17 characters and Registration number requires 7 characters!"); } if (!IsVinValid) { carToValidate.RegistrationNumber = ""; return("Vin number requires 17 characters!"); } if (!IsRegisterNumberValid) { carToValidate.Vin = ""; return("Registration number requires 7 characters!"); } return(message); }
static private int LoadFromAFile(string filename, CarList carList) { if (File.Exists(filename)) { string json = File.ReadAllText(filename); carList.Clear(); int maxId = 0; CarList loadedList = JsonConvert.DeserializeObject <CarList>(json); foreach (var car in loadedList) { if (car.Id > maxId) { maxId = car.Id; } carList.Add(car); } return(maxId + 1); } else { return(0); } }
public Car GetCar() { return((_dgv.CurrentCell == null) ? null : CarList.getInstance().getItem(GetID(1, _dgv.CurrentCell.RowIndex))); }
static private void SaveToAFile(string filename, CarList carList) { string json = JsonConvert.SerializeObject(carList); File.WriteAllText(filename, json); }
public BuscarVehiculoViewModel() { restService = new RestService(); cars = new CarList(); this.fetchCars(); }
private void autoButton_Click(object sender, EventArgs e) { CarList form = new CarList(); form.Show(); }
public static void VieAutot(List<Car> autoLista) { CarList autot = new CarList(); foreach (Car item in autoLista) { autot.Cars.Add(item); } Serialisointi.SerialisoiXml(HttpContext.Current.Server.MapPath("~/App_Data/WanhatAutot.xml"), autot); }
static void Dump() { CarList list = new CarList(); list.ReadFromFiles(); using (TextWriter output = new StreamWriter(File.Create("CarColours.txt"), Encoding.UTF8)) { foreach (Car car in list.Cars) { output.WriteLine($"{car.CarName} ({car.JPName} / {car.USName} / {car.EUName})"); output.WriteLine(); output.WriteLine("==Colors=="); if (car.Colours.Count > 1) { output.Write($"There are {GetNumber(car.Colours.Count)} colors"); } else { output.Write($"There is only one color"); } output.Write(" available for this vehicle"); bool hasColourNames = false; foreach (CarColour colour in car.Colours) { if (!string.IsNullOrWhiteSpace(colour.LatinName)) { hasColourNames = true; break; } } if (!hasColourNames) { if (car.Colours.Count > 1) { output.Write($", they are"); } else { output.Write($", it is"); } output.Write($" unnamed in-game"); } output.WriteLine($":"); foreach (CarColour colour in car.Colours) { CarColourWithName colourWithName = new CarColourWithName { CarName = car.CarName, ThumbnailColour = colour.ThumbnailColour, PaletteID = colour.PaletteID, JapaneseName = colour.JapaneseName, LatinName = colour.LatinName }; output.WriteLine($"*{{{{ColorSquare|{colour.HexColour}}}}}{(string.IsNullOrWhiteSpace(colour.LatinName) ? "" : " " + colour.LatinName)}"); } output.WriteLine(); output.WriteLine(); } } }
private void CarListReceived(CarList obj) => Items = obj;
public Car GetCar(DataGridViewCell cell) { return((cell == null) ? null : CarList.getInstance().getItem(GetID(1, cell.RowIndex))); }
public int Load(CarList carList) { return(LoadFromAFile(OutputFile, carList)); }
private void button1_Click(object sender, EventArgs e) { CarList temp = new CarList(); if(checkBox1.Checked) { foreach(Car car in cList.Cars) if(CheckCar(car)) temp.Cars.Add(car); } else { foreach(Team team in FormMain.user.TeamList) foreach(Car car in team.Cars) { if(CheckCar(car)) temp.Cars.Add(car); } } cList = temp; checkBox1.Enabled = cList.Cars.Count > 0; checkBox1.Checked = false; labelCount.Text = cList.Cars.Count.ToString(); listView1.Items.Clear(); foreach(Car car in cList.Cars) { ListViewItem item = new ListViewItem(car.CarNO); item.SubItems.Add(car.SimNO); item.SubItems.Add(car.MachineNO); item.SubItems.Add(car.ControlPassword); item.SubItems.Add(car.MachineType); item.SubItems.Add(car.CarBrand); item.SubItems.Add(car.CarType); item.SubItems.Add(car.CarColor); item.SubItems.Add(car.InstallPlace); item.SubItems.Add(car.InstallPerson); item.SubItems.Add(car.BusinessPerson); item.SubItems.Add(car.JoinTime); item.SubItems.Add(car.OverServiceTime); item.SubItems.Add(car.CarRemark); item.SubItems.Add(car.Driver); item.SubItems.Add(car.DriverTel); item.SubItems.Add(car.DriverMobile); item.SubItems.Add(car.Driver2); item.SubItems.Add(car.Driver2Tel); item.SubItems.Add(car.Driver2Mobile); item.SubItems.Add(car.Password); item.SubItems.Add(car.DriverAddress); item.SubItems.Add(car.DriverTel); item.SubItems.Add(car.DriverCompany); item.SubItems.Add(car.BuyTime); item.SubItems.Add(car.SpecialRequest); item.SubItems.Add(car.DriverRemark); listView1.Items.Add(item); } }