Пример #1
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddVehicleForm vehicleForm = new AddVehicleForm(null);

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

                Document.AddVehicle(newVehicle);
            }
        }
Пример #2
0
        private void toolStripButtonEdit_Click(object sender, EventArgs e)
        {
            ListViewItem   item        = VehiclesListView.SelectedItems[0];
            Vehicle        vehicle     = (Vehicle)item.Tag;
            AddVehicleForm vehicleForm = new AddVehicleForm(vehicle);

            if (vehicleForm.ShowDialog() == DialogResult.OK)
            {
                vehicle.brand       = vehicleForm.VehicleBrand;
                vehicle.maxSpeed    = vehicleForm.MaxSpeed;
                vehicle.prodDate    = vehicleForm.ProductionDate;
                vehicle.vehicleType = vehicleForm.Type;
                Document.UpdateVehicle(vehicle);
            }
        }