private void rwSubmitButton_Click(object sender, EventArgs e) { using (var ctx = new Shadowrun3Context()) { RangedWeapon rw = new RangedWeapon(); rw.RangedWeaponId = nameTB.Text; rw = SetVar(rw); Skill newSkill = ctx.Skills.FirstOrDefault(i => i.SkillId == skillString); rw.skill = newSkill; try { ctx.RangedWeapons.Add(rw); ctx.SaveChanges(); ResetForm(); } catch { MessageBox.Show("That weapon already exists"); } } }
private RangedWeapon SetVar(RangedWeapon rw) { rw.DamageAmount = (int)damAmtNB.Value; rw.TypeOfDamage = damTypeCB.Text; rw.ModeOfFire = modeOfFireCB.Text; rw.AmmoType = ammoTypeTB.Text; rw.AP = (int)apNB.Value; return(rw); }
private void remRangedButton_Click(object sender, EventArgs e) { string rwString = rwLB.SelectedItem.ToString(); using (var ctx = new Shadowrun3Context()) { RangedWeapon remRW = ctx.RangedWeapons.FirstOrDefault(i => i.RangedWeaponId == rwString); EnemyType updatedET = ctx.EnemyTypes.First(a => a.EnemyTypeId == nameTB.Text); updatedET.RangedWeapons.Remove(remRW); ctx.SaveChanges(); ResetForm(); } }
private void updateButton_Click(object sender, EventArgs e) { using (var ctx = new Shadowrun3Context()) { RangedWeapon rw = ctx.RangedWeapons.First(a => a.RangedWeaponId == nameTB.Text); rw = SetVar(rw); Skill newSkill = ctx.Skills.FirstOrDefault(i => i.SkillId == skillString); rw.skill = newSkill; ctx.SaveChanges(); ResetForm(); } }