Пример #1
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (bookStock.Value == "")
        {
            lblStock.Text = "Value cannot be empty";
        }
        else
        {
            try
            {
                string title  = this.txtTitle.Text;
                string cat    = this.ddlistCat.SelectedValue.ToString();
                string isbn   = this.txtISBN.Text;
                string author = this.txtAuthor.Text;
                string stock  = this.bookStock.Value;
                string price  = this.txtPrice.Text;

                bbl = new BookBusinesslogic();

                bbl.UpdateBook(isbn, cat, title, author, price, stock);

                Response.Redirect("Main.aspx");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(Page.GetType(),
                                                   "MessageBox",
                                                   "<script language='javascript'>alert('" + ex.Message + "');</script>");
            }
        }
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string val = Request.QueryString["ISBN"];
            if (val != null)
            {
                bookItem = new Book();
                bbl      = new BookBusinesslogic();
                bl       = new BusinessLogic();

                bookItem = bbl.GetBookDetails(val);

                txtISBN.Text = val;

                Image2.Width    = 150;
                Image2.Height   = 150;
                Image2.ImageUrl = "images/" + val + ".jpg";

                List <string> cat = bl.GetCategoryList();
                for (int i = 0; i < cat.Count; i++)
                {
                    ddlistCat.Items.Add(cat[i]);
                }
                string catName = bbl.GetCategory(bookItem.CategoryID).CategoryName.ToString();
                ddlistCat.ClearSelection();
                ddlistCat.SelectedValue = catName;

                txtTitle.Text   = bookItem.Title;
                txtAuthor.Text  = bookItem.Author;
                txtPrice.Text   = bookItem.Price.ToString();
                bookStock.Value = bookItem.Stock.ToString();
            }
        }
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int key = Convert.ToInt32(Request.QueryString[0].ToString());

        bl = new BusinessLogic();
        bookBusinessLogic = new BookBusinesslogic();
        List <Book> lstBook;

        lstBook = bl.GetBooksByCategoryID(key);
        Category cat = bookBusinessLogic.GetCategory(key);

        Label1.Text = cat.CategoryName;
        try
        {
            if (Session["userType"] == null || Session["userType"].Equals("Customer"))
            {
                bl.imageAssignForCustomer(lstBook, PlaceHolder1);
            }
            else if (Session["userType"].Equals("Admin"))
            {
                bl.imageAssign(lstBook, PlaceHolder1);
            }
        }
        catch (Exception ex)
        {
            ClientScript.RegisterStartupScript(Page.GetType(),
                                               "MessageBox",
                                               "<script language='javascript'>alert('" + ex.Message + "');</script>");
        }
    }
Пример #4
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (bookStock.Value == "")
        {
            lblStock.Text = "Value cannot be empty";
        }
        else
        {
            if (FileUpload1.HasFile)
            {
                bbl = new BookBusinesslogic();

                string  title  = txtTitle.Text;
                string  cat    = ddlistCat.SelectedValue.ToString();
                string  isbn   = txtISBN.Text;
                string  author = txtAuthor.Text;
                int     stock  = Convert.ToInt32(bookStock.Value);
                decimal price  = Convert.ToDecimal(txtPrice.Text);

                try
                {
                    FileUpload1.SaveAs(Server.MapPath("~/images/") + isbn + ".jpg");
                }
                catch (Exception ex)
                {
                    ClientScript.RegisterStartupScript(Page.GetType(),
                                                       "MessageBox",
                                                       "<script language='javascript'>alert('" + ex.Message + "');</script>");
                }

                if (bbl.AddBook(title, cat, isbn, author, stock, price))
                {
                    ClientScript.RegisterStartupScript(Page.GetType(),
                                                       "MessageBox",
                                                       "<script language='javascript'>alert('Adding Book Successful!');</script>");
                    Response.Redirect("Main.aspx");
                }
                else
                {
                    ClientScript.RegisterStartupScript(Page.GetType(),
                                                       "MessageBox",
                                                       "<script language='javascript'>alert('Error!');</script>");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(),
                                                   "MessageBox",
                                                   "<script language='javascript'>alert('Please upload Image!');</script>");
            }
        }
    }
Пример #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string val = Request.QueryString["BookID"];

        if (val != null)
        {
            isbn     = val;
            bookItem = new BookBusinesslogic().GetBookDetails(isbn);
            Category cat = new BookBusinesslogic().GetCategory(bookItem.CategoryID);
            Image2.Width    = 280;
            Image2.Height   = 280;
            Image2.ImageUrl = "images/" + bookItem.ISBN + ".jpg";
            lblTitle.Text   = bookItem.Title;
            lblCat.Text     = Convert.ToString(cat.CategoryName);
            lblISBN.Text    = bookItem.ISBN;
            lblAuthor.Text  = bookItem.Author;
            lblPrice.Text   = Convert.ToString(bookItem.Price);
        }
    }