示例#1
0
        private void BtnEditIssuedBook_Click(object sender, EventArgs e)
        {
            var issuedBook = issuedBooksBindingSource.Current as IssuedBook;

            if (issuedBook == null)
            {
                return;
            }

            var reader = readersRepository.FindById(issuedBook.IdReader);
            var book   = booksRepository.FindById(issuedBook.IdBook);

            using (var form = new AddEditIssuedBookForm(issuedBook, book,
                                                        reader, issuedBooksRepository))
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    issuedBooksBindingSource.ResetCurrentItem();
                    bookBindingSource.DataSource = booksRepository.GetAll();
                }
            }
        }
示例#2
0
        private void BtnAddIssuedBook_Click(object sender, EventArgs e)
        {
            if (bookBindingSource.Current == null || readerBindingSource.Current == null)
            {
                return;
            }

            if (((Book)bookBindingSource.Current).Count <= 0)
            {
                MessageBox.Show("Вы не можете выдать эту книгу. Количество книг равно нулю.", "Сообщение",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            using (var form = new AddEditIssuedBookForm(null, (Book)bookBindingSource.Current,
                                                        (Reader)readerBindingSource.Current, issuedBooksRepository))
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    issuedBooksBindingSource.DataSource = ((ICanGetAll <IssuedBookView>)issuedBooksRepository).GetAll();
                    bookBindingSource.DataSource        = booksRepository.GetAll();
                }
            }
        }