private void AddNewRequirementRecord() { RequirementModel reqModel; string tableName; string applyToName; reqModel = new RequirementModel(); tableName = comboCategory.SelectedItem.ToString(); applyToName = comboApplyTo.SelectedItem.ToString(); reqModel.TableNamesId = TableNamesModel.GetIdFromTableName(tableName); if (tableName == "Ability") { reqModel.ApplytoId = AbilityModel.GetIdFromName(applyToName); } else if (tableName == "Alignments") { reqModel.ApplytoId = AlignmentModel.GetIdFromName(applyToName); } else if (tableName == "Attribute") { reqModel.ApplytoId = AttributeModel.GetIdFromName(applyToName); } else if (tableName == "Class") { reqModel.ApplytoId = ClassModel.GetIdFromName(applyToName); } else if (tableName == "Enhancement") { reqModel.ApplytoId = GetEnhancementId(); } else if (tableName == "EnhancementSlot") { reqModel.ApplytoId = GetSlotId(); } else if (tableName == "Feat") { reqModel.ApplytoId = FeatModel.GetIdFromName(applyToName); } else if (tableName == "Race") { reqModel.ApplytoId = RaceModel.GetIdFromName(applyToName); } else if (tableName == "Skill") { reqModel.ApplytoId = SkillModel.GetIdFromName(applyToName); } else { Debug.WriteLine("Error: CategoryName isn't listed :: RequirementDialogClass: AddNewRequirement"); } reqModel.Save(); SelectedRequirementId = reqModel.Id; }
private Guid GetApplyToId() { Guid applyToId; string tableName; applyToId = Guid.Empty; tableName = comboCategory.SelectedItem.ToString(); if (tableName == "Ability") { applyToId = AbilityModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Alignments") { applyToId = AlignmentModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Attribute") { applyToId = AttributeModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Character") { applyToId = Guid.Empty; } if (tableName == "Class") { applyToId = ClassModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Enhancement") { applyToId = GetEnhancementId(); } if (tableName == "EnhancementSlot") { applyToId = GetSlotId(); } if (tableName == "Feat") { applyToId = FeatModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Race") { applyToId = RaceModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } if (tableName == "Skill") { applyToId = SkillModel.GetIdFromName(comboApplyTo.SelectedItem.ToString()); } return(applyToId); }
private void AddNewRequirementRecord() { RequirementModel model; string categoryName; string applyToName; string treeName; Guid treeId; Guid slotId; Guid enhancementId; treeName = ""; model = new RequirementModel(); categoryName = CategoryComboBox.SelectedItem.ToString(); applyToName = ApplyToComboBox.SelectedItem.ToString(); if (categoryName == "Enhancement" || categoryName == "EnhancementSlot") { treeName = TreeComboBox.SelectedItem.ToString(); } model.Initialize(Guid.Empty); model.TableNamesId = TableNamesModel.GetIdFromTableName(categoryName); if (categoryName == "Ability") { model.ApplytoId = AbilityModel.GetIdFromName(applyToName); } if (categoryName == "Attribute") { model.ApplytoId = AttributeModel.GetIdFromName(applyToName); } if (categoryName == "Class") { model.ApplytoId = ClassModel.GetIdFromName(applyToName); } if (categoryName == "Enhancement") { treeId = EnhancementTreeModel.GetIdFromTreeName(treeName); slotId = EnhancementSlotModel.GetIdFromTreeIdandSlotIndex(treeId, GetSlotIndex(SlotComboBox.SelectedItem.ToString())); enhancementId = EnhancementModel.GetIdFromSlotIdandDisplayOrder(slotId, GetDisplayOrder(ApplyToComboBox.SelectedItem.ToString())); model.ApplytoId = enhancementId; } if (categoryName == "EnhancementSlot") { treeId = EnhancementTreeModel.GetIdFromTreeName(treeName); slotId = EnhancementSlotModel.GetIdFromTreeIdandSlotIndex(treeId, GetSlotIndex(ApplyToComboBox.SelectedItem.ToString())); model.ApplytoId = slotId; } if (categoryName == "Feat") { model.ApplytoId = FeatModel.GetIdFromName(applyToName); } if (categoryName == "Race") { model.ApplytoId = RaceModel.GetIdFromName(applyToName); } if (categoryName == "Skill") { model.ApplytoId = SkillModel.GetIdFromName(applyToName); } model.Name = NameTextBox.Text; model.Save(); NewRequirementId = model.Id; }