private void LibraryListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TrackNameTextBlock.Text = "None";
            LengthTextBlock.Text    = "None";
            ArtistTextBlock.Text    = "None";
            AlbumTextBlock.Text     = "None";
            SubListSource.Clear();
            LibrarySelectedView.SelectedItem = null;
            LibrarySelectedView.ItemsSource  = null;
            TracksDataGrid.ItemsSource       = null;

            string current_selection = LibraryListView.SelectedValue.ToString();

            if (current_selection.Equals("Music"))
            {
                Console.WriteLine("Music detected.");
                //Display artists and its tracks.
                DataTable artists = dm.runSelectQuery("select * from Artists");
                foreach (DataRow row in artists.Rows)
                {
                    SubListSource.Add(row["FirstName"] + " " + row["LastName"]);
                }
            }
            else
            {
                DataTable playlists = dm.runSelectQuery("select * from Playlists");
                foreach (DataRow row in playlists.Rows)
                {
                    SubListSource.Add(row["PlaylistName"] as string);
                }
            }
            LibrarySelectedView.ItemsSource = SubListSource;
        }
示例#2
0
        private void OnTableSelectionChanged(object sender, RoutedEventArgs e)
        {
            string selected = TableSelectComboBox.SelectedValue.ToString();

            if (selected.Equals("Tracks"))
            {
                LastNameTextBox.IsEnabled  = false;
                YearTextBox.IsEnabled      = false;
                GenreNameTextBox.IsEnabled = false;

                DataTable artists = dm.runSelectQuery("select Artists.FirstName from Artists");
                Artists.Clear();
                foreach (DataRow row in artists.Rows)
                {
                    Artists.Add(row["FirstName"] as string);
                }
                ArtistSelectComboBox.ItemsSource = Artists;

                DataTable albums = dm.runSelectQuery("select Albums.AlbumName from Albums");
                Albums.Clear();
                foreach (DataRow row in albums.Rows)
                {
                    Albums.Add(row["AlbumName"] as string);
                }
                AlbumSelectComboBox.ItemsSource = Albums;
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string q = QueryTextbox.Text;

            Console.WriteLine("Received query: '" + q + "'");
            DataTable results = dm.runSelectQuery(q);

            SQLResultDataGrid.ItemsSource = null;
            SQLResultDataGrid.ItemsSource = results.DefaultView;
        }