Пример #1
0
 public static int DeleteArtist(Artist a)
 {
     //ook albums and songs implementeren
     string sql = "DELETE FROM artist WHERE ID=@ID";
     DbParameter parID = Database.AddParameter(Database.DBNAME, "@ID", a.ID);
     return Database.ModifyData(Database.GetConnection(Database.DBNAME), sql, parID);
 }
Пример #2
0
        public static void ImportSingleMP3IntoDB(string path)
        {
            TagLib.File f = TagLib.File.Create(path);

            //checken of artist al in db zit, zoja artist ophalen; zo nee, nieuwe aanmaken
            Artist ar = null;
            if (!string.IsNullOrEmpty(f.Tag.FirstAlbumArtist))
                ar = ArtistDA.GetArtistByName(f.Tag.FirstAlbumArtist);
            else
            {
                ar = (f.Tag.Artists.Length > 0) ? (ArtistDA.GetArtistByName(f.Tag.Artists[0])):(null);
            }

            if (ar == null)
            {
                if (!string.IsNullOrEmpty(f.Tag.FirstAlbumArtist))
                    ar = new Artist(f.Tag.FirstAlbumArtist);
                else if (f.Tag.Artists.Length > 0)
                    ar = new Artist(f.Tag.Artists[0]);
                else
                    ar = new Artist("Andere");

                ar.ID = ArtistDA.InsertArtist(ar);
                Console.WriteLine("DB: created new Artist - " + ar.ArtistName);
            }

            //checken of de album al in db zit aan de hand van albumnaam en artist id, zoja, album ophalen. Zo nee, nieuwe aanmaken
            Album al =null;
            if (!string.IsNullOrEmpty(f.Tag.Album))
                al = AlbumDA.GetAlbumByArtistIDAndAlbumName(ar.ID, f.Tag.Album);
            if(al == null)
            {
                string albumname = (!String.IsNullOrEmpty(f.Tag.Album)) ? (f.Tag.Album) : ("Andere");
                al = new Album(albumname, ar.ID);
                al.ID = AlbumDA.InsertAlbum(al);
                Console.WriteLine("DB: created new Album - " + al.Name);
            }

            //checken of da et liedje al in de database zit adhb artist / album id en songname, anders in db steken
            Song s = SongDA.GetSongByArtistAlbumSong(ar.ID, al.ID, f.Tag.Title);
            if (s==null)
            {
                s = new Song();
                s.AlbumID = al.ID;
                s.ArtistID = ar.ID;
                s.SongName = f.Tag.Title;
                s.Track = (int)f.Tag.Track;

                ShellFile so = ShellFile.FromFilePath(path);
                double nanoseconds;
                double.TryParse(so.Properties.System.Media.Duration.Value.ToString(),
                out nanoseconds);
                s.SongLength = (int)Math.Round((nanoseconds / 10000000), 0);
                s.PlayedAmmount = 0;
                s.FilePath = path;
                int songID = SongDA.InsertSong(s);
                s.ID = songID;
                Console.WriteLine("DB: created new Song - " + s.SongName);
            }
        }
Пример #3
0
 public static int UpdateArtist(Artist a)
 {
     string sql = "UPDATE artist SET artist=@Artist, image=@Image where ID=@ID;";
     DbParameter parID = Database.AddParameter(Database.DBNAME, "@ID", a.ID);
     DbParameter parName = Database.AddParameter(Database.DBNAME, "@Artist", a.ArtistName);
     DbParameter parImage = Database.AddParameter(Database.DBNAME, "@Image", a.Image);
     return Database.ModifyData(Database.GetConnection(Database.DBNAME), sql, parID, parName, parImage);
 }
Пример #4
0
 public static ObservableCollection<Album> GetAlbumsByArtist(Artist ar)
 {
     ObservableCollection<Album> albums = new ObservableCollection<Album>();
     string sql = "SELECT * FROM album WHERE ArtistID = @ID;";
     DbParameter parID = Database.AddParameter(Database.DBNAME, "@ID", ar.ID);
     DbDataReader reader = Database.GetData(Database.GetConnection(Database.DBNAME), sql, parID);
     while (reader.Read())
     {
         albums.Add(Create(reader));
     }
     reader.Close();
     return albums;
 }
Пример #5
0
 public static int InsertArtist(Artist a)
 {
     string sql = "INSERT INTO artist(artist) VALUES(@Artist);";
     DbParameter parName = Database.AddParameter(Database.DBNAME, "@Artist", a.ArtistName);
     return Database.InsertData(Database.GetConnection(Database.DBNAME), sql, parName);
 }
Пример #6
0
 public MP3Tag(Artist ar, Album al, Song s)
 {
     this.Artist = ar;
     this.Album = al;
     this.Song = s;
 }
Пример #7
0
 private void ViewArtistDetailClicked(Artist ar)
 {
     Messenger.Default.Send(new NotificationMessage<Artist>(ar, MVVMMessages.Messages.ARTIST_VIEW));
 }
Пример #8
0
 private void PlayArtistClicked(Artist ar)
 {
     Messenger.Default.Send(new NotificationMessage<Artist>(ar, MVVMMessages.Messages.ARTIST_PLAY));
 }