Exemplo n.º 1
0
        // Details

        private void Details(object sender, EventArgs e)
        {
            if (!CheckForSelectedItem())
            {
                return;
            }

            Hide();
            switch (_option)
            {
            case 1:
                var authorDetails = new AuthorDetails(entitiesListBox.SelectedItem as Author);
                authorDetails.Closed += (s, args) => Show();
                authorDetails.ShowDialog();
                break;

            case 2:
                var publisherDetails = new PublisherDetails(entitiesListBox.SelectedItem as Publisher);
                publisherDetails.Closed += (s, args) => Show();
                publisherDetails.ShowDialog();
                break;

            case 3:
                var studentDetails = new StudentDetails(entitiesListBox.SelectedItem as Student);
                studentDetails.Closed += (s, args) => Show();
                studentDetails.ShowDialog();
                break;

            case 4:
                var bookDetails = new BookDetails(entitiesListBox.SelectedItem as Book);
                bookDetails.Closed += (s, args) => Show();
                bookDetails.ShowDialog();
                break;

            case 5:
                var loanDetails = new LoanDetails(entitiesListBox.SelectedItem as Loan);
                loanDetails.Closed += (s, args) => Show();
                loanDetails.ShowDialog();
                break;

            default:
                CommonErrorMessage();
                break;
            }

            RefreshRepositories();
        }
        public void SearchBook(string searchFor)
        {
            List <Book> searchResult = bookservice.SearchBooks(searchFor);

            if (searchResult.Count == 1)
            {
                BookDetails result = new BookDetails();
                result.SetFieldReadOnly();
                result.AddController(this);
                result.ShowBookDetails(searchResult.ElementAt(0));
                result.ShowDialog();
            }
            else
            {
                BookSearchResults result = new BookSearchResults();
                result.AddController(this);
                result.UpdateDataInLstBook(searchResult);
                result.ShowDialog();
            }
        }
 public void ShowDetailsBook(int id)
 {
     bookDetails.SetFieldReadOnly();
     bookDetails.ShowBookDetails(bookservice.GetBook(id));
     bookDetails.ShowDialog();
 }