Beispiel #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            //Approve
            if (cmbStatusID.SelectedIndex == 0)
            {
                int             rowIndex = issueRequestGridView.CurrentCell.RowIndex;
                DataGridViewRow row      = issueRequestGridView.Rows[rowIndex];
                int             memberID = Convert.ToInt32(row.Cells[1].Value);
                int             bookID   = Convert.ToInt32(row.Cells[3].Value);

                int totalCurrentIssues = SelectQueries.CountCurrentIssuedBooks(memberID);
                int allowedIssues      = SelectQueries.CountMemberIssueLimit(memberID);


                //MEMBER IS IN HIS ISSUE LIMIT

                if (totalCurrentIssues < allowedIssues)
                {
                    int bookIssueCount = SelectQueries.BookIssuedCount(memberID, bookID, "YES");
                    int bookIssueLimit = SelectQueries.BookReissueLimitCount(bookID, memberID);

                    //member is in limit of reissuing current book
                    if (bookIssueCount < bookIssueLimit)
                    {
                        string issueDate  = DateTime.Now.Date.ToShortDateString();
                        string returnDate = issueReturnDate.Value.ToShortDateString();
                        if (SelectQueries.GetCopiesAvailable(bookID) > 0)
                        {
                            InsertQueries.IssueBook(bookID, memberID, issueDate, returnDate, "NO");
                            UpdateQueries.DecreaseBookQuantitiy(bookID);
                            UpdateQueries.FinishIssueRequest("APPROVED", Convert.ToInt32(cmbIssueRequestID.SelectedValue.ToString()));
                            MessageBox.Show("BOOK ISSUED SUCCESSFULLY", "RESULT", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ViewIssueRequests();
                        }
                        else
                        {
                            MessageBox.Show("NO COPIES AVAILABLE IN THE LIBRARY \n " +
                                            "PLEASE WAIT TILL COPIES BECOME AVAILABLE", "REJECTED", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                    }
                    else
                    {
                        MessageBox.Show("REISSUE LIMIT OF THIS PARTICULAR BOOK REACHED \n " +
                                        "CAN NO MORE ISSUE THIS SAME BOOK", "REJECTED", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
                else
                {
                    MessageBox.Show("ISSUE LIMIT OF MEMBER REACHED \n " +
                                    "CAN NO MORE ISSUE ANY BOOK", "REJECTED", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            //DECLINED
            if (cmbStatusID.SelectedIndex == 1)
            {
                UpdateQueries.FinishIssueRequest("DECLINED", Convert.ToInt32(cmbIssueRequestID.SelectedValue.ToString()));
                ViewIssueRequests();
                MessageBox.Show("ISSUE REQUEST DECLINED\n ", "DECLINED", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }