Esempio n. 1
0
        private void RemoveLastVehicle(object sender, EventArgs e)
        {
            if (vehicles.Count < 1)
            {
                errorLabel.Text = ErrorMessages.NO_VEHICLES_TO_REMOVE;
                timerClearErrors.Stop();
                timerClearErrors.Start();

                return;
            }

            string           action           = "remove the last vehicle";
            FormConfirmation formConfirmation = new FormConfirmation(action);

            var result = formConfirmation.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            Vehicle lastVehicle = vehicles[vehicles.Count - 1];

            IDManagement.MarkVehicleIDAsAvailable(lastVehicle.ID);

            lastVehicle.Selected = false;
            RemoveVehicle(lastVehicle);

            errorLabel.Text = "";
        }
Esempio n. 2
0
        void RemoveVehicle(Vehicle vehicle, bool makeIDAvailable = true)
        {
            if (makeIDAvailable)
            {
                IDManagement.MarkVehicleIDAsAvailable(vehicle.ID);
            }

            availableCarsElementsPanel.VerticalScroll.Value = 0;
            vehicles.Remove(vehicle);
            PopulateVehiclesPanel();
        }
Esempio n. 3
0
        public void RemoveRental(Rental rental, bool makeRentalIDAvailable = true, bool makeVehicleIDAvailable = true)
        {
            if (makeRentalIDAvailable)
            {
                IDManagement.MarkRentalIDAsAvailable(rental.ID);
            }

            if (makeVehicleIDAvailable)
            {
                IDManagement.MarkVehicleIDAsAvailable(rental.Vehicle.ID);
            }

            rentedCarsElementsPanel.VerticalScroll.Value = 0;
            rentals.Remove(rental);
            PopulateRentalsPanel();
        }
Esempio n. 4
0
        private void RemoveSelectedVehicles(object sender, EventArgs e)
        {
            if (indexesOfSelectedVehicles.Count > 0)
            {
                string           action           = "remove the selected vehicles";
                FormConfirmation formConfirmation = new FormConfirmation(action);

                var result = formConfirmation.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return;
                }

                errorLabel.Text = "";

                // Store the vehicles to be removed in a temporary List
                List <Vehicle> vehiclesToBeRemoved = new List <Vehicle>();
                foreach (int index in indexesOfSelectedVehicles)
                {
                    short idToBeMarkedAsAvailable = vehicles[index].ID;
                    IDManagement.MarkVehicleIDAsAvailable(idToBeMarkedAsAvailable);
                    vehiclesToBeRemoved.Add(vehicles.ElementAt(index));
                }

                // Remove the stored vehicles from the vehicles List
                foreach (Vehicle vehicle in vehiclesToBeRemoved)
                {
                    vehicles.Remove(vehicle);
                }

                PopulateVehiclesPanel();
                indexesOfSelectedVehicles.Clear();
            }

            else
            {
                errorLabel.Text = ErrorMessages.NO_VEHICLES_SELECTED;
                timerClearErrors.Stop();
                timerClearErrors.Start();
            }
        }