Example #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            DialogResult r =
                MessageBox.Show("Confirm Return?", "Confirm", MessageBoxButtons.YesNo);

            short    s          = Convert.ToInt16(dgvTransaction.CurrentRow.Cells[0].Value.ToString());
            DateTime returndate = this.dateTimePicker1.Value.Date;

            if (r == DialogResult.Yes)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    it = context.IssueTrans.Where(x => x.TransactionID == s).First();
                    it.BorrowStatus     = "IN";
                    it.DateActualReturn = returndate;
                    context.SaveChanges();
                    ts.Complete();
                    UpdateStatusBarText("Return of book completed");
                }
                mtxtID_TextChanged(sender, e);
            }
            else if (r == DialogResult.No)
            {
                UpdateStatusBarText("Please select Transaction");
            }
        }
Example #2
0
        private void btnBorrow_Click(object sender, EventArgs e)
        {
            //if (b.TotalStock == b.NumberBorrowed)
            //{
            //    tssStatus.Text = "Out of Stock";
            //    return;
            //}
            DialogResult r = MessageBox.Show("Confirm Borrow?" + Environment.NewLine
                                             + "Member ID: " + m.MemberID + Environment.NewLine
                                             + "Member Name: " + m.MemberName + Environment.NewLine
                                             + "Book ID: " + b.BookID + Environment.NewLine
                                             + "Book Title: " + b.BookTitle + Environment.NewLine,
                                             "Borrow", MessageBoxButtons.YesNo);

            if (r == DialogResult.No)
            {
                return;
            }
            try
            {
                IssueTran trans = new IssueTran();
                using (TransactionScope ts = new TransactionScope())
                {
                    trans.BookID       = b.BookID;
                    trans.MemberID     = m.MemberID;
                    trans.DateIssue    = dtpIssueDate.Value.Date;
                    trans.DateDue      = DateTime.Parse(lblDueDate.Text);
                    trans.Remarks      = txtRemarks.Text;
                    b.NumberBorrowed  += 1;
                    trans.BorrowStatus = "OUT";
                    context.IssueTrans.Add(trans);
                    context.SaveChanges();
                    ts.Complete();
                }
                tssStatus.Text = "Borrow Successful!";
                DialogResult print = MessageBox.Show("Would you like to print borrow receipt?", "Print receipt",
                                                     MessageBoxButtons.YesNo);
                if (print == DialogResult.Yes)
                {
                    frmGenerateReport fReceipt = new frmGenerateReport(trans.TransactionID);
                    fReceipt.ShowDialog();
                }

                ClearEntries();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            if (txtBook.Text == "")
            {
                lblValid.Text = "Please enter Book ID";
                EnableButtons(false);
                return;
            }
            short id;
            int   testId;

            if (!short.TryParse(txtBook.Text, out id))
            {
                if (int.TryParse(txtBook.Text, out testId))
                {
                    lblValid.Text = "Book ID should be number less than 32768";
                }
                else
                {
                    lblValid.Text = "Book ID should only contain numbers";
                    EnableButtons(false);
                }
                return;
            }

            Book b = new Book();

            try
            {
                b = context.Books.Where(x => x.BookID == id).First();
            }
            catch (Exception ex)
            {
                lblValid.Text = "Invalid Book ID";
                EnableButtons(false);
                return;
            }

            txtBookType.Text     = b.BookType;
            txtBookTitle.Text    = b.BookTitle;
            txtPublisher.Text    = b.Publisher;
            txtTotalStock.Text   = b.TotalStock.ToString();
            txtNumberBorrow.Text = b.NumberBorrowed.ToString();
            txtAuthor.Text       = b.Author;

            if (b.TotalStock == b.NumberBorrowed && b.TotalStock != 0)
            {
                ShowAvailDate(true);
                IssueTran it = new IssueTran();
                it = context.IssueTrans.Where(x => x.BookID == id && x.BorrowStatus == "OUT")
                     .OrderBy(x => x.DateDue).First();
                DateTime due = Convert.ToDateTime(it.DateDue);
                txtAvailDate.Text = due.ToString("dd-MMM-yyyy");
            }
            else
            {
                ShowAvailDate(false);
            }

            lblValid.Text = "";
            EnableButtons(true);
        }