private void btnDeleteTrack_Click(object sender, EventArgs e) { // deletes track from database if (validate.IsSelected(lbTrackList, "Track List")) { string band = TrimString(lbBandList); string album = TrimString(lbAlbumList); string[] track = lbTrackList.SelectedItem.ToString().Split('\t'); BandAlbumTrackDB.DeleteTrack(band, album, track); Dictionary <int, string> trackDict = BandAlbumTrackDB.FetchTrackData(band, album); FillDictionary(trackDict, lbTrackList); } }
private void lbAlbumList_SelectedIndexChanged(object sender, EventArgs e) { // clears and refills albums listbox when selected index changes ClearInput(); if (lbAlbumList.SelectedItem == null) { MessageBox.Show("Please select an item from the list.", "Whoops"); } else { string bandName = TrimString(lbBandList); string albumName = TrimString(lbAlbumList); Dictionary <int, string> trackList = BandAlbumTrackDB.FetchTrackData(bandName, albumName); FillDictionary(trackList, lbTrackList); } }
private void btnViewAlbum_Click(object sender, EventArgs e) { // displays windows with all data for the selected album if (validate.IsSelected(lbAlbumList, "Album List")) { string newTrackList = ""; string band = TrimString(lbBandList); string album = TrimString(lbAlbumList); Dictionary <int, string> trackList = BandAlbumTrackDB.FetchTrackData(band, album); foreach (var track in trackList) { newTrackList += $"{track.Key}\t{track.Value}\n"; } MessageBox.Show($"Band:\t{band}\n" + $"Album:\t{album}\n" + $"Tracks:\n" + $"{newTrackList}", "Album Data"); } }
private void btnAddTrack_Click(object sender, EventArgs e) { try { if (validate.IsInt(txtTrackNo) && validate.IsInList(txtTrackName, lbTrackList) && validate.IsPresent(txtTrackName, "Track Name") && validate.IsInDictionary(lbTrackList, txtTrackNo.Text) && validate.IsSelected(lbAlbumList, lblAlbumName.Text)) { // track name is added to the listbox then the textbox is cleared Tracks newTrack = new Tracks { TrackTitle = txtTrackName.Text, TrackNumber = Int32.Parse(txtTrackNo.Text) }; string bandName = TrimString(lbBandList); string albumName = TrimString(lbAlbumList); BandAlbumTrackDB.InsertTrack(newTrack, bandName, albumName); Dictionary <int, string> trackList = BandAlbumTrackDB.FetchTrackData(bandName, albumName); FillDictionary(trackList, lbTrackList); txtTrackName.Clear(); txtTrackNo.Clear(); txtTrackName.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.GetType().ToString() + "\n" + ex.StackTrace, "Exception"); } }