Esempio n. 1
0
        private void ModifyVehicleOnSearch(object sender, Form.SubmittedEventArgs e)
        {
            var rego = e.Data.Get <string>("Registration").ToUpper();

            if (!RegoRegex.IsMatch(rego))
            {
                e.Result = "Invalid rego";
                return;
            }

            var vehicle = _fleet.Vehicles.FirstOrDefault(v => v.Registration == rego.ToUpper());

            if (vehicle == null)
            {
                e.Result = "No vehicle with that rego";
                return;
            }

            var modifyForm = ModifyVehicle.GetComponent <Form>("modify");

            modifyForm.Set("Registration", rego);
            modifyForm.Set("Grade", vehicle.Grade);
            modifyForm.Set("Make", vehicle.Make);
            modifyForm.Set("Model", vehicle.Model);
            modifyForm.Set("Year", vehicle.Year.ToString());
            modifyForm.Set("Seat count", vehicle.SeatCount.ToString());
            modifyForm.Set("Transmission", vehicle.Transmission);
            modifyForm.Set("Fuel type", vehicle.Fuel);
            modifyForm.Set("Has GPS", vehicle.HasGps);
            modifyForm.Set("Has sunroof", vehicle.HasSunRoof);
            modifyForm.Set("Daily rate $", vehicle.DailyRate.ToString(CultureInfo.InvariantCulture));
            modifyForm.Set("Colour", vehicle.Colour);

            ModifyVehicle.ActiveComponent = "modify";
        }
Esempio n. 2
0
        private void ModifyVehicleClick(object sender, RoutedEventArgs e)
        {
            ModifyVehicle _ModifyVehicle = new ModifyVehicle();

            _ModifyVehicle.Show();
            this.Close();
        }
Esempio n. 3
0
 public FleetManager(Fleet fleet, CustomerResourceManager crm)
 {
     _fleet = fleet;
     _crm   = crm;
     AddVehicle.Submitted += AddVehicleOnSubmitted;
     FleetSearch.GetComponent <Form>("initial search").Submitted += FleetSearchOnSearch;
     FleetSearch.GetComponent <Form>("customer list").Submitted  += FleetSearchOnSearch;
     ModifyVehicle.GetComponent <Form>("search").Submitted       += ModifyVehicleOnSearch;
     ModifyVehicle.GetComponent <Form>("modify").Submitted       += ModifyVehicleOnSubmit;
     DeleteVehicle.GetComponent <Form>("select").Submitted       += DeleteVehicleOnSearch;
     DeleteVehicle.GetComponent <Form>("confirm").Submitted      += DeleteVehicleOnSubmitted;
     RentVehicle.Submitted   += RentVehicleOnSubmitted;
     ReturnVehicle.Submitted += ReturnVehicleOnSubmitted;
     VehicleReport.PreRender += VehicleReportOnFocused;
 }