public static string CreateSqlQuery(SpellScriptEntry spell, uint id)
        {
            var SQLtext         = "";
            var spellName       = "\"\"";
            var actionSpellList = spell.ActionSpellList.Length > 1 ? spell.ActionSpellList : "\"\"";

            if (spell.ActionSpellList.Length > 1)
            {
                actionSpellList = "\"" + spell.ActionSpellList + "\"";
            }

            uint triggered = Convert.ToUInt32(spell.Triggered);

            if (DBC.DBC.IsLoaded() && DBC.DBC.SpellName.ContainsKey((int)spell.SpellId))
            {
                spellName = "\"" + DBC.DBC.SpellName[(int)spell.SpellId].Name + "--" + hooksList[spell.Hook] + " - EFFECT_" + spell.EffectId.ToString() + "\"";
            }

            SQLtext += "(" + spell.SpellId + ", " + id.ToString() + ", " + spell.Hook + ", " + spell.EffectId + ", " + spell.Action + ", " + spell.ActionSpellId + ", " +
                       spell.ActionOriginalCaster + ", " + spell.ActionCaster + ", " + spell.ActionTarget + ", " + triggered + ", " + spell.CalculationType + ", " + spell.DataSource + ", " + actionSpellList + ", "
                       + spell.TargetSpellId + ", " + spell.TargetEffectId + ", " + spell.DataEffectId + ", " + spellName + ")";

            return(SQLtext);
        }
        public void AddScript()
        {
            switch (GetScriptType(mainForm.SpellAuraScriptType_ComboBox.SelectedIndex))
            {
            case ScriptTypes.SpellScript:
            {
                uint SpellId = uint.Parse(mainForm.SpellAuraScript_SpellID_TextBox.Text);

                if (!ValidateSpellId(SpellId))
                {
                    return;
                }

                uint Hook   = Convert.ToUInt32(mainForm.SpellAuraScript_Hooks_ComboBox.SelectedIndex);
                int  EffIdx = mainForm.SpellAuraScript_EffIndex_ComboBox.SelectedIndex;

                uint ActionSpellId = Convert.ToUInt32(mainForm.SpellAuraScripts_ActionSpellId_TextBox.Text.Length > 1 ? mainForm.SpellAuraScripts_ActionSpellId_TextBox.Text : "0");
                bool Triggered     = mainForm.SpellAuraScript_Triggered_ComboBox.SelectedIndex > 1;

                uint Action               = Convert.ToUInt32(mainForm.SpellAuraScript_ActionComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScript_ActionComboBox.SelectedIndex : 0);
                uint ActionCaster         = Convert.ToUInt32(mainForm.SpellAuraScripts_ActionCaster_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScripts_ActionCaster_ComboBox.SelectedIndex : 0);
                uint ActionTarget         = Convert.ToUInt32(mainForm.SpellAuraScripts_ActionTarget_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScripts_ActionTarget_ComboBox.SelectedIndex : 0);
                uint ActionOriginalCaster = Convert.ToUInt32(mainForm.SpellAuraScripts_ActionOrgCaster_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScripts_ActionOrgCaster_ComboBox.SelectedIndex : 0);

                uint   CalcType        = Convert.ToUInt32(mainForm.SpellAuraScript_CalcType_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScript_CalcType_ComboBox.SelectedIndex : 0);
                uint   Source          = Convert.ToUInt32(mainForm.SpellAuraScriptSources_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScriptSources_ComboBox.SelectedIndex : 0);
                string ActionSpellList = mainForm.SpellAuraScripts_ActionSpellList_TextBox.Text;

                uint TargetSpellId = Convert.ToUInt32(mainForm.SpellAuraScripts_TargetSpellId_TextBox.Text.Length > 1 ? mainForm.SpellAuraScripts_TargetSpellId_TextBox.Text : "0");
                int  DataEffIdx    = mainForm.SpellAuraScripts_DataEffIdx_ComboBox.SelectedIndex;
                int  TargetEffIdx  = mainForm.SpellAuraScripts_TargetEffIdx_ComboBox.SelectedIndex;

                SpellScriptEntry spell = new SpellScriptEntry(SpellId, Hook, EffIdx, Action, ActionSpellId, ActionCaster, ActionTarget, Triggered, ActionSpellList, ActionOriginalCaster,
                                                              Source, CalcType, TargetSpellId, TargetEffIdx, DataEffIdx);

                if (!spellScriptsEntries.ContainsKey(spell.SpellId))
                {
                    spellScriptsEntries.Add(spell.SpellId, new ArrayList());
                }

                spellScriptsEntries[spell.SpellId].Add(spell);
                MessageBox.Show("Information added correctly to SpellId");
                break;
            }

            case ScriptTypes.AuraScript:
            {
                uint SpellId = uint.Parse(mainForm.SpellAuraScript_SpellID_TextBox.Text);

                if (!ValidateSpellId(SpellId))
                {
                    return;
                }

                uint Hook   = Convert.ToUInt32(mainForm.SpellAuraScript_Hooks_ComboBox.SelectedIndex);
                int  EffIdx = mainForm.SpellAuraScript_EffIndex_ComboBox.SelectedIndex;

                uint ActionSpellId = Convert.ToUInt32(mainForm.SpellAuraScripts_ActionSpellId_TextBox.Text.Length > 1 ? mainForm.SpellAuraScripts_ActionSpellId_TextBox.Text : "0");
                bool Triggered     = mainForm.SpellAuraScript_Triggered_ComboBox.SelectedIndex > 1;

                uint Action               = Convert.ToUInt32(mainForm.SpellAuraScript_ActionComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScript_ActionComboBox.SelectedIndex : 0);
                uint ActionCaster         = Convert.ToUInt32(mainForm.SpellAuraScripts_ActionCaster_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScripts_ActionCaster_ComboBox.SelectedIndex : 0);
                uint ActionTarget         = Convert.ToUInt32(mainForm.SpellAuraScripts_ActionTarget_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScripts_ActionTarget_ComboBox.SelectedIndex : 0);
                uint ActionOriginalCaster = Convert.ToUInt32(mainForm.SpellAuraScripts_ActionOrgCaster_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScripts_ActionOrgCaster_ComboBox.SelectedIndex : 0);

                uint   CalcType        = Convert.ToUInt32(mainForm.SpellAuraScript_CalcType_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScript_CalcType_ComboBox.SelectedIndex : 0);
                uint   Source          = Convert.ToUInt32(mainForm.SpellAuraScriptSources_ComboBox.SelectedIndex != -1 ? mainForm.SpellAuraScriptSources_ComboBox.SelectedIndex : 0);
                string ActionSpellList = mainForm.SpellAuraScripts_ActionSpellList_TextBox.Text;

                uint TargetSpellId = Convert.ToUInt32(mainForm.SpellAuraScripts_TargetSpellId_TextBox.Text.Length > 1 ? mainForm.SpellAuraScripts_TargetSpellId_TextBox.Text : "0");
                int  DataEffIdx    = mainForm.SpellAuraScripts_DataEffIdx_ComboBox.SelectedIndex;
                int  TargetEffIdx  = mainForm.SpellAuraScripts_TargetEffIdx_ComboBox.SelectedIndex;

                AuraScriptEntry auraScript = new AuraScriptEntry(SpellId, Hook, EffIdx, Action, ActionSpellId, ActionCaster, ActionTarget, Triggered, ActionSpellList, ActionOriginalCaster,
                                                                 Source, CalcType, TargetSpellId, TargetEffIdx, DataEffIdx);

                if (!auraScriptsEntries.ContainsKey(auraScript.SpellId))
                {
                    auraScriptsEntries.Add(auraScript.SpellId, new ArrayList());
                }

                auraScriptsEntries[auraScript.SpellId].Add(auraScript);
                MessageBox.Show("Information added correctly to SpellId");
                break;
            }
            }
        }