private void bAdd_Click(object sender, EventArgs e) { if (tBName.Text != "") { MusicDataEF.MusicPlayers mp = new MusicDataEF.MusicPlayers(); mp.MP_name = tBName.Text; ctx.MusicPlayers.Add(mp); ctx.SaveChanges(); foreach (var art in lBArtist.SelectedItems) { MusicDataEF.ArtistPlayer con = new MusicDataEF.ArtistPlayer(); //DataRowView drv = (DataRowView)lBArtist.Items[(int)id]; //artists.Add((int)drv["A_id"]); //MessageBox.Show(id.ToString() + " " + drv["A_id"].ToString()); con.AP_artId = ((MusicDataEF.Artists)art).A_id; con.Ap_playerId = mp.MP_id; ctx.ArtistPlayer.Add(con); ctx.SaveChanges(); } Close(); } else { MessageBox.Show("Wrong information"); } }
public EditPlayer(MusicDataEF.MusicPlayers mp) { InitializeComponent(); this.mp = mp; this.ctx = new MusicDataEF.DBMusicEntities(); this.Text = "Edit mode of plyer " + mp.MP_name; }