Example #1
0
 private void finishButton_Click(object sender, EventArgs e)
 {
     foreach (Control control in borrowFlowLayout.Controls)
     {
         BorrowBookPanel bookPanel = (BorrowBookPanel)control;
         addTransaction(Member, bookPanel.Book);
     }
     ParentTransForm.closeThisTab();
 }
Example #2
0
 public void RemoveBookFromList(BorrowBookPanel bookPanel)
 {
     borrowFlowLayout.Controls.Remove(bookPanel);
 }
Example #3
0
        private void addBookButton_Click(object sender, EventArgs e)
        {
            #region Check for maximum
            if (borrowFlowLayout.Controls.Count > SettingsModel.MaxBookCount)
            {
                MessageBox.Show("Can't lend more books", "Maximum Reached");
                return;
            }
            #endregion

            string accessNo = addBookNoTextBox.Text;

            #region Check whether exists
            bool isExists = BookController.IsBookExists(accessNo);
            if (!isExists)
            {
                ValidationClass.ShowInvalidError(
                    highlighter,
                    addBookNoTextBox,
                    "There is not a Book with this Accession Number.",
                    "Invalid Accession No"
                    );
                return; //End Execution
            }
            #endregion

            #region Is Book Available (No member has borrowed)
            bool isAvailable = TransactionController.GetMember_NotReturned(accessNo) == null;

            if (!isAvailable)
            {
                ValidationClass.ShowInvalidError(
                    highlighter,
                    addBookNoTextBox,
                    "The Book has been borrowed by other Member.\n" +
                    "The Book is not available now.",
                    "Not Available"
                    );
                return; //End Execution
            }
            #endregion

            #region Check for Already Exists
            foreach (Control control in borrowFlowLayout.Controls)
            {
                BorrowBookPanel bookPanel = (BorrowBookPanel)control;
                if (bookPanel.Book.AccessNo == accessNo)
                {
                    ValidationClass.ShowInvalidError(
                        highlighter,
                        addBookNoTextBox,
                        "The Book has been already added.",
                        "Duplicating Book"
                        );
                    return;
                }
            }
            #endregion

            BookModel       book            = BookController.GetBook(accessNo);
            BorrowBookPanel borrowBookPanel = new BorrowBookPanel();
            borrowBookPanel.Book           = book;
            borrowBookPanel.ParentTabPanel = this;
            borrowFlowLayout.Controls.Add(borrowBookPanel);
            returnBorrowFlowLayout_Resize(borrowFlowLayout, null);

            addBookNoTextBox.Text = "";
            addBookNoTextBox.Select();
        }