private void btnGuardar_Click(object sender, EventArgs e) { try { if (VerificarInformacion()) { DatoAutomovil automovil = new DatoAutomovil(); automovil.Conductor = txtConductor.Text; automovil.Marca = txtMarca.Text; automovil.Modelo = txtModelo.Text; automovil.Placa = txtPlaca.Text; automovil.Kilometraje = Convert.ToInt32(mtxtKilometraje.Text); automovil.FechaCompra = dtpFecha.Value.ToString(); automoviles.Agregar(automovil); MessageBox.Show("Datos guardados correctamente."); LimpiarControles(); } else { MessageBox.Show("Ingrese toda la información"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Agregar(DatoAutomovil datoAutomovil) { datosAutomoviles.Add(datoAutomovil); }