Exemple #1
0
        private void InitSearchExpansionList()
        {
            listBoxSearchExpansion.Items.Clear();
            listBoxSearchExpansion.Items.Add("(All)"); listBoxSearchExpansion.SelectedIndex = 0;
            Database      database   = DatabaseCreatorFactory.CreateDatabase();
            IDbConnection connection = database.CreateConnection();

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }

            IDbCommand cmd = database.CreateCommand();

            cmd.Connection  = connection;
            cmd.CommandText = "SELECT NAME FROM EXTENSION";

            if (comboBoxSearchFormat.SelectedIndex > 0)
            {
                TournamentFormat format = comboBoxSearchFormat.SelectedItem as TournamentFormat;

                if (format.Set.Count() > 0)
                {
                    string list = "";
                    foreach (string sel in format.Set)
                    {
                        if (sel.Contains("\""))
                        {
                            list += "'" + sel + "', ";
                        }
                        else
                        {
                            list += "\"" + sel + "\", ";
                        }
                    }
                    list = list.Remove(list.Length - 2, 2);

                    cmd.CommandText += " WHERE NAME IN (" + list + ")";
                }
            }

            cmd.CommandText += " ORDER BY NAME";

            IDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                listBoxSearchExpansion.Items.Add(reader.GetString(0));
            }
            reader.Close();
        }
Exemple #2
0
        private void InitSearch()
        {
            comboBoxSearchFormat.DataSource    = TournamentFormats.Instance.Formats;
            comboBoxSearchFormat.DisplayMember = "GroupName";

            textBoxSearchName.Text = "";
            comboBoxSearchU.Items.Clear();
            comboBoxSearchB.Items.Clear();
            comboBoxSearchW.Items.Clear();
            comboBoxSearchR.Items.Clear();
            comboBoxSearchG.Items.Clear();
            textBoxSearchText.Text   = "";
            textBoxSearchFlavor.Text = "";
            listBoxSearchExpansion.Items.Clear();
            listBoxSearchType.Items.Clear();

            string[] searchlist = new string[] { "May", "Must", "Must not" };
            comboBoxSearchU.Items.AddRange(searchlist); comboBoxSearchU.SelectedIndex = 0;
            comboBoxSearchB.Items.AddRange(searchlist); comboBoxSearchB.SelectedIndex = 0;
            comboBoxSearchW.Items.AddRange(searchlist); comboBoxSearchW.SelectedIndex = 0;
            comboBoxSearchR.Items.AddRange(searchlist); comboBoxSearchR.SelectedIndex = 0;
            comboBoxSearchG.Items.AddRange(searchlist); comboBoxSearchG.SelectedIndex = 0;

            InitSearchExpansionList();


            Database      database   = DatabaseCreatorFactory.CreateDatabase();
            IDbConnection connection = database.CreateConnection();

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            listBoxSearchType.Items.Add("(All)"); listBoxSearchType.SelectedIndex = 0;
            IDbCommand cmd = database.CreateCommand();

            cmd.Connection  = connection;
            cmd.CommandText = "SELECT distinct(TYPE) as TYPE FROM CARD ORDER BY TYPE";
            IDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                listBoxSearchType.Items.Add(reader.GetString(0));
            }
            reader.Close();
        }