예제 #1
0
        private void BShow_Click(object sender, EventArgs e)
        {
            manage = new TBook();
            bookList.Items.Clear();

            int typeSort = -1;

            if (radioName.Checked)
            {
                typeSort = 0;
            }
            else if (radioYear.Checked)
            {
                typeSort = 1;
            }
            else if (radioAuthor.Checked)
            {
                typeSort = 2;
            }

            List <string> books = manage.getBooks(typeSort);

            foreach (var book in books)
            {
                bookList.Items.Add(book);
            }
        }
예제 #2
0
        private void BAdd_Click(object sender, EventArgs e)
        {
            manage = new TBook();

            if (isEmpty())
            {
                Title  = bookName.Text;
                Author = bookAuthor.Text;
                Year   = int.Parse(bookYear.Text);

                if (!manage.isContains(Title))
                {
                    manage.addBooks(Title, Author, Year);

                    bookName.Text   = string.Empty;
                    bookAuthor.Text = string.Empty;
                    bookYear.Text   = string.Empty;
                }
                else
                {
                    MessageBox.Show("Данная книга уже есть в базе данных!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Одно из поле не заполнено!");
                return;
            }
        }