Example #1
0
        private void editCar_Click(object sender, EventArgs e)
        {
            if (carsList.SelectedIndex > -1)
            {
                int          index      = carsList.SelectedIndex;
                List <CarID> carsIDList = new List <CarID>();
                foreach (Transport car in Cars)
                {
                    carsIDList.Add(car.ID);
                }

                if ((Cars[index] as RouteTaxi) != null)
                {
                    EditRouteTaxi editRouteTaxi = new EditRouteTaxi(carsIDList, "Edit car", (RouteTaxi)Cars[index]);
                    editRouteTaxi.ShowDialog();
                    if (editRouteTaxi.IsHandled)
                    {
                        Cars[index] = new RouteTaxi(editRouteTaxi.Car);

                        carsList.SelectedIndex = Cars.Count - 1;
                        carsList_SelectedIndexChanged(this, new EventArgs());
                        changesSaved = false;
                        EnableSave(true);
                    }
                }
            }
        }
Example #2
0
        private void newCar_Click(object sender, EventArgs e)
        {
            List <CarID> carsIDList = new List <CarID>();

            foreach (Transport car in Cars)
            {
                carsIDList.Add(car.ID);
            }

            switch (typesList.Text)
            {
            case "Route taxi":
                EditRouteTaxi editRouteTaxi = new EditRouteTaxi(carsIDList, "Register car");
                editRouteTaxi.ShowDialog();
                if (editRouteTaxi.IsHandled)
                {
                    Cars.Add(editRouteTaxi.Car);
                    carsList.SelectedIndex = Cars.Count - 1;
                    carsList_SelectedIndexChanged(this, new EventArgs());
                    changesSaved = false;
                    EnableSave(true);
                }
                break;
            }
        }