protected void Page_Load(object sender, EventArgs e)
        {
            bm = new BusinessModel();

            if (Session["bookDetailId"] == null || Session["Role"] == null)
            {
                Response.Redirect("/404.aspx");
            }

            if (Session["Role"].ToString() != "Admin")
            {
                Response.Redirect("/404.aspx");
            }

            bookId = (int)Session["bookDetailId"];

            b = bm.getBook(bookId);

            lblTitle.Text    = b.Title.ToString();
            lblAuthor.Text   = b.Author.ToString();
            lblCategory.Text = bm.getCategory(b.CategoryID);
            lblIsbn.Text     = b.ISBN.ToString();
            if (!IsPostBack)
            {
                txtStock.Attributes.Add("placeholder", b.Stock.ToString());
                txtPrice.Attributes.Add("placeholder", String.Format("{0:0.00}", b.Price));
                txtDiscount.Attributes.Add("placeholder", b.Discount.ToString());
            }
            Image1.ImageUrl = "images/" + b.ISBN + ".jpg";

            lblInvalidDiscount.Text = "";
            lblInvalidPrice.Text    = "";
            lblInvalidStock.Text    = "";
        }
Example #2
0
        public void Update(Book b)
        {
            BusinessModel bm   = new BusinessModel();
            Book          book = bm.getBook(b.BookID);

            book.Stock    = b.Stock;
            book.Price    = b.Price;
            book.Discount = b.Discount;
            bm.updateBook(book);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bm = new BusinessModel();

            /*
             * if (Session["bookDetailId"] == null)
             * {
             *  Response.Redirect("/404.aspx");
             * }
             *
             *
             * bookId = (int)Session["bookDetailId"];
             */

            if (Request.QueryString["bookId"] == null)
            {
                bookId = 1;
            }
            else
            {
                bookId = int.Parse(Request.QueryString["bookId"]);
            }

            b = bm.getBook(bookId);

            if (b == null)
            {
                Response.Redirect("404.aspx");
            }

            lblTitle.Text    = b.Title.ToString();
            lblAuthor.Text   = b.Author.ToString();
            lblCategory.Text = bm.getCategory(b.CategoryID);
            lblIsbn.Text     = b.ISBN.ToString();
            lblStock.Text    = b.Stock.ToString();
            lblPrice.Text    = String.Format("{0:c}", b.Price);
            lblDiscount.Text = b.Discount != null?String.Format("{0:p}", b.Discount) : "No discount :(";

            Image1.ImageUrl = "images/" + b.ISBN + ".jpg";

            if (!IsPostBack)
            {
                refreshStock();
            }

            lblInvalid.Text    = "";
            lblSuccessful.Text = "";

            if (Session["Role"] != null)
            {
                btnEdit.Visible = Session["Role"].ToString() == "Admin"? true : false;
            }
        }
        protected void linkPrevious_Command(object sender, CommandEventArgs e)
        {
            //int prevBookID = (int)Session["bookDetailId"] - 1;
            int prevBookID = bookId - 1;

            while (true)
            {
                if (prevBookID < 1)
                {
                    return;
                }
                b = bm.getBook(prevBookID);
                if (b != null)
                {
                    break;
                }
                prevBookID--;
            }
            //Session["bookDetailId"] = prevBookID;
            Response.Redirect("/BookDetails.aspx?bookId=" + prevBookID);
        }
Example #5
0
 protected Book getBook(int bookId)
 {
     return(bm.getBook(bookId));//String.Format("{0:c}",bm.getOne(bookId).Price);
 }