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    = "";
        }
        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;
            }
        }