Beispiel #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        lblAuthor.Text    = lblDiscount.Text = lblTitle.Text = lblPrice.Text = lblISBN.Text =
            litAdded.Text = "";
        if (validateAddContents())
        {
            string  title        = txtTitle.Text;
            string  isbn         = txtISBN.Text;
            string  categoryName = ddlCat.SelectedValue;
            string  author       = txtAuthor.Text;
            int     stock        = int.Parse(ddlStock.SelectedValue.ToString());
            decimal price        = decimal.Parse(txtPrice.Text);
            decimal discount     = decimal.Parse(txtDiscount.Text);

            try
            {
                BusinessLogic.AddBook(title, isbn, categoryName, author, stock, price, discount);
                BindGrid();
                litAdded.Text = "Book has been added!";
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
        mp1.Show();
    }
Beispiel #2
0
    protected void Button1_Click1(object sender, EventArgs e)
    {
        BusinessLogic bl = new BusinessLogic();

        title      = BookTitle.Text;
        categoryID = Int32.Parse(DropDownList1.Text);
        ISBN       = ISBNS.Text;
        author     = Author.Text;
        stock      = Convert.ToInt32(Stock.Text);
        price      = Decimal.Parse(Price.Text);
        //Response.Redirect("Index.aspx");
        bl.AddBook(title, categoryID, ISBN, author, stock, price);
    }
        protected void Add_onClick(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                try
                {
                    string filename = FileUpload1.FileName;


                    FileUpload1.SaveAs(Server.MapPath(@"~/Image/") + filename);
                    StatusLabel.Text    = "Upload status: File uploaded!";
                    StatusLabel.Visible = true;
                }
                catch (Exception ex)
                {
                    StatusLabel.Text =
                        "Upload status: The file could not be uploaded." +
                        "The following error occurred: " + ex.Message;
                    StatusLabel.Visible = true;
                }
            }

            string title  = tbTitle.Text;
            string author = tbAuthor.Text;

            string  isbn         = tbISBN.Text;
            decimal price        = Convert.ToDecimal(tbPrice.Text);
            string  categoryName = ddlCategory.SelectedValue;
            int     stock        = Convert.ToInt32(tbQuantity.Text);

            Message.Visible = true;
            try
            {
                BusinessLogic.AddBook(title, categoryName, isbn, author, stock, price);
                Message.Text = "Added Successfully";
            }
            catch (Exception exp)
            {
                Message.Text = "Cannot Add Book";

                Response.Write(exp.ToString());
            }
        }