public void agregarCoche(Coches coche, int vecesRepetido)
        {
            /*Es necesario esto para poder guardar luego los nuevos coches que se vallan agregando a una formacion ya existente*/
            Formaciones_X_Coches fc = new Formaciones_X_Coches();
            fc.Coches = coche;
            fc.VecesRepetido = vecesRepetido;
            fc.Id_Formacion = this.Id;
            Formaciones_X_Coches.Add(fc);

            for (int i = 0; i < vecesRepetido; i++)
                _listaCoches.Add(coche);
        }
        private void btnAgregarCocheMod_Click(object sender, EventArgs e)
        {
            if (lbxCochesExistentesMod.SelectedIndex > -1)
            {
                string errorMsj = "";
                Coches cocheSeleccionado = (Coches)lbxCochesExistentesMod.SelectedItem;
                Formaciones formacionSeleccionada = (Formaciones)lbxFormacionesModificar.SelectedItem;

                if (formacionSeleccionada == null)
                    errorMsj += "No se seleccionó ninguna formación para ser modificada.\n";
                if (cocheSeleccionado == null)
                    errorMsj += "No se seleccionó ningún coche para ser agregado.\n";
                if (!Util.EsNumerico(txtCantidadCochesMod.Text))
                    errorMsj += "Cantidad de coches: Incompleto ó Incorrecto.\n";
                else if (Convert.ToInt32(txtCantidadCochesMod.Text) == 0)
                {
                    errorMsj += "Cantidad de coches: El valor debe ser positivo.\n";
                }

                if (formacionSeleccionada.Formaciones_X_Coches.Where(x => x.Coches.Modelo == cocheSeleccionado.Modelo).Count() != 0)
                    errorMsj += "El coche ya pertenece a la formación.\n";

                if (string.IsNullOrEmpty(errorMsj))
                {
                    Formaciones_X_Coches fc = new Formaciones_X_Coches();
                    fc.Coches = cocheSeleccionado;
                    fc.Id_Coche = cocheSeleccionado.Id;
                    fc.VecesRepetido = Convert.ToInt32(txtCantidadCochesMod.Text);
                    formacionSeleccionada.Formaciones_X_Coches.Add(fc);
                    lbxCochesFormacionMod.Items.Add(fc);
                    txtCantidadCochesMod.Text = "";
                    RecalcularTotalesFormacion();
                }
                else
                    MessageBox.Show(errorMsj);
            }
        }
        private void btnAgregarFormacion_Click(object sender, EventArgs e)
        {
            Coches unCoche = (Coches)lbxCochesExistentes.SelectedItem;

            if (unCoche == null) return;

            string errorMsj = "";
            if (!Util.EsNumerico(txtCantidadCoches.Text))
                errorMsj += "Cantidad: Incompleto ó Incorrecto.\n";
            else if (int.Parse(txtCantidadCoches.Text) < 1)
                errorMsj += "Cantidad: El Valor debe ser Positivo.\n";
            if(lbxCochesExistentes.SelectedItem == null)
                errorMsj += "No se seleccionó ningun coche para agregar a la formación.\n";
            if (auxCochesFormacion.Where(x => x.Id_Coche == unCoche.Id).Count() != 0)
                errorMsj += "El coche ya existe dentro de esta formación.\n";

            if (String.IsNullOrEmpty(errorMsj))
            {
                Formaciones_X_Coches fc = new Formaciones_X_Coches();
                fc.Coches = unCoche;
                fc.Id_Coche = unCoche.Id;
                fc.VecesRepetido = Convert.ToInt32(txtCantidadCoches.Text);
                auxCochesFormacion.Add(fc);
                lbxCochesFormacion.Items.Add(unCoche);
                RecalcularTotalesFormacion();
            }
            else
                MessageBox.Show(errorMsj);
        }