private void ObtenerValoresBusqueda(int inicio, int limite) { try { if (dgConsulta.Items.Count > 0) { dgConsulta.ItemsSource = null; dgConsulta.Items.Clear(); } var tiposParametros = new List <Type>(); var valoresParametros = new List <Object>(); if (string.Compare(txtBusqueda.Text.Trim(), descripcionAnterior.Trim(), StringComparison.CurrentCultureIgnoreCase) != 0) { descripcionAnterior = txtBusqueda.Text; ucPaginacion.Inicio = 1; inicio = 1; } var paginacionInfo = new PaginacionInfo { Inicio = inicio, Limite = limite }; tiposParametros.Add(paginacionInfo.GetType()); valoresParametros.Add(paginacionInfo); Contexto.GetType().GetProperty(CampoDescripcion).SetValue(Contexto, txtBusqueda.Text, null); tiposParametros.Add(Contexto.GetType()); valoresParametros.Add(Contexto); MethodInfo metodo = ObjetoNegocio.GetType().GetMethod(MetodoInvocacion, tiposParametros.ToArray()); if (metodo != null) { dynamic resultadoInvocacion = metodo.Invoke(ObjetoNegocio, valoresParametros.ToArray()); if (resultadoInvocacion != null && resultadoInvocacion.Lista != null && resultadoInvocacion.Lista.Count > 0) { ucPaginacion.TotalRegistros = resultadoInvocacion.TotalRegistros; dgConsulta.ItemsSource = resultadoInvocacion.Lista; } else { ucPaginacion.TotalRegistros = 0; } } } catch (ExcepcionGenerica) { SkMessageBox.Show(this, SuKarne.Controls.Properties.Resources.Ayuda_MensajeError, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(this, SuKarne.Controls.Properties.Resources.Ayuda_MensajeError, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Consulta los valores de ayuda /// </summary> /// <param name="valorParametro"></param> private void ConsultarValores(object valorParametro) { if (ValidarSiPuedeBuscar()) { try { existenDatos = false; PropertyInfo property = EsAyudaSimple ? Contexto.GetType().GetProperty(CampoDescripcion) : Contexto.GetType().GetProperty(CampoClave); if (property != null) { var tiposParametros = new[] { Contexto.GetType() }; var metodo = ObjetoNegocio.GetType().GetMethod(MetodoInvocacion, tiposParametros); if (metodo != null) { if (valorParametro == null) { object valorPropiedad = property.GetValue(Contexto, null); property.SetValue(Contexto, valorPropiedad, null); } else { try { property.SetValue(Contexto, valorParametro, null); } catch (Exception) { property.SetValue(Contexto, Convert.ToInt32(valorParametro), null); } } var valoresParametros = new[] { Contexto }; object resultadoInvocacion = metodo.Invoke(ObjetoNegocio, valoresParametros); if (resultadoInvocacion != null) { existenDatos = true; AsiganaValores(resultadoInvocacion); } else { SkMessageBox.Show(Application.Current.Windows[1], MensajeClaveInexistenteBusqueda, MessageBoxButton.OK, MessageImage.Warning); LimpiarCampos(); if (BusquedaVacia != null) { BusquedaVacia(); } } } } } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[1], SuKarne.Controls.Properties.Resources.Ayuda_MensajeError, MessageBoxButton.OK, MessageImage.Error); } } }