//Update Picked Book data
        private void BooksDataGrid_SelectionChanged(object sender, RoutedEventArgs e)
        {
            //Update the book
            _selectedBook = BooksDataGrid.SelectedItem as Book;

            if (_selectedBook != null)
            {
                //Update the book's data
                BorrowDateTextBox.Text      = ArchiveDataProvider.GetSpecificBorrowDateTime(_selectedBook.Id, _borrower.Id).ToString();
                ReturnDateTextBox.Text      = _selectedBook.ReturnUntil.ToString();
                NumberOfExtendsTextBox.Text = _selectedBook.TimesExtended.ToString() + " alkalommal";
                switch (BookDataProvider.Returnable(_selectedBook, _borrower))
                {
                case ReturnStatus.INVALID:
                    ReturnableLabel.Content = "Hiba! Keressen fel egy könyvtárost!";
                    break;

                case ReturnStatus.RULEBREAK:
                    ReturnableLabel.Content = "A könyvet díjmegfizetés terheli.";
                    break;

                case ReturnStatus.RETURNABLE:
                    ReturnableLabel.Content = "A könyv visszaszolgáltatható.";
                    break;
                }
            }
        }
        private void UpdateMemberBookList()
        {
            _loanedBooks   = BookDataProvider.GetBooksOfMember(_currentMember.MemberId);
            _loanBookInfos = new List <LoanBookInfo>();

            foreach (var item in _loanedBooks)
            {
                LoanBookInfo lbinf = new LoanBookInfo();
                lbinf.LoanDate   = item.LoanDate;
                lbinf.ReturnDate = item.ReturnDate;
                Book book = BookDataProvider.GetBookByInvNum(item.LB_InventoryNumber);
                lbinf.Title       = book.Title;
                lbinf.ISBN        = book.ISBN;
                lbinf.Pages       = book.Pages;
                lbinf.Genre       = book.Genre;
                lbinf.Publisher   = book.Publisher;
                lbinf.ReleaseDate = book.ReleaseDate;
                Author author = BookDataProvider.GetBookAuthor(book.BookId);
                lbinf.Author = author;
                _loanBookInfos.Add(lbinf);
            }
            _loanBookInfos = _loanBookInfos.OrderBy(o => o.ReturnDate).ToList();


            BooksLoanedList.ItemsSource = _loanBookInfos;
        }
Exemple #3
0
 private void Add(object sender, RoutedEventArgs e)
 {
     try
     {
         if (AllFieldHasContent())
         {
             if (DateValidator.ValidateDate(StartOfBorrow.SelectedDate.Value, DateOfDeadline.SelectedDate.Value))
             {
                 var BookInstence   = BookToLend.SelectedItem as Book;
                 var ReaderInstence = Borrower.SelectedItem as Reader;
                 BookInstence.IsBorrowed = true;
                 BookDataProvider.Update(BookInstence);
                 _borrowedBook.BookNumber   = BookInstence.Id;
                 _borrowedBook.BookName     = BookInstence.BookTitle;
                 _borrowedBook.ReaderNumber = ReaderInstence.Id;
                 _borrowedBook.ReaderName   = $"{ReaderInstence.FirstName} {ReaderInstence.LastName}";
                 _borrowedBook.DateOfBorrow = StartOfBorrow.SelectedDate.Value;
                 _borrowedBook.Deadline     = DateOfDeadline.SelectedDate.Value;
                 BorrowedBookDataProvider.Create(_borrowedBook);
                 DialogResult = true;
                 Close();
             }
             else
             {
                 DeadlineError.Content      = "Nem jók a dátumok!";
                 DeadlineError.Visibility   = Visibility.Visible;
                 BorrowDateError.Content    = "Nem jók a dátumok!";
                 BorrowDateError.Visibility = Visibility.Visible;
             }
         }
     }catch (Exception ex)
     {
         log.Error(ex.Message);
     }
 }
        //Extend the borrowing time by a week
        private void ExtendButton_Click(object sender, RoutedEventArgs e)
        {
            switch (BookDataProvider.ExtendBorrow(_selectedBook, _borrower))
            {
            case 1:
                MessageBox.Show("Sikertelen meghosszabbítás hibás adatok miatt! Kérem keressen fel egy könyvtárost!",
                                "Hibás adatok!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                break;

            case 2:
                MessageBox.Show("Már nem hosszabbíthatja könyvkölcsönzését!\n" +
                                "Ez azért lehetséges, mert már elérte a maximális hosszabbítások számát, vagy mert késedelmi díj megfizetésére kötelezett. " +
                                "Kérem lépjen kapcsolatba egy könyvtárossal! ",
                                "Hosszabbítás nem lehetséges!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                break;

            case 3:
                MessageBox.Show("Csak a kölcsönzés lejárata előtti egy hétben hosszabbíthat!",
                                "Sikertelen hosszabbítás!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                break;

            default:
                MessageBox.Show("Sikeresen meghosszabbította a kölcsönzése időtartamát.",
                                "Sikeres hosszabbítás!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                break;
            }
        }
Exemple #5
0
        public BorrowEditor(BorrowedBook BB)
        {
            InitializeComponent();
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));

            Borrower.ItemsSource = ReaderDataProvider.GetAllAsList();
            List <Book> BookList = BookDataProvider.GetAllAsList() as List <Book>;

            BookToLend.ItemsSource = BookList.FindAll(x => x.IsBorrowed == false);

            if (!(BB == null))
            {
                _borrowedBook               = BB;
                CurrantBorrower.Content     = _borrowedBook.ReaderName;
                CurrantBorrower.Visibility  = Visibility.Visible;
                CurrantBook.Content         = _borrowedBook.BookName;
                CurrantBook.Visibility      = Visibility.Visible;
                StartOfBorrow.SelectedDate  = _borrowedBook.DateOfBorrow;
                DateOfDeadline.SelectedDate = _borrowedBook.Deadline;

                AddButton.Visibility = Visibility.Hidden;
            }
            else
            {
                _borrowedBook           = new BorrowedBook();
                DeleteButton.Visibility = Visibility.Hidden;
                SaveButton.Visibility   = Visibility.Hidden;
            }
        }
        public AvalibelBooks()
        {
            InitializeComponent();
            List <Book> ListOfAllBook = BookDataProvider.GetAllAsList() as List <Book>;

            BookList.ItemsSource = ListOfAllBook.FindAll(x => x.IsBorrowed == false);
        }
Exemple #7
0
        private void AddBookButton_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateBook())
            {
                _book             = new Book();
                _book.Title       = BookTitleTextBox.Text.Trim();
                _book.ISBN        = BookIsbnTextBox.Text.Trim();
                _book.ReleaseDate = PublishDatePicker.SelectedDate.Value;
                _book.Publisher   = PublisherTextBox.Text.Trim();
                _book.Pages       = int.Parse(PagesTextBox.Text);
                _book.Genre       = GenreTextBox.Text;

                BookDataProvider.CreateBook(_book);

                var newBookId = BookDataProvider.GetBookByIsbn(_book.ISBN);

                _bookAuthor             = new BookAuthor();
                _bookAuthor.BA_AuthorId = _author.AuthorId;
                _bookAuthor.BA_BookId   = newBookId;

                BookAuthorDataProvider.CreateBookAuthorLink(_bookAuthor);

                DialogResult = true;
                Close();
            }
        }
Exemple #8
0
        private void Save(object sender, RoutedEventArgs e)
        {
            var CurrantBook    = BookDataProvider.GetById(_borrowedBook.BookNumber);
            var BookInstence   = BookToLend.SelectedItem as Book;
            var ReaderInstence = Borrower.SelectedItem as Reader;

            if (ReaderInstence == null && BookInstence != null)
            {
                CurrantBook.IsBorrowed = false;
                BookDataProvider.Update(CurrantBook);
                _borrowedBook.BookNumber = BookInstence.Id;
                _borrowedBook.BookName   = BookInstence.BookTitle;
                var NewBook = BookToLend.SelectedItem as Book;
                NewBook.IsBorrowed = true;
                BookDataProvider.Update(NewBook);
                BorrowedBookDataProvider.Update(_borrowedBook);
                BookSaved.Visibility = Visibility.Visible;
            }
            else if (BookInstence == null && ReaderInstence != null)
            {
                _borrowedBook.ReaderNumber = ReaderInstence.Id;
                _borrowedBook.ReaderName   = $"{ReaderInstence.FirstName} {ReaderInstence.LastName}";
                BorrowedBookDataProvider.Update(_borrowedBook);
                BorrowerSave.Visibility = Visibility.Visible;
            }
            else if (ReaderInstence != null && BookInstence != null)
            {
                CurrantBook.IsBorrowed = false;
                BookDataProvider.Update(CurrantBook);
                _borrowedBook.BookNumber   = BookInstence.Id;
                _borrowedBook.BookName     = BookInstence.BookTitle;
                _borrowedBook.ReaderNumber = ReaderInstence.Id;
                _borrowedBook.ReaderName   = $"{ReaderInstence.FirstName} {ReaderInstence.LastName}";
                var NewBook = BookToLend.SelectedItem as Book;
                NewBook.IsBorrowed = true;
                BookDataProvider.Update(NewBook);
                BorrowedBookDataProvider.Update(_borrowedBook);
                BorrowerSave.Visibility = Visibility.Visible;
                BookSaved.Visibility    = Visibility.Visible;
            }
            if (DateValidator.ValidateDate(StartOfBorrow.SelectedDate.Value, DateOfDeadline.SelectedDate.Value))
            {
                _borrowedBook.DateOfBorrow = StartOfBorrow.SelectedDate.Value;
                _borrowedBook.Deadline     = DateOfDeadline.SelectedDate.Value;
                BorrowedBookDataProvider.Update(_borrowedBook);
                DialogResult = true;
                Close();
            }
            else
            {
                DeadlineError.Content      = "Nem jók a dátumok!";
                DeadlineError.Visibility   = Visibility.Visible;
                BorrowDateError.Content    = "Nem jók a dátumok!";
                BorrowDateError.Visibility = Visibility.Visible;
            }
        }
Exemple #9
0
        private void Delete(object sender, RoutedEventArgs e)
        {
            var CurrantBook = BookDataProvider.GetById(_borrowedBook.BookNumber);

            CurrantBook.IsBorrowed = false;
            BookDataProvider.Update(CurrantBook);
            BorrowedBookDataProvider.DeleteById(_borrowedBook.Id);
            DialogResult = true;
            Close();
        }
Exemple #10
0
        //Borrow a book to the picked person
        private void BorrowBookButton_Click(object sender, RoutedEventArgs e)
        {
            //Borrowable only if not null
            if (_selectedBook != null && _selectedPerson != null)
            {
                //Borrowable only if available
                if (_selectedBook.IsAvailable)
                {
                    BookDataProvider.BorrowBook(_selectedBook, _selectedPerson);
                    var updatedBook = LibraryDataProvider.GetSingleData <Book>(LibraryDataProvider.bookUrl, _selectedBook.Id);
                    MessageBox.Show("Az olvasó sikeresen kikölcsönözte a könyvet az alábbi időpontig: " + updatedBook.ReturnUntil.ToString() + "!",
                                    "Sikeres kölcsönzés!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);

                    //Archivate the borrowing data.
                    ArchiveData save = new ArchiveData
                    {
                        //Borrow time.
                        BorrowedAt = DateTime.Now,
                        //Borrowed book's data.
                        BookId = _selectedBook.Id,
                        Author = _selectedBook.Author,
                        Title  = _selectedBook.Title,
                        Code   = _selectedBook.Code,
                        //Borrower's data.
                        BorrowerId  = _selectedPerson.Id,
                        FirstName   = _selectedPerson.FirstName,
                        LastName    = _selectedPerson.LastName,
                        DateOfBirth = _selectedPerson.DateOfBirth
                    };
                    //Save the borrowing data.
                    LibraryDataProvider.CreateData <ArchiveData>(LibraryDataProvider.archiveUrl, save);

                    //Update the View.
                    UpdateBooks();
                }
                //Error if already borrowed
                else
                {
                    MessageBox.Show("A választott könyv jelenleg ki van kölcsönözve, legkésőbb az alábbi időpontig: " + _selectedBook.ReturnUntil.ToString() + "!",
                                    "Kölcsönzés sikertelen!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Kérem válassza ki, hogy melyik könyvet kölcsönzi ki melyik olvasó!",
                                "Könyv vagy olvasó nem található!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }
        }
Exemple #11
0
 private void LoadBookData()
 {
     try
     {
         BookList.ItemsSource = BookDataProvider.GetAllAsList();
     }
     catch (Exception ex)
     {
         log.Error(ex.Message);
     }
 }
        private void UpdateBook_Click(object sender, RoutedEventArgs e)
        {
            _currentbook.Title       = BookTitleTextBox.Text;
            _currentbook.ISBN        = BookIsbnTextBox.Text;
            _currentbook.Publisher   = PublisherTextBox.Text;
            _currentbook.ReleaseDate = PublishDatePicker.SelectedDate.Value;
            _currentbook.Genre       = GenreTextBox.Text;
            _currentbook.Pages       = int.Parse(PagesTextBox.Text);

            BookDataProvider.UpdateBook(_currentbook);
            MessageBox.Show("Book Updated");
        }
Exemple #13
0
 private void Add(object sender, RoutedEventArgs e)
 {
     try
     {
         _book.BookTitle = BookTitleTextBox.Text;
         BookDataProvider.Create(_book);
         DialogResult = true;
         Close();
     }
     catch (Exception ex)
     {
         log.Error(ex.Message);
     }
 }
Exemple #14
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            string title; string author; string isbn;

            if (string.IsNullOrEmpty(SearchByTitleTextBox.Text))
            {
                UpdateBooks();
            }

            if (!string.IsNullOrEmpty(SearchByTitleTextBox.Text))
            {
                title  = SearchByTitleTextBox.Text;
                _books = BookDataProvider.GetBooksByTitle(title);
                libraryBookList.ItemsSource = _books;
            }
        }
        //Update the book list
        private void UpdateBooks()
        {
            //Update the list
            _books = BookDataProvider.SearchBooksByBorrower(_borrower.Id);
            BooksDataGrid.ItemsSource = _books;

            //No chosen item
            BooksDataGrid.UnselectAll();
            _selectedBook = null;

            //Set all View to empty//Update the book's data
            BorrowDateTextBox.Text      = string.Empty;
            ReturnDateTextBox.Text      = string.Empty;
            NumberOfExtendsTextBox.Text = string.Empty;
            ReturnableLabel.Content     = string.Empty;
        }
Exemple #16
0
        //Return a book
        private void ReturnBookButton_Click(object sender, RoutedEventArgs e)
        {
            var status = BookDataProvider.ReturnBook(_selectedBook, _selectedPerson, false);

            switch (status)
            {
            //Show error message.
            case null: MessageBox.Show("Az alábbi könyvet nem szolgáltathatja vissza az olvasó, mivel nem ő bérelte ki!",
                                       "Rossz adatok!",
                                       MessageBoxButtons.OK,
                                       MessageBoxIcon.Error);
                break;

            case false:
                //Ask for permission.
                var result = MessageBox.Show("Az alábbi könyvet késedelmi, vagy más büntetési díj megfizetése terheli! " +
                                             "Amennyiben ezt már a felhasználó megtette, akkor az igen gomb megnyomásával végérvényesítheti a könyv visszaszolgáltatásának folyamatát." +
                                             "\n\nKifizette a felhasználó a díjat? ",
                                             "Büntetés kifizetése kötelező !",
                                             MessageBoxButtons.YesNo,
                                             MessageBoxIcon.Question);
                //Save if allowed
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    BookDataProvider.ReturnBook(_selectedBook, _selectedPerson, true);
                    goto default;
                }
                else
                {
                    break;
                }

            default:
                //Show success message.
                MessageBox.Show("A könyv sikeresen visszavéve!",
                                "Sikeres könyvleadás!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Asterisk);
                //Update the archivated borrowing data.
                ArchiveData save = ArchiveDataProvider.GetSpecificData(_selectedBook.Id, _selectedPerson.Id);
                save.ReturnedAt = DateTime.Now;
                LibraryDataProvider.UpdateData <ArchiveData>(LibraryDataProvider.archiveUrl, save, save.Id);
                //Update the view.
                UpdateBooks();
                break;
            }
        }
Exemple #17
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            string       title;
            IList <Book> booksbytitle = new List <Book>();


            if (string.IsNullOrEmpty(SearchByTitleTextBox.Text))
            {
                UpdateLibraryBookList();
            }

            if (!string.IsNullOrEmpty(SearchByTitleTextBox.Text))
            {
                title         = SearchByTitleTextBox.Text;
                _libraryBooks = BookDataProvider.GetBooksByTitle(title);
                LibraryBooksList.ItemsSource = _libraryBooks;
            }
        }
Exemple #18
0
 private void Delete(object sender, RoutedEventArgs e)
 {
     if (_book.IsBorrowed)
     {
         BookError.Content    = "A könyv nem törölhető mert ki van kölcsönözve!";
         BookError.Visibility = Visibility.Visible;
     }
     else
     {
         try
         {
             BookError.Visibility = Visibility.Collapsed;
             BookDataProvider.DeleteById(_book.Id);
             DialogResult = true;
             Close();
         }
         catch (Exception ex)
         {
             log.Error(ex.Message);
         }
     }
 }
Exemple #19
0
 private void Edit(object sender, RoutedEventArgs e)
 {
     if (_book.IsBorrowed)
     {
         BookError.Content    = "A könyv nem szerkeszthető mert ki van kölcsönözve!";
         BookError.Visibility = Visibility.Visible;
     }
     else
     {
         try
         {
             BookError.Visibility = Visibility.Collapsed;
             _book.BookTitle      = BookTitleTextBox.Text;
             BookDataProvider.Update(_book);
             DialogResult = true;
             Close();
         }
         catch (Exception ex)
         {
             log.Error(ex.Message);
         }
     }
 }
Exemple #20
0
 //Show only the books borrowed by user
 private void ShowBorrowedButton_Click(object sender, RoutedEventArgs e)
 {
     _books = BookDataProvider.SearchBooksByBorrower(_selectedPerson.Id);
     BooksDataGrid.ItemsSource = _books;
 }
Exemple #21
0
 private void UpdateLibraryBookList()
 {
     _libraryBooks = BookDataProvider.GetBooks();
     LibraryBooksList.ItemsSource = _libraryBooks;
 }
Exemple #22
0
 private void UpdateBooks()
 {
     _books = BookDataProvider.GetBooks();
     libraryBookList.ItemsSource = _books;
 }