private void AddVehicleToolStripMenuItem_Click(object sender, EventArgs e) { VehicleForm vehicleForm = new VehicleForm(null, document.vehicles); if (vehicleForm.ShowDialog() == DialogResult.OK) { Vehicle newVehicle = new Vehicle(vehicleForm.vehicleBrand, vehicleForm.vehicleMaxSpeed, vehicleForm.vehicleDateOfProductionValue, vehicleForm.vehicleType); document.AddVehicle(newVehicle); } }
private void EditVehicleToolStripMenuItem_Click(object sender, EventArgs e) { if (vehicelsListView.SelectedItems.Count == 1) { Vehicle vehicle = (Vehicle)vehicelsListView.SelectedItems[0].Tag; VehicleForm vehicleForm = new VehicleForm(vehicle, document.vehicles); if (vehicleForm.ShowDialog() == DialogResult.OK) { vehicle.brand = vehicleForm.vehicleBrand; vehicle.maxSpeed = vehicleForm.vehicleMaxSpeed; vehicle.dateOfProduction = vehicleForm.vehicleDateOfProductionValue; vehicle.type = vehicleForm.vehicleType; document.UpdateVehicle(vehicle); } } }