Beispiel #1
0
        public LibraryForm()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
            mainPanel.Dock = DockStyle.Fill;

            RepositoryFactory bookRepoFactory = new RepositoryFactory();
            _bookService = new BookService(bookRepoFactory);
            _bookService.Updated += showBookBtn_Click;

            RepositoryFactory authorRepoFactory = new RepositoryFactory();
            _authorService = new AuthorService(authorRepoFactory);
            _authorService.Updated += allAuthorsBtn_Click;

            RepositoryFactory memberRepoFactory = new RepositoryFactory();
            _memberService = new MemberService(memberRepoFactory);
            _memberService.Updated += allMemberBtn_Click;

            RepositoryFactory loanRepoFactory = new RepositoryFactory();
            _loanService = new LoanService(loanRepoFactory);
            _loanService.Updated += memberLoanBtn_Click;

            RepositoryFactory bookCopyRepoFactory = new RepositoryFactory();
            _bookCopyService = new BookCopyService(bookCopyRepoFactory);
            _bookCopyService.Updated += showBookBtn_Click;

            CreateLibrary();
        }
Beispiel #2
0
        public LibraryForm()
        {
            InitializeComponent();

            // Start on "Books" tab
            tbc_Main.SelectedIndex = 0;

            // Init services
            RepositoryFactory repoFactory = new RepositoryFactory();

            _bookCopyService = new BookCopyService(repoFactory);
            _bookService = new BookService(repoFactory);
            _authorService = new AuthorService(repoFactory);
            _memberService = new MemberService(repoFactory);
            _loanService = new LoanService(repoFactory);

            // Subscribe to events
            _bookService.Updated += _bookService_Updated;
            _bookCopyService.Updated += _bookService_Updated;
            _memberService.Updated += _memberService_Updated;
            _loanService.Updated += _bookService_Updated;
            _loanService.Updated += _memberService_Updated;
            _loanService.Updated += _loanService_Updated;

            // Fill the three main gridviews on startup
            UpdateMembers(_memberService.All());
            UpdateLoans(_loanService.Search(null, false));
            UpdateBooks(_bookService.All());
        }
Beispiel #3
0
        public NewLoanForm(BookService bookService, BookCopyService bookCopyService, MemberService memberService, LoanService loanService)
        {
            InitializeComponent();

            _bookService = bookService;
            _bookCopyService = bookCopyService;
            _memberService = memberService;
            _loanService = loanService;

            // Keep comboboxes updated
            _bookService.Updated += _bookService_Updated;
            _bookCopyService.Updated += _bookService_Updated;
            _memberService.Updated += _memberService_Updated;

            _bookService_Updated(this, new EventArgs());
            _memberService_Updated(this, new EventArgs());
        }
Beispiel #4
0
 public NewLoanForm(BookService bookService, BookCopyService bookCopyService, MemberService memberService, LoanService loanService, Member selectedMember)
     : this(bookService, bookCopyService, memberService, loanService)
 {
     SetSelectedMember(selectedMember);
 }
Beispiel #5
0
 /// <summary>
 /// Different ways to enter the NewLoanForm, either from the Member view, with the member as predetermined value or
 /// with the selected book and bookcopy as predetermined values, from the Books view.
 /// </summary>
 public NewLoanForm(BookService bookService, BookCopyService bookCopyService, MemberService memberService, LoanService loanService, BookCopy selectedBookCopy)
     : this(bookService, bookCopyService, memberService, loanService)
 {
     SetSelectedBookAndCopy(selectedBookCopy);
 }