Beispiel #1
0
        private void setBoxes()
        {
            allBooks = booksBase.getAllBooks();
            List <int> prices = new List <int>();

            nameBookList.Items.Add("Все");
            authorBookList.Items.Add("Все");
            genreBookList.Items.Add("Все");
            costBookLower.Items.Add("Любая");
            costBookUpper.Items.Add("Любая");

            BooksList.RowCount = allBooks.Count + 1;
            for (int i = 0; i < BooksList.RowCount - 1; i++)
            {
                BooksList[0, i].Value = allBooks[i].name;
                if (!nameBookList.Items.Contains(allBooks[i].name))
                {
                    nameBookList.Items.Add(allBooks[i].name);
                }

                BooksList[1, i].Value = allBooks[i].author;
                if (!authorBookList.Items.Contains(allBooks[i].author))
                {
                    authorBookList.Items.Add(allBooks[i].author);
                }

                BooksList[2, i].Value = allBooks[i].genre;
                if (!genreBookList.Items.Contains(allBooks[i].genre))
                {
                    genreBookList.Items.Add(allBooks[i].genre);
                }

                BooksList[3, i].Value = allBooks[i].cost;
                if (!prices.Contains(allBooks[i].cost))
                {
                    prices.Add(allBooks[i].cost);
                }
            }

            prices.Sort();
            foreach (var i in prices)
            {
                costBookLower.Items.Add(i.ToString());
                costBookUpper.Items.Add(i.ToString());
            }

            nameBookList.SelectedIndex   = 0;
            authorBookList.SelectedIndex = 0;
            genreBookList.SelectedIndex  = 0;
            costBookLower.SelectedIndex  = 0;
            costBookUpper.SelectedIndex  = 0;
        }