//метод за додавање на нова песна во базата 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); } }
/// <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); }
//избор на песна од листата 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 = ""; } }
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); } }
/// <summary> /// Deprecated Method for adding a new object to the songs EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTosongs(song song) { base.AddObject("songs", song); }
/// <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; }
//метод за додавање на нова песна во базата 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; } }