Ejemplo n.º 1
0
    protected void btnaddproduct_Click(object sender, EventArgs e)
    {
        p.procatname     = DropDownList1.Text;
        p.proproductname = txtproname.Text;
        p.unitcost       = txtproprice.Text;
        p.desc           = txtprodesc.Text;
        p.oprice         = txtOrigional.Text;
        p.proquantity    = dpquantity.Text;

        if (FileUpload1.HasFile)
        {
            //string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
            p.filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
            FileUpload1.SaveAs(Server.MapPath("Images/" + p.filename));

            bool b = bl.bll_insertproducts(p);

            if (b == true)

            {
                lblresult.Text = "Insert Successfully";
                Response.Redirect("Products.aspx");
            }
            else
            {
                lblresult.Text = "not Insert Successfully";
            }



            /* string query = "insert into Products(CategoryID,ProductName,ProductImage,UnitCost,Description,origionalPrice,productquantity) select CategoryID,'" + txtproname.Text + "','" + "Images/" + filename + "'," + txtproprice.Text + ",'" + txtprodesc.Text + "','"+txtOrigional.Text+"','"+dpquantity.Text+"' from Categories where CategoryName='" + DropDownList1.Text + "'";
             * bool b = obj.UDI(query);
             *
             * if (b)
             * {
             *    lblresult.Text = "Inserted";
             *
             *    Response.Redirect("Products.aspx");
             * }
             * else
             * {
             *
             *    lblresult.Text = "Not Inserted";
             * }*/
        }

        else
        {
            UploadStatusLabel.Text = "You did not specify a file to upload.";
        }
    }