/// <summary>
        /// Save the data from the model into the database
        /// </summary>
        private void SaveScreen()
        {
            Guid spellId;

            SaveFeedbackLabel.Text = "Saving Record...";
            SaveFeedbackLabel.Refresh();

            Model.Save();
            //clear the detail model in the database to make sure we save the correct data
            spellId = SpellModel.GetIdFromName(Model.SpellName);
            SpellDetailsModel.DeleteBySpell(spellId);
            for (int i = 0; i < DetailModel.Count; i++)
            {
                //note: It is possible the detail models don't yet have the correct spell ID. Make sure they do before saving
                DetailModel[i].SpellId = spellId;
                DetailModel[i].Save();
            }
            DataHasChanged = false;

            //repopulate the spell list (in case any of the names have changed or new ones added)
            PopulateSpellListBox();

            //update the modification fields
            ModDateLabel.Text    = Model.LastUpdatedDate.ToString();
            ModVersionLabel.Text = Model.LastUpdatedVersion;

            SaveFeedbackLabel.Text = "Record Saved";

            DatabaseName = Model.SpellName;
        }
Пример #2
0
        private Guid GetApplyToId()
        {
            Guid   applyToId;
            string tableName;

            applyToId = Guid.Empty;
            tableName = comboCategory.SelectedItem.ToString();


            if (tableName == "Ability")
            {
                applyToId = AbilityModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Attribute")
            {
                applyToId = AttributeModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Feat")
            {
                applyToId = FeatModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Save")
            {
                applyToId = SaveModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Skill")
            {
                applyToId = SkillModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else if (tableName == "Spell")
            {
                applyToId = SpellModel.GetIdFromName(comboModifier.SelectedItem.ToString());
            }
            else
            {
                //We should never reach this, if so, we need to add a category of fix one.
                Debug.WriteLine("Error: no category exists for the selected. ModifierDialogClass::GetApplyToId()");
                return(applyToId);
            }

            return(applyToId);
        }