示例#1
0
        private void addSongButton_Click(object sender, EventArgs e)
        {
            var repository = new CDCatalogRepository();
            var formHelper = new FormHelper();

            if (!formHelper.TextBoxHasContents(addSongTxtBoxSongGenre))
            {
                MessageBox.Show("Please enter a genre.", "Input validation error");
                addSongTxtBoxSongGenre.Focus();
            }
            else
            {
                var newGenre = addSongTxtBoxSongGenre.Text.Trim();
                var genres = repository.SearchGenreByGenreName(newGenre);

                if (genres.Count > 0)
                {
                    MessageBox.Show("You wanted to add " + newGenre + ", but " + genres[0].GenreName + " already exsists.", "Genre must be unique");
                    addSongTxtBoxSongGenre.Focus();
                }
                else
                {
                    CreatedGenre = repository.CreateGenre(addSongTxtBoxSongGenre.Text.Trim());
                    Close();
                }
            }
        }
示例#2
0
        private void addArtistButton_Click(object sender, System.EventArgs e)
        {
            var repository = new CDCatalogRepository();
            var formHelper = new FormHelper();

            if (!formHelper.TextBoxHasContents(addArtistTxtBoxArtistName))
            {
                MessageBox.Show("Please enter an artist name.", "Input validation error");
                addArtistTxtBoxArtistName.Focus();
            }
            else
            {
                var newArtist = addArtistTxtBoxArtistName.Text.Trim();
                var artists = repository.SearchArtistByArtistNameExclusive(newArtist);

                if (artists.Count > 0)
                {
                    MessageBox.Show("You wanted to add " + newArtist + ", but " + artists[0].ArtistName + " already exsists.", "Artist must be unique");
                    addArtistTxtBoxArtistName.Focus();
                }
                else
                {
                    CreatedArtist = repository.CreateArtist(addArtistTxtBoxArtistName.Text.Trim());
                    this.Close();
                }
            }
        }
示例#3
0
        private void updateSongButton_Click(object sender, System.EventArgs e)
        {
            var repository = new CDCatalogRepository();
            var formHelper = new FormHelper();

            int songRating = 0;

            //Check if textbox has an int and it is between 0 and 5 (inclusive)
            if (int.TryParse(updateSongTextBox.Text.Trim(), out songRating) && songRating >= 0 && songRating <= 5)
            {
                //if AlbumTitle not provided assing null to album
                var albums = AlbumTitleOfSong != null ? repository.SearchAlbumsByAlbumTitleExclusive(AlbumTitleOfSong) : null;
                //Send update to reposistory based on whether album name provided
                if (AlbumTitleOfSong == null)
                    repository.UpdateSongRating(SongTitleToUpdate, songRating);

                else
                    repository.UpdateSongRating(SongTitleToUpdate, songRating, albums[0]);
                Close();
            }
            else
            {
                MessageBox.Show("Please enter a rating can only be between 1 and 5", "Input validation error");
                updateSongTextBox.Focus();
                DialogResult = DialogResult.None;
            }
        }
示例#4
0
        private void updateAlbumButton_Click(object sender, System.EventArgs e)
        {
            var repository = new CDCatalogRepository();
            var formHelper = new FormHelper();

            int albumRating = 0;

            if (int.TryParse(updateAlbumTextBox.Text.Trim(), out albumRating) && albumRating >= 0 && albumRating <= 5)
            {
                repository.UpdateAlbumRating(AlbumTitle, albumRating, AlbumArtist);
                Close();
            }
            else
            {
                MessageBox.Show("Please enter a rating can only be between 1 and 5", "Input validation error");
                updateAlbumTextBox.Focus();
                DialogResult = DialogResult.None;
            }
        }
示例#5
0
 private void GetSongInformation(int songId)
 {
     var repository = new CDCatalogRepository();
     Song = repository.GetSongViewByID(songId);
 }