private void SetupDataGridViewColumns() { dataGridViewCustomers.ColumnCount = customerColumns.Length; for (int i = 0; i < customerColumns.Length; i++) { dataGridViewCustomers.Columns[i].Name = customerColumns[i]; } dataGridViewFleet.ColumnCount = fleetColumns.Length; for (int j = 0; j < fleetColumns.Length; j++) { dataGridViewFleet.Columns[j].Name = fleetColumns[j]; } // USED TO LABEL THE COLUMNS AT THE TOP OF THE TABLE v = fleet.GetFleet(); for (int k = 0; k < v.Count(); k++) { string[] vehicle = v[k].ToCSVString().Split(','); this.dataGridViewFleet.Rows.Add(vehicle[0], vehicle[1], vehicle[2], vehicle[3], vehicle[4], vehicle[5], vehicle[6], vehicle[7], vehicle[8], vehicle[9], vehicle[11], vehicle[10]); } c = crm.GetCustomers(); for (int l = 0; l < c.Count(); l++) { string[] customer = c[l].ToCSVString().Split(','); this.dataGridViewCustomers.Rows.Add(customer[0], customer[1], customer[2], customer[3], customer[4], customer[5]); } //USED TO ADD CUSTOMERS AND VEHICLES TO THE TABLE }
private void SetUpRentalReport() { int totalRented = 0; double totalRent = 0; rentalsDataGridView.Rows.Clear(); foreach (Vehicle vec in fleet.GetFleet(true)) { string[] input = new string[] { vec.VehicleRego, fleet.RentedBy(vec.VehicleRego).ToString(), "$" + vec.DailyRate.ToString() }; rentalsDataGridView.Rows.Add(input); totalRented++; totalRent += vec.DailyRate; } rentedLabel.Text = totalRented.ToString(); totalDailyRateLabel.Text = "$" + totalRent.ToString(); }
private void PopulateFleetGrid() { //Author: Jericho Duggan dgvFleet.Rows.Clear(); foreach (Vehicle variable in fleet.GetFleet()) { dgvFleet.Rows.Add(new string[] { variable._VehicleRego, variable._Model, variable._Make, variable._Year.ToString(), variable._VehicleClass.ToString(), variable._NumSeats.ToString(), variable._Transmissiontype.ToString(), variable._FuelType.ToString(), variable._gps.ToString(), variable._SunRoof.ToString(), variable._Colour, variable._DailyRate.ToString() }); } }
// Method to set up vehicles for the search private void setUpVehicles(out Fleet fleetVehicles) { // Create fleet instance object inside the method fleetVehicles = new Fleet(Fleet.FleetFile, Fleet.RentalsFile); // Create vehicle list to store vehicles and their attributes as a string List <string> vehicles = new List <string>(); // For each vehicle in unrented vehicle list foreach (Vehicle vehicle in fleetVehicles.GetFleet(false)) { // convert attribute list to a string using the join method vehicles.Add(string.Format($"{vehicle.registration},{vehicle.grade},{vehicle.make},{vehicle.model},{vehicle.year},{vehicle.numSeats}," + $"{vehicle.transmission},{vehicle.fuel},{vehicle.GPS},{vehicle.sunRoof},{vehicle.colour}")); } // For each vehicle, insert the csv string. for (int i = 0; i < vehicles.Count; i++) { fleetVehicles.insertVehicle(vehicles[i]); } }
private void RefreshFleet() { this.carListView1.Items.Clear(); foreach (Vehicle Veh in fleetMan.GetFleet()) { string[] newArr = new string[12]; newArr[0] = Veh.car_rego; newArr[1] = Veh.car_make; newArr[2] = Veh.car_model; newArr[3] = Veh.car_year; // newArr[4] = Veh.car_class; newArr[4] = Veh.car_class.ToString(); newArr[5] = Veh.car_numSeats.ToString(); newArr[6] = Veh.car_trans.ToString(); newArr[7] = Veh.car_fuel.ToString(); newArr[8] = Veh.car_GPS.ToString(); newArr[9] = Veh.car_sunroof.ToString(); newArr[10] = Veh.car_colour; decimal dr = decimal.Parse(Veh.car_Drate.ToString()); string drate = String.Format("{0:C}", dr); newArr[11] = drate; ListViewItem itm = new ListViewItem(newArr); this.carListView1.Items.Add(itm); } }