예제 #1
0
 private void bAdd_Click(object sender, EventArgs e)
 {
     if (tBName.Text != "" && nUDLength.Value > 0)
     {
         MusicDataEF.Songs song = new MusicDataEF.Songs();
         song.S_name   = tBName.Text;
         song.S_length = (int)nUDLength.Value;
         song.S_albId  = (int)cBAlbum.SelectedValue;
         ctx.Songs.Add(song);
         ctx.SaveChanges();
         foreach (var ganre in lBGanres.SelectedItems)
         {
             MusicDataEF.SongGanre con = new MusicDataEF.SongGanre();
             con.SG_ganreId = ((MusicDataEF.Ganres)ganre).G_id;
             con.SG_songId  = song.S_id;
             ctx.SongGanre.Add(con);
             ctx.SaveChanges();
         }
         Close();
     }
     else
     {
         MessageBox.Show("Wrong information");
     }
 }
예제 #2
0
 public EditSong(MusicDataEF.Songs song)
 {
     InitializeComponent();
     ctx       = new MusicDataEF.DBMusicEntities();
     this.song = song;
     this.Text = "Edit of song: " + song.S_name;
 }