private void btn_registrar_Click(object sender, RoutedEventArgs e) { String marca = txt_marca.Text; String modelo = txt_modelo.Text; String año = txt_año.Text; String color = txt_color.Text; String aseguradora = txt_aseguradora.Text; String numPoliza = txt_num_poliza.Text; String numPlacas = txt_num_placas.Text; int posicionConductor = cmb_conductores.SelectedIndex; Boolean camposLlenos = true; Boolean placasRepetida = false; placasRepetida = VehiculoDAO.verificarPlacasRegistradas(numPlacas); if (marca.Length == 0) { camposLlenos = false; txt_marca.BorderBrush = Brushes.Red; } if (modelo.Length == 0) { camposLlenos = false; txt_modelo.BorderBrush = Brushes.Red; } if (año.Length == 0) { camposLlenos = false; txt_año.BorderBrush = Brushes.Red; } if (color.Length == 0) { camposLlenos = false; txt_color.BorderBrush = Brushes.Red; } if (aseguradora.Length == 0) { camposLlenos = false; txt_aseguradora.BorderBrush = Brushes.Red; } if (numPoliza.Length == 0) { camposLlenos = false; txt_num_poliza.BorderBrush = Brushes.Red; } if (numPlacas.Length == 0) { camposLlenos = false; txt_num_placas.BorderBrush = Brushes.Red; } if (posicionConductor < 0) { camposLlenos = false; cmb_conductores.BorderBrush = Brushes.Red; } if (camposLlenos) { String numLicencia = conductores[cmb_conductores.SelectedIndex].NumeroLicencia; int resultado = 0; if (isNuevo) { if (!placasRepetida) { resultado = VehiculoDAO.agregarVehiculo(numLicencia, marca, modelo, año, color, aseguradora, numPoliza, numPlacas); if (resultado > 0) { MessageBox.Show("El vehiculo se registro exitosamente", "Registro exitoso"); notificacion.actualizaInformacion("Registrar"); this.Close(); } else { MessageBox.Show("No fue posible hacer el registro", "Ocurrió un error"); } } else { MessageBox.Show("Este numero de placas han sido registradas anteriormente.", "Atención"); } } else { resultado = VehiculoDAO.modificarVehiculo(numLicencia, marca, modelo, año, color, aseguradora, numPoliza, numPlacas, vehiculoEdicion.IdVehiculo); if (resultado > 0) { MessageBox.Show("Vehiculo actualizado exitosamente", "Mensaje de confirmación"); notificacion.actualizaInformacion("Editar"); this.Close(); } else { MessageBox.Show("Error, intente más tarde", "Error"); } } } else { MessageBox.Show("Favor de llenar todos los campos", "Campos vacíos"); } }