Exemplo n.º 1
0
        private void AddToolStripMenuItem_Click(object sender, EventArgs e)
        {
            VehicleForm vehicleForm = new VehicleForm(null);

            if (vehicleForm.ShowDialog() == DialogResult.OK)
            {
                Vehicle newVehicle = new Vehicle(vehicleForm.Model, vehicleForm.Type, vehicleForm.ProductionDate, vehicleForm.MaxVelocity);

                Document.AddVehicle(newVehicle);
            }
        }
Exemplo n.º 2
0
        private void EditToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem vehicleItem in vehiclesListView.SelectedItems)
            {
                Vehicle     vehicle     = (Vehicle)vehicleItem.Tag;
                VehicleForm vehicleForm = new VehicleForm(vehicle);
                if (vehicleForm.ShowDialog() == DialogResult.OK)
                {
                    vehicle.Model          = vehicleForm.Model;
                    vehicle.Type           = vehicleForm.Type;
                    vehicle.ProductionDate = vehicleForm.ProductionDate;
                    vehicle.MaxVelocity    = vehicleForm.MaxVelocity;

                    Document.UpdateVehicle(vehicle);
                }
            }
        }