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(); } } }
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(); } } }
private void findAlbumButton_Click(object sender, EventArgs e) { var formHelper = new FormHelper(); if (findAlbumRadioButtonByAlbumName.Checked && formHelper.TextBoxHasContents(findAlbumTxtBoxAlbumName)) { FoundAlbums = repository.SearchAlbumsByAlbumTitle(findAlbumTxtBoxAlbumName.Text); if (FoundAlbums.Count == 0) { MessageBox.Show("Unable to locate any matching albumns."); DialogResult = DialogResult.None; } else Close(); } else { FoundAlbums = repository.SearchAlbumsByArtistName(((Artist)findAlbumComboBoxArtist.SelectedItem).ArtistName); if (FoundAlbums.Count == 0) { MessageBox.Show("Unable to locate any matching albumns."); DialogResult = DialogResult.None; } else Close(); } //TODO: Move Close(); to here }
private void findGenreButton_Click(object sender, System.EventArgs e) { var formHelper = new FormHelper(); if (formHelper.TextBoxHasContents(FindGenreTextBox)) { FoundGenres = repository.SearchGenreByGenreName(FindGenreTextBox.Text); if (FoundGenres.Count > 0) { Close(); } else { MessageBox.Show("Unable to locate any matching genres."); DialogResult = DialogResult.None; } } else { MessageBox.Show("Please enter a genre.", "Data validation error"); DialogResult = DialogResult.None; } }