//Выбор плейлиста
        private void PlayListOpen_click(object sender, EventArgs e)
        {
            try
            {
                using (MusicPlayerEntities db = new MusicPlayerEntities())
                {
                    Vars.Files.Clear();
                    PlayList.Items.Clear();

                    int plid = 0;

                    var id = db.DBPlayList.Where(p => p.Name == PlayListList.SelectedItem.ToString());

                    foreach (var a in id)
                    {
                        plid = a.Id;
                    }

                    var bdfiles = db.DBFiles.Where(p => p.PLId == plid);

                    foreach (var file in bdfiles)
                    {
                        Vars.Files.Add(file.Path.ToString());
                        string insertsong = file.Path.ToString();
                        Song   InsertSong = new Song(insertsong);
                        PlayList.Items.Add(InsertSong);
                    }
                }
            }
            catch { }
        }
        //Удаление плейлиста
        private void PlayListDelete_click(object sender, EventArgs e)
        {
            try
            {
                using (MusicPlayerEntities db = new MusicPlayerEntities())
                {
                    //Поиск элемента с именем, как выбранное в списке
                    int plid = 0;
                    var id   = db.DBPlayList.Where(p => p.Name == PlayListList.SelectedItem.ToString());

                    //получение его id
                    foreach (var a in id)
                    {
                        plid = a.Id;
                    }

                    var count = db.DBFiles.Where(p => p.PLId == plid);

                    DBFiles dbfiles;

                    foreach (var f in count)
                    {
                        dbfiles = db.DBFiles.Where(p => p.PLId == plid).FirstOrDefault();
                        db.DBFiles.Remove(dbfiles);
                    }

                    DBPlayList dbpl = db.DBPlayList.Where(p => p.Name == PlayListList.SelectedItem.ToString()).FirstOrDefault();
                    db.DBPlayList.Remove(dbpl);

                    db.SaveChanges();

                    if (Vars.IsRus)
                    {
                        MessageBox.Show("Плейлист успешно удален");
                    }
                    else if (!Vars.IsRus)
                    {
                        MessageBox.Show("Playlist deleted successfully");
                    }
                }
            }
            catch { }
            GetPlaylists();
        }
        //Получение плейлистов
        private void GetPlaylists()
        {
            Vars.Playlists.Clear();
            PlayListList.Items.Clear();
            using (MusicPlayerEntities db = new MusicPlayerEntities())
            {
                DBPlayList dbplaylist = new DBPlayList();
                var        songs      = db.DBPlayList.Where(p => p.Name != null);

                foreach (var a in songs)
                {
                    Vars.Playlists.Add(a.Name);
                }
            }
            foreach (var a in Vars.Playlists)
            {
                PlayListList.Items.Add(a);
            }
        }
        //Сохранение плейлиста
        private void PlayListSave_click(object sender, EventArgs e)
        {
            using (MusicPlayerEntities db = new MusicPlayerEntities())
            {
                if (PlayListName.Text.Length <= 55 && PlayListName.Text.Length >= 1)
                {
                    int ii     = 0;
                    var isname = db.DBPlayList.Where(p => p.Name == PlayListName.Text);

                    foreach (var c in isname)
                    {
                        ii++;
                    }

                    if (ii != 0)
                    {
                        if (Vars.IsRus)
                        {
                            MessageBox.Show("Плейлист с таким именем уже есть");
                        }
                        else if (!Vars.IsRus)
                        {
                            MessageBox.Show("There is already a playlist with the same name");
                        }
                    }
                    else
                    {
                        DBPlayList dbplaylist = new DBPlayList();

                        dbplaylist.Name = PlayListName.Text;

                        db.DBPlayList.Add(dbplaylist);
                        db.SaveChanges();

                        int i = 0;
                        foreach (string files in Vars.Files)
                        {
                            DBFiles dbfiles = new DBFiles();
                            i++;
                            var peremennaya = db.DBPlayList.Where(p => p.Name == PlayListName.Text);
                            foreach (var a in peremennaya)
                            {
                                dbfiles.PLId = a.Id;
                            }
                            dbfiles.Path   = files;
                            dbfiles.Number = i;
                            db.DBFiles.Add(dbfiles);
                        }
                        db.SaveChanges();

                        if (Vars.IsRus)
                        {
                            MessageBox.Show("Плейлист успешно сохранен");
                        }
                        else if (!Vars.IsRus)
                        {
                            MessageBox.Show("Playlist saved successfully");
                        }
                    }
                }
                else
                {
                    if (Vars.IsRus)
                    {
                        MessageBox.Show("Название плейлиста должно быть от 1 до 55 символов");
                    }
                    else if (!Vars.IsRus)
                    {
                        MessageBox.Show("Playlist name must be between 1 and 55 characters");
                    }
                }
            }
            GetPlaylists();
        }