Ejemplo n.º 1
0
        private void tb_search_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (tb_search.Text == "")
            {
                btn_refresh_Click(sender, e);
            }
            else
            {
                try
                {
                    DataGrid_Shipments.ItemsSource = null;

                    var allShipments = _shipmentController.GetShipmentsAll();
                    var data         = allShipments.Where(t => t.Fio.ToUpper().StartsWith(tb_search.Text.ToUpper())).ToList();
                    var sDop         = allShipments.Where(t => t.Fio.ToUpper().Contains(tb_search.Text.ToUpper())).ToList();
                    data.AddRange(sDop);
                    var noDupes = data.Distinct().ToList();
                    DataGrid_Shipments.ItemsSource = noDupes;

                    //TODO: WTF?
                    if (noDupes.Count == 0)
                    {
                        //Ничекго не нашел
                    }
                    else
                    {
                        // Нашел
                    }
                }
                catch (Exception ex)
                {
                    MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                    if (mainWindow != null)
                    {
                        mainWindow.ContentErrorText.ShowAsync();
                        mainWindow.text_debuger.Text = ex.ToString();
                    }
                }
            }
        }