示例#1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            double          dueAmount  = 0;
            int             rowIndex   = returnRequestGridView.CurrentCell.RowIndex;
            DataGridViewRow row        = returnRequestGridView.Rows[rowIndex];
            DateTime        returnDate = Convert.ToDateTime(row.Cells[3].Value);
            int             issueID    = Convert.ToInt32(row.Cells[0].Value);

            try
            {
                if (DateTime.Compare(DateTime.Today, returnDate) > 0)
                {
                    if (txtOverdueAmount.Text.Trim() == "")
                    {
                        MessageBox.Show("AMOUNT CANNOT BE EMPTY");
                    }
                    else
                    {
                        dueAmount = Convert.ToDouble(txtOverdueAmount.Text.Trim());

                        try
                        {
                            InsertQueries.InsertIntoOverdue(issueID, dueAmount, cmbPaidStatus.SelectedValue.ToString());
                            UpdateQueries.FinishReturnRequest(Convert.ToInt32(cmbReturnRequestID.SelectedValue.ToString()));
                            UpdateQueries.UpdateIssueReturnRequest(issueID);
                            UpdateQueries.IncreaseBookQuantity(SelectQueries.GetBookidFromIssueId(issueID));
                            MessageBox.Show("Return request successfully served");
                            ViewReturnRequests();
                        }
                        catch (Exception exc)
                        {
                            Console.WriteLine(exc);
                        }
                    }
                }
                else
                {
                    try
                    {
                        InsertQueries.InsertIntoReturn(issueID, DateTime.Now.Date.ToShortDateString());
                        UpdateQueries.FinishReturnRequest(Convert.ToInt32(cmbReturnRequestID.SelectedValue.ToString()));
                        UpdateQueries.UpdateIssueReturnRequest(issueID);
                        UpdateQueries.IncreaseBookQuantity(SelectQueries.GetBookidFromIssueId(issueID));
                        MessageBox.Show("Return request successfully served");
                        ViewReturnRequests();
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Due amount can only be in number");
                Console.WriteLine(ex);
            }
        }
示例#2
0
        private void Button6_Click(object sender, EventArgs e)
        {
            int    issueID = Convert.ToInt32(cmbIssueID_return.SelectedValue.ToString());
            string newDate = newReturnDate.Value.ToShortDateString();

            int bookID       = SelectQueries.GetBookidFromIssueId(issueID);
            int crntIssueReq = SelectQueries.GetBookCountInIssueRequests(bookID);

            //Book issue can be extended as no issue requests are there for that book
            if (crntIssueReq == 0)
            {
                UpdateQueries.UpdateReturnDate(issueID, newDate);
                string message = "Return Date successfully changed";
                MessageBox.Show(message, "DONE", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ViewToUpdateReturns();
            }
            else
            {
                string message = "Cannot change return date as there is a issue request for same book";
                MessageBox.Show(message, "PROBIHATED", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }