private void updateDueDateInLendingList(Account account, ObservableCollection <BookToShow> renewBookList) { foreach (var book in renewBookList) { BookItem bookItem = dataLoadFromDB.findBookItemByID(int.Parse(book.Id)); if (bookItem.dueDate != null) { DateTime dateTime = (DateTime)bookItem.dueDate; bookItem.dueDate = dateTime.AddDays(10); } bookItem.lendingStatus = model.enums.LendingStatus.RENEWED; if (Db.getInstace().updateLendingRenew(CurrentMember.getInstance().GetAccount(), bookItem)) { if (dataLoadFromDB.updateBookItem(bookItem) != null) { returnUpdateBook(); returnUpdateMember(); } } else { MessageBox.Show("Unknow error"); } } }
private void removeBookToLendingList(Account account, ObservableCollection <BookToShow> CheckOutBookList) { foreach (var book in CheckOutBookList) { BookItem bookItem = book.toBookItem(); account.removeBookToLendingBookList(bookItem); if (bookItem.lendingStatus != model.enums.LendingStatus.RESV) { bookItem.lendingStatus = model.enums.LendingStatus.AVAI; } else { bookItem.lendingStatus = model.enums.LendingStatus.READY; } bookItem.bordate = null; bookItem.dueDate = null; if (dataLoadFromDB.updateBookItem(bookItem) != null) { returnUpdateBook(); returnUpdateMember(); } else { MessageBox.Show("Unknow error"); } } }
private void Confirm_Click(object sender, RoutedEventArgs e) { foreach (var bookItem in getListReservedItem()) { bookItem.lendingStatus = model.enums.LendingStatus.RESV; if (!isInLendingBookList(bookItem)) { if (account.addNewBookToReservedBookList(bookItem)) { dataLoadFromDB.updateBookItem(bookItem); } } } ClearInfo(); this.Close(); ToggleForm(); }
private void Button_Click(object sender, RoutedEventArgs e) { model.Account account = data.findMemberByID(int.Parse(ID.Content.ToString())); if (account != null) { foreach (var bookItem in account.getLendingBookItems()) { bookItem.lendingStatus = model.enums.LendingStatus.LOST; data.updateBookItem(bookItem); } while (account.getReservedBookItem().Count > 0) { account.removeBookToReserveBookList(account.getReservedBookItem()[0], "CANCELED"); } data.deleteMember(account); updateMember(); this.Close(); ToggleForm(); } }
private void addBookToLendingList(Account account, ObservableCollection <BookToShow> CheckOutBookList) { foreach (var book in CheckOutBookList) { BookItem bookItem = dataLoadFromDB.findBookItemByID(int.Parse(book.Id)); bookItem.lendingStatus = model.enums.LendingStatus.LOANED; bookItem.bordate = DateTime.Now; DateTime dateTime = (DateTime)bookItem.bordate; bookItem.dueDate = dateTime.AddDays(10); if (account.addNewBookToLendingList(bookItem) && account.removeBookToReserveBookList(bookItem, "COMPLETED")) { if (dataLoadFromDB.updateBookItem(bookItem) != null) { checkOutUpdateBook(); checkOutUpdateMember(); } else { MessageBox.Show("Unknow error"); } } } }