private void computeJourneyHistoryDetails(Vehicle v, List <Journey> allJournies) { //Get data List <Journey> vJournies = Journey.FindJournies(allJournies, v.getVehicleID()); //Get the journies for this vehicle! //Compute revenue info double revenue = 0; double unpaid = 0; //initialise costings foreach (Journey j in vJournies) { //loop through journies for vehicle revenue = revenue + j.JourneyCost(); //Sum journey costs if (!j.isPaid()) { unpaid = unpaid + j.JourneyCost(); } //Sum unpaid costs for this vehicle } this.revenueInfo = revenue + " (with " + unpaid + " unpaid)"; }
public HistoryWindow(int vehicleID, List <Service> allServices, List <Journey> allJournies, List <FuelPurchase> allFuelPurchases) { InitializeComponent(); this.vehicleID = vehicleID; this.Title = "History of Vehicle ID: " + vehicleID; // the journeys of the car this.allJournies = allJournies; this.journies = Journey.FindJournies(allJournies, vehicleID); // services of the car this.allServices = allServices; this.services = Service.FindServices(allServices, vehicleID); //Fuel Purchase of the car this.allFuelPurchases = allFuelPurchases; this.FPurchases = FuelPurchase.FindFuelPurchases(allFuelPurchases, vehicleID); this.DataContext = this; formatDates("{0:dd/MM/yyyy}"); performRefresh(); //Binding }