Ejemplo n.º 1
0
        private void searchData(string keywords, string category, string expansion)
        {
            bool added = false;
            string SQL = "SELECT ID, Name, Category, Expansion FROM Models WHERE ";

            if (keywords != null)
            {
                //Special thingy for Keywords
                string[] newKeys = keywords.Split(Convert.ToChar(" "));
                SQL += " (";
                for (int i = 0; i < newKeys.Length; i++)
                {
                    if (i == 0) SQL += " Name LIKE '%" + newKeys[i] + "%'";
                    else SQL += " AND Name LIKE '%" + newKeys[i] + "%'";
                }
                SQL += ") ";

                added = true;
            }
            if (category != null)
            {
                if (added == true) SQL += " AND Category = '" + category + "' ";
                else
                {
                    added = true;
                    SQL += " Category = '" + category + "' ";
                }
            }
            if (expansion != null)
            {
                if (added == true) SQL += " AND Expansion = '" + expansion + "' ";
                else
                {
                    added = true;
                    SQL += " Expansion = '" + expansion + "' ";
                }
            }
            //MessageBox.Show(SQL);
            XmlDbConnection connect = null;
            try
            {
                connect = new XmlDbConnection(xmlfile);
                IDbDataAdapter adapter = new XmlDbDataAdapter(new XmlDbCommand(SQL, connect));
                itemModels.Tables["Models"].Clear();
                adapter.Fill(itemModels);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (connect != null) connect.Close();
            }
        }
Ejemplo n.º 2
0
        private void searchData(string keywords, string category, string expansion)
        {
            bool   added = false;
            string SQL   = "SELECT ID, Name, Category, Expansion FROM Models WHERE ";

            if (keywords != null)
            {
                //Special thingy for Keywords
                string[] newKeys = keywords.Split(Convert.ToChar(" "));
                SQL += " (";
                for (int i = 0; i < newKeys.Length; i++)
                {
                    if (i == 0)
                    {
                        SQL += " Name LIKE '%" + newKeys[i] + "%'";
                    }
                    else
                    {
                        SQL += " AND Name LIKE '%" + newKeys[i] + "%'";
                    }
                }
                SQL += ") ";

                added = true;
            }
            if (category != null)
            {
                if (added == true)
                {
                    SQL += " AND Category = '" + category + "' ";
                }
                else
                {
                    added = true;
                    SQL  += " Category = '" + category + "' ";
                }
            }
            if (expansion != null)
            {
                if (added == true)
                {
                    SQL += " AND Expansion = '" + expansion + "' ";
                }
                else
                {
                    added = true;
                    SQL  += " Expansion = '" + expansion + "' ";
                }
            }
            //MessageBox.Show(SQL);
            XmlDbConnection connect = null;

            try
            {
                connect = new XmlDbConnection(xmlfile);
                IDbDataAdapter adapter = new XmlDbDataAdapter(new XmlDbCommand(SQL, connect));
                itemModels.Tables["Models"].Clear();
                adapter.Fill(itemModels);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (connect != null)
                {
                    connect.Close();
                }
            }
        }