Ejemplo n.º 1
0
        /// <summary>
        /// Create a new lockbook object.
        /// </summary>
        /// <param name="bookid">Initial value of the bookid property.</param>
        /// <param name="username">Initial value of the username property.</param>
        public static lockbook Createlockbook(global::System.Int32 bookid, global::System.String username)
        {
            lockbook lockbook = new lockbook();

            lockbook.bookid   = bookid;
            lockbook.username = username;
            return(lockbook);
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the lockbooks EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTolockbooks(lockbook lockbook)
 {
     base.AddObject("lockbooks", lockbook);
 }