예제 #1
0
 public void SaveExecute()
 {
     if (String.IsNullOrEmpty(Song.Name) || String.IsNullOrEmpty(Song.Author) || String.IsNullOrEmpty(Song.Duration.ToString()) ||
         Song.Duration.ToString() == "00:00:00")
     {
         MessageBox.Show("Please fill all fields.", "Notification");
     }
     else
     {
         try
         {
             MessageBoxResult result = MessageBox.Show("Are you sure you want to save the song?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
             if (result == MessageBoxResult.Yes)
             {
                 bool isCreated = songs.CreateSong(User, Song);
                 if (isCreated == true)
                 {
                     MessageBox.Show("Song is created.", "Notification", MessageBoxButton.OK);
                     songView.Close();
                 }
                 else
                 {
                     MessageBox.Show("Song cannot be created.", "Notification", MessageBoxButton.OK);
                     songView.Close();
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
예제 #2
0
        private void SaveExecute()
        {
            try
            {
                using (AudioPlayerDbEntities db = new AudioPlayerDbEntities())
                {
                    db.tblSongs.Add(Song);
                    db.SaveChanges();
                }

                MessageBox.Show("Song Added Successfully!");
                main.Close();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }