void bwCDList_DoWork(object sender, DoWorkEventArgs e) { SafeObservableCollection <AlbumItem> items = new SafeObservableCollection <AlbumItem>(); int count = 0; Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree); using (DataBaseView view = AlbumView.CreateView(this.DataBase, this.CdListFields.GetFields(), new SortFieldCollection(), 0, searchCondition)) { object[] values; while ((values = view.Read()) != null) { AlbumItem newItem = new AlbumItem(); newItem.ID = (int)values[0]; newItem.Items = new object[values.Length - 1]; FillRowValues(newItem, values); items.AddItemFromThread(newItem); count++; } } e.Result = items; }
private void UpdateAlbumItem(AlbumItem albumItem) { DataBaseView view = AlbumView.CreateView(DataBase, CdListFields.GetFields(), CdListSort, albumItem.ID); object[] values = view.Read(); FillRowValues(albumItem, values); ListCollectionView lcv = this.dataGrid.ItemsSource as ListCollectionView; lcv.Refresh(); }
private void Search() { Big3.Hitbase.DataBaseEngine.Condition sel = new Big3.Hitbase.DataBaseEngine.Condition(); // Diese Sachen direkt speichern, wenn einmal gesucht wurde. Settings.SetValue("LinkSameNumber", checkBoxSameTrackCount.IsChecked == true ? (int)1 : (int)0); Settings.SetValue("LinkNotLinked", checkBoxNotAssigned.IsChecked == true ? (int)1 : (int)0); // Nur CDs. sel.Add(Field.AlbumType, Operator.Equal, 0); if (this.checkBoxNotAssigned.IsChecked == true) { sel.Add(Field.Identity, Operator.Empty, 0); } if (this.checkBoxSameTrackCount.IsChecked == true) { sel.Add(Field.NumberOfTracks, Operator.Equal, cdInDrive.NumberOfTracks); } if (textBoxArtist.Text != "") { sel.Add(Field.ArtistCDName, Operator.Contains, textBoxArtist.Text); } if (textBoxTitle.Text != "") { sel.Add(Field.Title, Operator.Contains, textBoxTitle.Text); } SortFieldCollection sortKeys = new SortFieldCollection(); sortKeys.Add(Field.ArtistCDName); sortKeys.Add(Field.Title); FieldCollection fc = new FieldCollection(); fc.Add(Field.ArtistCDName); fc.Add(Field.Title); fc.Add(Field.TotalLength); fc.Add(Field.NumberOfTracks); List <CDItemResult> items = new List <CDItemResult>(); using (DataBaseView albumView = AlbumView.CreateView(dataBase, fc, sortKeys, 0, sel)) { object[] values; while ((values = albumView.Read()) != null) { CDItemResult newItem = new CDItemResult(); newItem.CDID = (int)values[0]; newItem.Artist = (string)values[1]; newItem.Title = values[2] is DBNull ? "" : (string)values[2]; newItem.Length = (int)values[3]; newItem.NumberOfTracks = (int)values[4]; items.Add(newItem); } } DataGridResult.ItemsSource = items; return; }