Beispiel #1
0
 private void addTransactionDetails()
 {
     for (int i = 0; i < borrowedBookList.Count; i++)
     {
         BookTransDetail k = new BookTransDetail();
         k.TransactionID = B.transactionNo;
         k.BookID        = borrowedBookList[i];
         k.DateDue       = DateTime.Today.AddDays(21).Date;
         k.RentalStatus  = false;
         context.BookTransDetails.Add(k);
     }
 }
Beispiel #2
0
        private void updateTransactionDetailsAndFine()
        {
            BookTransDetail k = context.BookTransDetails.Where(x => x.BookID == returnBookID && !x.RentalStatus).First();

            k.RentalStatus = true;
            k.DateReturn   = DateTime.Today.Date;
            if (k.DateReturn > k.DateDue)
            {
                FineTran f = new FineTran();
                f.MemberID      = context.BookTransactions.Where(x => x.TransactionID == k.TransactionID).First().MemberID;
                f.TransactionID = k.TransactionID;
                f.FineAmount    = Convert.ToDecimal(((Convert.ToDateTime(k.DateReturn) - k.DateDue).TotalDays) * 0.30);
                f.FineStatus    = false;
            }
        }
Beispiel #3
0
        private void ExtendButton_Click(object sender, EventArgs e)
        {
            DateTime datedue = Convert.ToDateTime(dataGridView1.CurrentRow.Cells[3].Value.ToString());
            int      TrID    = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            int      BID     = Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value.ToString());

            context = new LibrarySevenAEntities();
            var             QBT = context.BookTransactions.Where(x => x.TransactionID == TrID);
            BookTransaction bk  = QBT.First();

            if (bk.OriginalDateDue == datedue)
            {
                var             QBTD = context.BookTransDetails.Where(x => x.TransactionID == TrID && x.BookID == BID);
                BookTransDetail btd  = QBTD.First();
                btd.DateDue = datedue.AddDays(21);
                context.SaveChanges();
                //refresh
                context = new LibrarySevenAEntities();
                List <BookTransaction> lbt = new List <BookTransaction>();
                lbt = context.BookTransactions.Where(x => x.MemberID == memberID).ToList();
                if (lbt.Count > 0)
                {
                    List <object> lbtd = new List <object>();

                    for (int i = 0; i < lbt.Count; i++)
                    {
                        int temp = Convert.ToInt32(lbt[i].TransactionID.ToString());
                        var q    = from x in context.BookTransDetails
                                   where x.TransactionID == temp && x.RentalStatus == false
                                   select new { x.TransactionID, x.BookID, x.book.BookTitle, x.DateDue };
                        if (q.ToList().Count > 0)
                        {
                            object bktd = q.ToList().First();
                            lbtd.Add(bktd);
                        }
                    }
                    dataGridView1.DataSource = lbtd;
                    this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                }
            }
            else
            {
                MessageBox.Show("Unable to extend, this book has previously been extended");
            }
        }