private void removeSGButton_Click(object sender, EventArgs e) { using (var ctx = new Shadowrun3Context()) { DataGridViewRow sg = sgDGV.CurrentRow; string sgString = sg.Cells[0].Value.ToString(); EnemySkillGroup esg = ctx.EnemySkillGroups.FirstOrDefault(i => i.SkillGroup.SkillGroupId == sgString); ctx.EnemySkillGroups.Remove(esg); ctx.SaveChanges(); ResetForm(); } }
private void addSGButton_Click(object sender, EventArgs e) { string sgString = skillGroupCB.SelectedValue.ToString(); using (var ctx = new Shadowrun3Context()) { SkillGroup sg = ctx.SkillGroups.FirstOrDefault(i => i.SkillGroupId == sgString); EnemyType et = ctx.EnemyTypes.First(a => a.EnemyTypeId == nameTB.Text); int rank = (int)skillGroupRankNB.Value; EnemySkillGroup esg = new EnemySkillGroup(); esg.SkillGroup = sg; esg.EnemyType = et; esg.Rank = rank; ctx.EnemySkillGroups.Add(esg); ctx.SaveChanges(); ResetForm(); } }