private void bt_Search_Click(object sender, RoutedEventArgs e) { string _searchphrase = tb_Search.Text; using (dbSclad = new ScladDbset(_pathDB)) { dataTable.ItemsSource = null; //dataTable.Items.Clear(); //dataTable.Columns.Clear(); var _search = dbSclad.Goods.Where(p => p.Name.Contains(_searchphrase)).ToList(); var _binding = new BindingList <Good>(_search); dataTable.ItemsSource = _binding; dataTable.Columns[0].Visibility = Visibility.Hidden; } }
private void Create_Base_Click(object sender, RoutedEventArgs e) { SaveFileDialog _saveFile = new SaveFileDialog(); _saveFile.DefaultExt = ".mdf"; _saveFile.Filter = "Local Data Base (.mdf)|*.mdf"; if (_saveFile.ShowDialog() == true) { string _filename = _saveFile.FileName; _pathDB = @" data source=(localdb)\v11.0; AttachDbFilename=" + _filename + ";Integrated Security=True;"; dbSclad = new ScladDbset(_pathDB); dbSclad.Goods.Load(); dataTable.ItemsSource = dbSclad.Goods.Local.ToBindingList(); dataTable.Columns[0].Visibility = Visibility.Hidden; } else { return; } }