Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.hfbookid.Value = Request.QueryString["bookid"];
                libraryEntities db     = new libraryEntities();
                int             bookid = Convert.ToInt32(this.hfbookid.Value);
                book            book   = db.books.Where <book>(x => x.id == bookid).FirstOrDefault();
                this.lblbooktitle.Text = book.title;
                this.imgbook.ImageUrl  = book.cover_picture;

                borrowhistory objBorrowHistory = db.borrowhistories.OrderByDescending(u => u.id).FirstOrDefault(); // get the last borrower from history.
                if (objBorrowHistory != null && book.status == "checkout")
                {
                    this.txtCheckOutDate.Text = objBorrowHistory.checkout_date.ToShortDateString();
                    this.txtCheckInDate.Text  = objBorrowHistory.checkin_date.ToShortDateString();
                    this.txtReturnDate.Text   = DateTime.Now.ToShortDateString();
                    this.txtBorrower.Text     = objBorrowHistory.borrower;
                    this.txtMobile.Text       = objBorrowHistory.mobile;
                    int bDays = Rules.GetBusinessDays(objBorrowHistory.checkout_date, DateTime.Now);
                    if (bDays > 15)
                    {
                        this.lblMessage.Text = "Penalty of 5 Dhs will be charged for over days." + "\n" + "You need to pay: " + Math.Abs(bDays - 15) * 5 + " Dhs";
                    }
                }
                else
                {
                    this.lblMessage.Text    = "Book Information Not Found.";
                    this.btnCheckIn.Enabled = false;
                }
            }
        }
Пример #2
0
        public static void SendExcepToDB(Exception exdb)
        {
            libraryEntities db = new libraryEntities();

            exepurl = context.Current.Request.Url.ToString();
            db.ExceptionLoggingToDataBase(exdb.Message.ToString(), exdb.GetType().Name.ToString(), exepurl, exdb.StackTrace.ToString());
        }
Пример #3
0
        protected void btnCheckOut_Click(object sender, EventArgs e)
        {
            libraryEntities db = new libraryEntities();
            lockbook        objLockBook;
            int             bookid = Convert.ToInt32(this.hfbookid.Value);

            objLockBook = db.lockbooks.Where <lockbook>(x => x.bookid == bookid).FirstOrDefault();
            if (objLockBook == null)
            {
                objLockBook          = new lockbook();
                objLockBook.bookid   = bookid;
                objLockBook.username = User.Identity.Name;
                db.lockbooks.AddObject(objLockBook);
                db.SaveChanges();
            }
            else
            {
                lblMessage.Text = "Book not available";
                return;
            }

            book objBook = db.books.Where <book>(x => x.id == bookid).FirstOrDefault();

            if (objBook.status == "checkout")
            {
                lblMessage.Text = "Book not available";
            }
            else
            {
                borrowhistory bh = new borrowhistory();
                bh.bookid        = bookid;
                bh.borrower      = this.txtBorrower.Text;
                bh.checkin_date  = Rules.AddBusinessDays(DateTime.Now, 14);
                bh.checkout_date = DateTime.Now;
                bh.nationalid    = this.txtNationalID.Text;
                bh.mobile        = this.txtMobile.Text;
                db.borrowhistories.AddObject(bh);

                objBook.status  = "checkout";
                lblMessage.Text = "CheckOut Successfull";

                db.SaveChanges();
            }

            db.lockbooks.DeleteObject(objLockBook);
            db.SaveChanges();
        }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.hfbookid.Value = Request.QueryString["bookid"];
         libraryEntities db     = new libraryEntities();
         int             bookid = Convert.ToInt32(this.hfbookid.Value);
         book            book   = db.books.Where <book>(x => x.id == bookid).FirstOrDefault();
         this.lblbooktitle.Text = book.title;
         this.imgbook.ImageUrl  = book.cover_picture;
         if (book.status == "checkout")
         {
             lblIsBorrowed.Text  = "Book Already Borrowed";
             btnCheckOut.Enabled = false;
         }
         this.txtCheckOutDate.Text = DateTime.Now.ToShortDateString();
         this.txtReturnDate.Text   = Rules.AddBusinessDays(DateTime.Now, 15).ToShortDateString();
     }
 }
Пример #5
0
        protected void btnCheckIn_Click(object sender, EventArgs e)
        {
            libraryEntities db      = new libraryEntities();
            int             bookid  = Convert.ToInt32(this.hfbookid.Value);
            book            objBook = db.books.Where <book>(x => x.id == bookid).FirstOrDefault();

            if (objBook.status == "checkout")
            {
                objBook.status = "checkin";
                borrowhistory bh = new borrowhistory();
                bh = db.borrowhistories.OrderByDescending(u => u.id).FirstOrDefault(); // get the last borrower from history.
                bh.checkin_date_return = DateTime.Now;
                db.SaveChanges();
                lblMessage.Text = "CheckIn Successfull";
            }
            else
            {
                lblMessage.Text = "Book CheckIn Failed";
            }
        }
Пример #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.hfbookid.Value = Request.QueryString["bookid"];
         libraryEntities db     = new libraryEntities();
         int             bookid = Convert.ToInt32(this.hfbookid.Value);
         book            book   = db.books.Where <book>(x => x.id == bookid).FirstOrDefault();
         this.lblbooktitle.Text   = book.title;
         this.imgbook.ImageUrl    = book.cover_picture;
         this.lblISBN.Text        = book.isbn;
         this.lblPrice.Text       = book.price.ToString();
         this.lblPublishYear.Text = book.publish_year.ToString();
         this.lblStatus.Text      = book.status;
         if (book.status == "checkout")
         {
             lblIsBorrowed.Text = "Book Already Borrowed";
         }
     }
 }