Пример #1
0
        private void addSongAnotherButton_Click(object sender, EventArgs e)
        {
            // The user clicked on the AddSong Another Song button.
            this.DialogResult = DialogResult.Yes; // This passes Yes back

            string title = this.songNameTextBox.Text;
            int    artistId;

            int.TryParse(artistComboBox.SelectedValue.ToString(), out artistId);
            int albumId;

            int.TryParse(albumTitleComboBox.SelectedValue.ToString(), out albumId);
            int trackNumber;

            int.TryParse(songTrackNumberTextBox.Text, out trackNumber);
            int songRating = ratingComboBox.SelectedIndex; //the index corresponds to 0-5
            int trackLength;                               // seconds

            int.TryParse(songTrackLengthTextBox.Text, out trackLength);
            int genreId;

            int.TryParse(genreComboBox.SelectedValue.ToString(), out genreId);

            //todo: validation

            int    SongId = Song.AddSong(title, artistId, albumId, trackNumber, songRating, trackLength, genreId);
            string msg    = "SongID=" + SongId.ToString();

            MessageBox.Show(msg);
        }