Exemplo n.º 1
0
        private void frmBorrow_Load(object sender, EventArgs e)
        {
            //Get Next Loan ID
            txtLoanID.Text = Loans.getNextLoanID().ToString("00000");

            //Calling method to set GridView Style
            setMemberListStyle();
            setBookListStyle();

            //Set Min Date for Due Date
            dtpDueDate.MinDate = DateTime.Today;
        }
Exemplo n.º 2
0
        } //End numberOfDays

        //Method to do updates
        private void updDetails()
        {
            //Update Book Status to Available
            Loans.updBookStatus(intBookID, 'A');

            //Update Number of Books Borrow (-1)
            Loans.updBooksBorrowDecrement(intMemID);

            //Display confirmation message
            MessageBox.Show("Book '" + txtBookTitle.Text + "' Returned Successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

            //Calling method to prompt user more books to be returned for same Member?
            returnMoreBooks();
        } //End Update
Exemplo n.º 3
0
        }     //End saveRentalItems();

        //Private Method to Register Loans
        private void registerLoan()
        {
            //Insert Items into Rental File
            //Instantiate Loan Object
            Loans aLoan = new Loans();

            aLoan.setLoanID(Convert.ToInt32(txtLoanID.Text));
            aLoan.setMemID(Convert.ToInt32(txtMemID.Text));
            aLoan.setBorrowDate(dtpCurrentDate.Text);
            aLoan.setReturnDate(dtpDueDate.Text);

            //Save Details
            aLoan.regLoan();
        } //End registerLoan();
Exemplo n.º 4
0
        }     //End click event

        //Private Method to Save Rental Items
        private void saveRentalItems()
        {
            //For item in lstCart from 0 to lstCart total items - 1
            for (int i = 0; i < lstCart.Items.Count; i++)
            {
                //Instantiate LoanItems Object
                LoanItems aLoanItem = new LoanItems();
                aLoanItem.setLoanID(Convert.ToInt32(txtLoanID.Text));
                aLoanItem.setBookID(Convert.ToInt32(lstCart.Items[i].ToString().Substring(0, 4)));

                //Save Rental Item Detials
                aLoanItem.regLoanItems();

                //Update book status in Book File
                Loans.updBookStatus(Convert.ToInt32(lstCart.Items[i].ToString().Substring(0, 4)), 'U');

                //Update No. Books Borrow of the member in Member File
                Loans.updBooksBorrowIncrement(aMember.getMemID());
            } //End For
        }     //End saveRentalItems();
Exemplo n.º 5
0
        } //End Cell Click Event

        private void grdLoanItemList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //Extract LoanID from column 0 of selected row
            //Extract BookID from column 1 of selected row
            intLoanID = Convert.ToInt32(grdLoanItemList.Rows[grdLoanItemList.CurrentCell.RowIndex].Cells[0].Value);
            intBookID = Convert.ToInt32(grdLoanItemList.Rows[grdLoanItemList.CurrentCell.RowIndex].Cells[1].Value);

            //Extract Book Title from column 3 of selected row
            //Variable to store Book Title
            String strTitle = Convert.ToString(grdLoanItemList.Rows[grdLoanItemList.CurrentCell.RowIndex].Cells[3].Value).Trim();

            //Instantiate Members object and retrieve member details from Member File
            Members aMember = new Members();

            aMember.getMember(intMemID);
            String strForename = aMember.getForename().Trim();
            String strSurname  = aMember.getSurname().Trim();

            //Instantiate Loans object to retrieve loan details
            Loans aLoan = new Loans();

            aLoan.getLoan(intLoanID);
            String strBorrowDate = aLoan.getBorrowDate();

            this.strReturnDate = aLoan.getReturnDate();

            //Variable to store Member Name
            String strMemName = strForename + " " + strSurname;

            //Set Text to TextBox
            txtLoanID.Text      = intLoanID.ToString("00000");
            txtMemName.Text     = strMemName;
            txtBookTitle.Text   = strTitle;
            dtpBorrowDate.Value = Convert.ToDateTime(strBorrowDate);
            dtpDueDate.Value    = Convert.ToDateTime(strReturnDate);

            //Set Book Loan to True
            grpLoanDetails.Visible = true;
        }
Exemplo n.º 6
0
        //Borrow Button Event
        private void btnBorrow_Click(object sender, EventArgs e)
        {
            //Initialize Variable to get Number of Books Borrowed
            int numBooks = Loans.getNumBooksBorrow(Convert.ToInt32(txtMemID.Text));

            //Validates Number of Books Borrowed (Not more than 3)
            if (!isValidBooksBorrowed(numBooks))
            {
                //Display appropriate error message
                //If numBooks == 0 but Librarian selected more than 3 books
                if (numBooks == 0)
                {
                    String strMessage = "Member '" + txtForename.Text + " " + txtSurname.Text + "' can only borrow 3 books";
                    MessageBox.Show(strMessage, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    //Hide grpBorrowDetails
                    grpBorrowDetails.Visible = false;

                    lstCart.Focus();

                    //Do nothing
                    return;
                }
                //If numBooks == 1 but Librarian selected more than 2 books
                else if (numBooks == 1)
                {
                    String strMessage = "Member '" + txtForename.Text + " " + txtSurname.Text + "' can only borrow 2 books";
                    MessageBox.Show(strMessage, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    //Hide grpBorrowDetails
                    grpBorrowDetails.Visible = false;

                    lstCart.Focus();

                    //Do nothing
                    return;
                }
                //If numBooks == 2 but Librarian selected more than 1 books
                else if (numBooks == 2)
                {
                    String strMessage = "Member '" + txtForename.Text + " " + txtSurname.Text + "' can only borrow 1 books";
                    MessageBox.Show(strMessage, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    //Hide grpBorrowDetails
                    grpBorrowDetails.Visible = false;

                    lstCart.Focus();

                    //Do nothing
                    return;
                }
                //Reset whole UI if numBooks >= 3
                else
                {
                    String strMessage = "Total books borrowed by Member '" + txtForename.Text + " " + txtSurname.Text + "' has exceeded 3 books";
                    MessageBox.Show(strMessage, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    //Calling resetMember() method to reset Member Details
                    resetMember();
                    txtSname.Focus();

                    //Calling resetBook() method to reset Book Details
                    resetBook();
                    grpBorrowDetails.Visible = false;

                    //Do nothing
                    return;
                }
            }
            else
            {
                //Calling method to save Loan Details in Rental File
                registerLoan();

                //Calling method to save rental items in Book Rental Items File
                saveRentalItems();

                //Display confirmation message
                MessageBox.Show("Loan " + txtLoanID.Text + " registered succesfully", "Registered", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //Reset UI
                //Reset Member Details
                resetMember();

                //Reset Book Details
                resetBook();

                //Reset Borrow Details
                grpBorrowDetails.Visible = false;
                txtSname.Focus();

                //Get next Loan ID
                txtLoanID.Text = Loans.getNextLoanID().ToString("00000");
            } //End if
        }     //End click event