コード例 #1
0
 //метод за додавање на нова песна во базата
 public bool AddSong(String _author, String _name, String _text, int _id_category)
 {
     // мора да се осигураме дека сеуште имаме пристап до базата
     // доколку не јавуваме соодветна порака
     try
     {
         song pesna = new song
         {
             id_song     = 1,
             author      = _author,
             name        = _name,
             text        = _text,
             id_category = _id_category
         };
         testcontext.songs.AddObject(pesna);
         testcontext.SaveChanges();
         if (currentCategory == _id_category)
         {
             UpdateSongs("", true);
         }
         else
         {
             UpdateSongs(); // ажурирање на листата на песни
         }
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.InnerException.ToString());
         MessageBox.Show("Настана проблем при додавање на песната.\nПроверете ја вашата интернет конекција.", "Грешка при внесување");
         return(false);
     }
 }
コード例 #2
0
        /// <summary>
        /// Create a new song object.
        /// </summary>
        /// <param name="id_song">Initial value of the id_song property.</param>
        /// <param name="author">Initial value of the author property.</param>
        /// <param name="name">Initial value of the name property.</param>
        /// <param name="text">Initial value of the text property.</param>
        /// <param name="id_category">Initial value of the id_category property.</param>
        public static song Createsong(global::System.Int32 id_song, global::System.String author, global::System.String name, global::System.String text, global::System.Int32 id_category)
        {
            song song = new song();

            song.id_song     = id_song;
            song.author      = author;
            song.name        = name;
            song.text        = text;
            song.id_category = id_category;
            return(song);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Aleksandra123/VP_Songbook
 //избор на песна од листата
 private void lbSongs_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lbSongs.SelectedIndex != -1)
     {
         song s = (song)lbSongs.SelectedItem;
         tbAutorName.Text = s.author + " - " + s.name;
         tbText.Text      = s.text;
     }
     else
     {
         tbAutorName.Text = "";
         tbText.Text      = "";
     }
 }
コード例 #4
0
        public bool RemoveSong()
        {
            song p      = lbRemoveSong.SelectedItem as song;
            int  songId = p.id_song;

            try
            {
                song pesna = testcontext.songs.First(i => i.id_song == songId);
                testcontext.songs.DeleteObject(pesna);
                testcontext.SaveChanges();
                UpdateSongs();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException.ToString());
                return(false);
            }
        }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the songs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTosongs(song song)
 {
     base.AddObject("songs", song);
 }
コード例 #6
0
 /// <summary>
 /// Create a new song object.
 /// </summary>
 /// <param name="id_song">Initial value of the id_song property.</param>
 /// <param name="author">Initial value of the author property.</param>
 /// <param name="name">Initial value of the name property.</param>
 /// <param name="text">Initial value of the text property.</param>
 /// <param name="id_category">Initial value of the id_category property.</param>
 public static song Createsong(global::System.Int32 id_song, global::System.String author, global::System.String name, global::System.String text, global::System.Int32 id_category)
 {
     song song = new song();
     song.id_song = id_song;
     song.author = author;
     song.name = name;
     song.text = text;
     song.id_category = id_category;
     return song;
 }
コード例 #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the songs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTosongs(song song)
 {
     base.AddObject("songs", song);
 }
コード例 #8
0
ファイル: Controller.cs プロジェクト: nikoloskimk/Chordbook
 //метод за додавање на нова песна во базата
 public bool AddSong(String _author, String _name, String _text, int _id_category)
 {
     // мора да се осигураме дека сеуште имаме пристап до базата
     // доколку не јавуваме соодветна порака
     try
     {
         song pesna = new song
         {
             id_song=1,
             author=_author,
             name=_name,
             text=_text,
             id_category=_id_category
         };
         testcontext.songs.AddObject(pesna);
         testcontext.SaveChanges();
         if (currentCategory == _id_category)
         {
             UpdateSongs("", true);
         }
         else
         {
             UpdateSongs(); // ажурирање на листата на песни
         }
         return true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Настана проблем при додавање на песната.\nПроверете ја вашата интернет конекција.","Грешка при внесување");
         MessageBox.Show(ex.InnerException.ToString());
         return false;
     }
 }