private void btnAceptar_Click(object sender, EventArgs e) { var datosInterprete = new Interprete(); datosInterprete.Nombre = txtNombre.Text.Trim(); datosInterprete.Id = _id; if (cmbPais.SelectedValue is null) { MessageBox.Show("Nombre de pais no existe!"); cmbPais.Focus(); return; } else { datosInterprete.Id_Pais = cmbPais.SelectedValue.ToString(); } if (!datosInterprete.NombreValido()) { MessageBox.Show("Nombre Invalido!"); txtNombre.Text = ""; txtNombre.Focus(); return; } if (datosInterprete.Nombre != interprete.Nombre) { if (datosInterprete.NombreRepetido(datosInterprete.Nombre)) { MessageBox.Show("Nombre ya existe!"); txtNombre.Text = ""; txtNombre.Focus(); return; } } if (!datosInterprete.IdValido()) { MessageBox.Show("Pais Invalido!"); cmbPais.Focus(); return; } if (interpretesRepositorio.Editar(datosInterprete)) { MessageBox.Show("La edicion ha finalizado correctamente"); this.Dispose(); } }
private void btnAceptar_Click(object sender, EventArgs e) { var interprete = new Interprete(); interprete.Nombre = txtNombre.Text.Trim(); if (cmbPais.SelectedValue is null) { MessageBox.Show("Nombre de pais no existe!"); cmbPais.Focus(); return; } else { interprete.Id_Pais = cmbPais.SelectedValue.ToString(); } if (!interprete.NombreValido()) { MessageBox.Show("Nombre Invalido!"); txtNombre.Text = ""; txtNombre.Focus(); return; } if (interprete.NombreRepetido(interprete.Nombre)) { MessageBox.Show("Nombre ya existe!"); txtNombre.Text = ""; txtNombre.Focus(); return; } if (!interprete.IdValido()) { MessageBox.Show("Pais Invalido!"); cmbPais.Focus(); return; } if (interpretesRepositorio.Guardar(interprete)) { MessageBox.Show("Se agrego interprete con exito!"); this.Dispose(); } }