private void buttonSave_Click(object sender, EventArgs e) { if (Validate(textBoxSongTitle.Text) && Validate(comboBoxGenre.Text) && Validate(comboBoxAlbum.Text) && Validate(textBoxPath.Text)) { song.SongTitle = textBoxSongTitle.Text.Trim(); song.AlbumId = Convert.ToInt32(comboBoxAlbum.SelectedValue); song.GenreId = Convert.ToInt32(comboBoxGenre.SelectedValue); int tempNum; if (song.SongId == 0) { tempNum = MusicLibraryOperation.createOperation(TYPE.SONG).Add(song); } else { tempNum = MusicLibraryOperation.createOperation(TYPE.SONG).Update(song); } if (tempNum > 0) { Message.show("Submitted successfully.", MESSAGE_TYPE.SUCCESS); } else { Message.show("Submission Failed.", MESSAGE_TYPE.FAILURE); } Clear(); PopulateDataGridView(); } }
private void buttonDelete_Click(object sender, EventArgs e) { if (Message.show("Are you sure you want to delete?", MESSAGE_TYPE.ADVISORY) == DialogResult.Yes) { int tempNum = MusicLibraryOperation.createOperation(TYPE.SONG).Delete(song); if (tempNum > 0) { Message.show("Deleted successfully.", MESSAGE_TYPE.SUCCESS); } else { Message.show("Failed to delete.", MESSAGE_TYPE.FAILURE); } PopulateDataGridView(); Clear(); } }
private void dataGridViewSong_DoubleClick(object sender, EventArgs e) { if (dataGridViewSong.CurrentRow.Index != -1) { int tempNum = Convert.ToInt32(dataGridViewSong.CurrentRow.Cells["songIdDataGridViewTextBoxColumn"].Value); song = (Song)MusicLibraryOperation.createOperation(TYPE.SONG).Get(tempNum); if (song == null) { Message.show("Could not find this information.", MESSAGE_TYPE.FAILURE); return; } textBoxSongTitle.Text = song.SongTitle; comboBoxAlbum.SelectedValue = song.AlbumId; comboBoxGenre.SelectedValue = song.GenreId; textBoxPath.Text = song.Path; buttonSave.Text = "Update"; buttonDelete.Enabled = true; } }