private DataTable FindSpell(string search) { LocalSearch = true; DataTable result = new DataTable(); List <uint> listed = new List <uint>(); result.Columns.Add("ID", typeof(int)); result.Columns.Add("Name", typeof(string)); result.Columns.Add("Description", typeof(string)); // Get data DataTable dbc = DBCQuery.GetSpells(); // "m_ID", "m_name_lang_1", "m_description_lang_1" (DataTable sql, bool _) = LookupQuery.GetSpells(search); // Id, Comment(name) DataRow newRow = null; // Add DBC spells if (dbc.Rows.Count != 1 && dbc.Columns.Count != 1) // Invalid DBC config { foreach (DataRow dr in dbc.Rows) { if (dr["m_name_lang_1"].ToString().Contains(search)) { newRow = result.NewRow(); newRow["ID"] = dr["m_ID"]; newRow["Name"] = dr["m_name_lang_1"]; newRow["Description"] = dr["m_description_lang_1"]; result.Rows.Add(newRow); listed.Add((uint)dr["m_ID"]); } } } // Add unlisted SQL spells foreach (DataRow dr in sql.Rows) { if (!listed.Contains((uint)dr["Id"])) { newRow = result.NewRow(); newRow["ID"] = dr["Id"]; newRow["Name"] = dr["Comment"]; result.Rows.Add(newRow); } } FullDbcTable = result.Copy(); return(result); }
/// <summary> /// DBC definitions /// </summary> /// <param name="target"></param> private void HandleDbcQuery() { LocalSearch = true; DataTable result = null; switch (SelectedTarget) { case Target.QuestSort: result = DBCQuery.GetQuestSort(); break; case Target.Map: result = DBCQuery.GetMap(); break; case Target.Faction: result = DBCQuery.GetFaction(); break; case Target.Title: result = DBCQuery.GetCharTitles(); break; case Target.Emotes: result = DBCQuery.GetEmotes(); break; // SQL query will be handled in searchBtn_Click default: LocalSearch = false; break; } // Copy DataTable when DBC if (LocalSearch) { FullDbcTable = result.Copy(); SetGridSource(result); } }