예제 #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 редактироватьТрекToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var selectedRow = TracksGridView.SelectedRows[0];

            var musicTrackDto = (MusicTrackDto)selectedRow.DataBoundItem;

            var genre = GenresRepo.GetByName(musicTrackDto.GenreName);

            var musicTrack = new MusicTrack
            {
                TrackAuthor  = musicTrackDto.AuthorName,
                TrackName    = musicTrackDto.Name,
                TrackId      = musicTrackDto.Id,
                UploadUserId = _currentUser.UserId,
                GenreId      = genre.GenreId,
                Genres       = genre
            };

            new MusicTrackForm(musicTrack).Show(this);

            FillOrRefreshTracksGridView();
        }
예제 #3
0
        public MusicTrackForm(MusicTrack musicTrack)
        {
            InitializeComponent();

            _musicTrack = musicTrack;

            TrackNameTxtBox.TextChanged   += ResetBackground;
            TrackAuthorTxtBox.TextChanged += ResetBackground;
            GenreCmbBox.TextChanged       += ResetBackground;
            PlaylistCmbBox.TextChanged    += ResetBackground;

            TrackNameTxtBox.Text      = _musicTrack.TrackName;
            TrackAuthorTxtBox.Text    = _musicTrack.TrackAuthor;
            GenreCmbBox.DataSource    = GenresRepo.GetAll();
            PlaylistCmbBox.DataSource = PlaylistsRepo.GetAll(_musicTrack.UploadUserId);

            GenreCmbBox.DisplayMember = "GenreName";
            GenreCmbBox.ValueMember   = "GenreId";

            PlaylistCmbBox.DisplayMember = "PlaylistName";
            PlaylistCmbBox.ValueMember   = "PlaylistId";
        }