private Dictionary <string, MusicGroupsFolder.Song> LoadSongTable() // Nahrani tabulky Pisnicek do Dictionary { Dictionary <string, MusicGroupsFolder.Song> dictionary = new Dictionary <string, MusicGroupsFolder.Song>(); try { using (StreamReader reader = File.OpenText(_savingPath + "SongTable.csv")) { string line = null; while ((line = reader.ReadLine()) != null) { var data = line.Split(';'); if (data.Length == 6) { string name = data[1]; DateTime created = ConvertStringDateToDateTime(data[2]); string genre = data[3]; string length = data[4]; string writer = data[5]; MusicGroupsFolder.Song tmpGroup = new MusicGroupsFolder.Song(name, created, (TypeOfMusic)Enum.Parse(typeof(TypeOfMusic), genre), length, writer); dictionary.Add(data[0], tmpGroup); } } } } catch (Exception e) { ErrorString = e.Message; MessageBox.Show("Nepodařilo se nahrat tabulku pisniček!\n\n" + ErrorString); } return(dictionary); }
public System.Guid AddSong(MusicGroupsFolder.Song song) // Pridani pisnicky { Song tmpSong = new Song() { SongName = song.Name, SongGenre = song.Genre.ToString(), SongLength = song.Length, SongReleased = song.Released, SongWriter = song.Writer }; try { _database.Songs.InsertOnSubmit(tmpSong); _database.SubmitChanges(); } catch (Exception e) { ErrorString = e.Message; MessageBox.Show("Nepodařilo se přidat pisničku do databáze!\n\n" + ErrorString); } return(tmpSong.SongID); }