private void btnRegistrar_Click(object sender, EventArgs e) { try { if (!DAL.Vaidacion.validarTxtBox(panel1)) { DAL.Cliente ingreso = new DAL.Cliente(); ingreso.Nombre = txtNombre.Text; ingreso.Paterno = txtPaterno.Text; ingreso.Materno = txtMaterno.Text; ingreso.Cedula = Convert.ToInt32(txtCedula.Text); ingreso.Telefono = Convert.ToInt32(txtTelefono.Text); ingreso.Eliminar = 0; if (dgvAutos.Rows.Count > 0) { foreach (DataGridViewRow item in dgvAutos.Rows) { if (item.Cells[0].Value != null) { DAL.Vehiculo v = new DAL.Vehiculo(); v.Placa = item.Cells[0].Value.ToString(); v.Modelo.IdModelo = Convert.ToInt32(item.Cells["Modelo"].Value); v.TipoVehiculo.IdTipoVehiculo = Convert.ToInt32(item.Cells["TipoVehiculo"].Value); ingreso.setVehiculo(v); } } } BRL.ClienteBRL.GuardarCliente(ingreso); MessageBox.Show("Datos Agregados"); dgvAutos.Rows.Clear(); } else { MessageBox.Show("Campos requeridos vacios", "ERROR"); } } catch (SqlException ex) { MessageBox.Show("Error " + ex, "Error SQL", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { MessageBox.Show("Datos incorrectos", "Error Datos", MessageBoxButtons.OK, MessageBoxIcon.Error); } }