コード例 #1
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            if (TrackNameTxtBox.Text == string.Empty)
            {
                TrackNameTxtBox.BackColor = Color.IndianRed;
                return;
            }

            if (TrackAuthorTxtBox.Text == string.Empty)
            {
                TrackAuthorTxtBox.BackColor = Color.IndianRed;
                return;
            }

            if (GenreCmbBox.Text == string.Empty)
            {
                GenreCmbBox.BackColor = Color.IndianRed;
                return;
            }

            _musicTrack.TrackName   = TrackNameTxtBox.Text;
            _musicTrack.TrackAuthor = TrackAuthorTxtBox.Text;
            _musicTrack.GenreId     = GenresRepo.GetByName(GenreCmbBox.Text).GenreId;
            if (PlaylistCmbBox.Text != string.Empty)
            {
                var playlist = PlaylistsRepo.GetById((int)PlaylistCmbBox.SelectedValue);
                playlist.MusicTracks.Add(_musicTrack);
                PlaylistsRepo.AddOrUpdate(playlist);
            }

            MusicTracksRepo.AddOrUpdate(_musicTrack);

            Close();
        }
コード例 #2
0
 private void AddPlaylistBtn_Click(object sender, EventArgs e)
 {
     if (PlaylistNameTxtBox.Text != string.Empty)
     {
         _playlist.PlaylistName = PlaylistNameTxtBox.Text;
         PlaylistsRepo.AddOrUpdate(_playlist);
         DialogResult = DialogResult.OK;
         Close();
     }
     else
     {
         PlaylistNameTxtBox.BackColor = Color.IndianRed;
     }
 }