Beispiel #1
0
        private void button_intoPlaylist_Click(object sender, EventArgs e)
        {
            List <User_Track> user_Tracks = new List <User_Track>();

            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                User_Track track = new User_Track();
                track.id       = Convert.ToInt32(row.Cells[0].Value.ToString());
                track.author   = Convert.ToInt32(row.Cells[1].Value.ToString());
                track.track_id = Convert.ToInt32(row.Cells[2].Value.ToString());
                track.artist   = row.Cells[3].Value.ToString();
                track.title    = row.Cells[4].Value.ToString();
                track.genre    = row.Cells[5].Value.ToString();
                track.mood     = row.Cells[6].Value.ToString();
                track.bitrate  = Convert.ToInt32(row.Cells[7].Value.ToString());
                track.source   = row.Cells[8].Value.ToString();
                track.path     = row.Cells[9].Value.ToString();
                track.duration = TimeSpan.Parse(row.Cells[10].Value.ToString());
                track.date_add = Convert.ToDateTime(row.Cells[11].Value.ToString());
                user_Tracks.Add(track);
            }
            Edit_MyPlaylist f = new Edit_MyPlaylist("Добавить", user_Tracks, -1, author, login, name, surname);

            f.ShowDialog();
        }
        private void button_Edit_Click(object sender, EventArgs e)
        {
            int CurrentRow = dataGridView1.SelectedCells[0].RowIndex;
            //    //получить значение id выбранной строки
            int valueId = Convert.ToInt32(dataGridView1[0, CurrentRow].Value);
            Intensiv2018Entities       context = new Intensiv2018Entities();
            List <User_Track_Playlist> user_Track_Playlists = context.User_Track_Playlist.Where(a => a.playlist_id == valueId).ToList();

            List <Track> tracks = new List <Track>();

            foreach (User_Track_Playlist temp in user_Track_Playlists)
            {
                tracks.Add(context.Tracks1.Where(a => a.id == temp.track_id).FirstOrDefault());
            }

            List <User_Track> list = new List <User_Track>();

            //List<User_Track_for_Playlist> list = new List<User_Track_for_Playlist>();
            foreach (Track track in tracks)
            {
                User_Track user = context.User_Track.Where(a => a.track_id == track.id).FirstOrDefault();

                //User_Track_for_Playlist _For_Playlist = new User_Track_for_Playlist();
                //_For_Playlist.artist = user.artist;
                //_For_Playlist.author = user.author;
                //_For_Playlist.bitrate = user.bitrate;
                //_For_Playlist.date_add = user.date_add;
                //_For_Playlist.duration = user.duration;
                //_For_Playlist.genre = user.genre;
                //_For_Playlist.id = user.id;
                //_For_Playlist.mood = user.mood;
                //_For_Playlist.path = user.path;
                //_For_Playlist.source = user.source;
                //_For_Playlist.title = user.title;
                //_For_Playlist.track_id = user.track_id;
                //_For_Playlist.user_track_playlist_id = 0;
                //list.Add(_For_Playlist);

                list.Add(context.User_Track.Where(a => a.track_id == track.id).FirstOrDefault());
            }

            Edit_MyPlaylist f = new Edit_MyPlaylist("Редактировать", list, valueId, author_id, login, name, surname);

            f.ShowDialog();
        }