private void AbrirBuscador(ProductoCriterioBusqueda? criterio, string text = null) { var texto = string.IsNullOrEmpty(text) ? txtCodigo.Text : text; if (!this.OwnedForms.Any()) { var productos = ProductosDatasource.Where(p => ComprasProducto.All(c => c.ProductoId != p.ProductoId)).ToList(); var frm = new BuscadorCompleto(texto, productos, criterio.GetValueOrDefault()); frm.TeclaApretada += FrmOnTeclaApretada; frm.Owner = this; Point locationOnForm = txtCodigo.PointToScreen(Point.Empty); //frm.ShowDialog(); frm.Top = locationOnForm.Y + 24; frm.Left = locationOnForm.X; frm.Closing += FrmOnClosing; frm.Show(); frm.Texto = texto; txtCodigo.Focus(); txtCodigo.Select(texto.Length, 0); } else { var buscador = this.OwnedForms.First() as BuscadorCompleto; buscador.Texto = texto; if (criterio != null) { buscador.EstablecerCriterio(criterio.GetValueOrDefault()); } buscador.AplicarFiltros(); } }
private void AbrirBuscador(ProductoCriterioBusqueda criterio) { if (!this.OwnedForms.Any()) { var frm = new BuscadorCompleto(txtCodigo.Text, ProductosDatasource.ToList(), criterio); frm.TeclaApretada += FrmOnTeclaApretada; frm.Owner = this; Point locationOnForm = txtCodigo.PointToScreen(Point.Empty); //frm.ShowDialog(); frm.Top = locationOnForm.Y + 24; frm.Left = locationOnForm.X; frm.Closing += FrmOnClosing; frm.Show(); frm.Texto = txtCodigo.Text; txtCodigo.Focus(); } else { var buscador = this.OwnedForms.First() as BuscadorCompleto; buscador.Texto = txtCodigo.Text; buscador.AplicarFiltros(); } }