private bool esValido() { Negocio.Cargos oCargos = new Negocio.Cargos(); string errores = ""; if (tipoOperacion != General.TipoOperacion.Alta) { if ((txtIdCargo.Text == "") || (!oCargos.ExisteCargo(Convert.ToInt32(txtIdCargo.Text)))) { errores += "-Nº de id incorrecto.\n"; } } if (txtDescripcion.Text == "") { errores += "-El cargo no es válido.\n"; } if (errores == "") { return true; } else { MessageBox.Show(errores, "Error"); return false; } }
private void buscarCargo() { Negocio.Cargos oCargos = new Negocio.Cargos(); if ((txtIdCargo.Text != "") && (oCargos.ExisteCargo(Convert.ToInt32(txtIdCargo.Text)))) { try { Entidades.Cargo oCargo = oCargos.RecuperarUno(int.Parse(txtIdCargo.Text))[0]; txtDescripcion.Text = oCargo.DescripcionCargo; this.id_buscado = txtIdCargo.Text; } finally { oCargos = null; } } else { MessageBox.Show("IdCargo incorrecto", "Error"); } }