private void removeSButton_Click(object sender, EventArgs e) { using (var ctx = new Shadowrun3Context()) { DataGridViewRow s = sDGV.CurrentRow; string sString = s.Cells[0].Value.ToString(); EnemySkill es = ctx.EnemySkills.FirstOrDefault(i => i.Skill.SkillId == sString); ctx.EnemySkills.Remove(es); ctx.SaveChanges(); ResetForm(); } }
private void addSButton_Click(object sender, EventArgs e) { string sString = skillCB.SelectedValue.ToString(); using (var ctx = new Shadowrun3Context()) { Skill s = ctx.Skills.FirstOrDefault(i => i.SkillId == sString); EnemyType et = ctx.EnemyTypes.First(a => a.EnemyTypeId == nameTB.Text); int rank = (int)skillRankNB.Value; EnemySkill es = new EnemySkill(); es.Skill = s; es.EnemyType = et; es.EnemySkillRank = rank; ctx.EnemySkills.Add(es); ctx.SaveChanges(); ResetForm(); } }