예제 #1
0
        private bool validate()
        {
            Control[] controls = new Control[] {
                accTextBox, typeDoubleInput, autherTextBox,
                publisherTextBox, pubYearIntInput
            };
            string[] captions = new string[] {
                "Accession Number", "Type Number", "Auther of the Book",
                "Publisher of the Book", "Published Year"
            };

            //Accession No already exists.
            if (BookController.IsBookExists(accTextBox.Text))
            {
                ValidationClass.ShowInvalidError(highlighter, accTextBox, "The Accession No is already exists!", "Accession No");
                accTextBox.SelectAll();
                return(false);
            }

            //Test for Required Fields
            bool valid = ValidationClass.ValidateEmptyText(highlighter, controls, captions);

            if (!valid)
            {
                return(false);
            }

            return(true);
        }
예제 #2
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();
        }
예제 #3
0
        private void findButton_Click(object sender, EventArgs e)
        {
            string accessNo;
            string memberNo;

            //Get the member who doesn't return the book
            #region Get the member
            if (bookIDRadioButton.Checked)
            {
                accessNo = searchIDTextBox.Text;
                memberNo = TransactionController.GetMember_NotReturned(accessNo);
                if (memberNo == null)
                {
                    ValidationClass.ShowInvalidError(
                        highlighter,
                        searchIDTextBox,
                        "This Book is already available in the Library OR\nAccession Number is not valid!",
                        "Invalid Accession Number"
                        );

                    //No Execution further
                    return;
                }
            }
            else
            {
                memberNo = searchIDTextBox.Text;
                if (!MemberController.IsMemberExists(memberNo))
                {
                    ValidationClass.ShowInvalidError(
                        highlighter,
                        searchIDTextBox,
                        "Invalid Member Number",
                        "Member No"
                        );

                    //No Execution further
                    return;
                }
            }

            //Load Member
            MemberModel member = MemberController.GetMember(memberNo);

            //If the member is already opened by a tab in parent form
            SubItemsCollection openedTabs = ParentTransForm.GetOpenedTabs();//TODO : This in not good
            for (int i = 0; i < openedTabs.Count; i++)
            {
                if (openedTabs[i].Text == member.Name)
                {
                    MessageBox.Show("This Member has already opened in a Tab.");
                    return;
                }
            }

            Member = member;
            memberPanel.Visible = true;

            #endregion

            //Load Books
            #region Load Books
            List <TransactionModel> transList = TransactionController.GetTransactions(memberNo);
            int transCount = transList.Count;
            returnBooks = new ReturnBookPanel[transCount];
            returnFlowLayout.Controls.Clear();
            for (int i = 0; i < transCount; i++)
            {
                BookModel book = BookController.GetBook(transList[i].AccessNo);
                addReturnBooksToTheFlowLayout(ref returnBooks[i]);
                returnBooks[i].BookModel   = book;
                returnBooks[i].Transaction = transList[i];
            }
            isAllReturned();
            #endregion

            verifyNextButton.PerformClick();
        }