Example #1
0
        protected void Update_Click(object sender, EventArgs e)
        {
            String imgPath = "";

            if (FileUpload1.HasFile)
            {
                String FileExtension = Path.GetExtension(FileUpload1.PostedFile.FileName).Substring(1);

                String filePath = Request.PhysicalApplicationPath + "images";
                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }

                filePath += @"\menu" + menuID + "." + FileExtension;
                imgPath   = "./images/menu" + menuID + "." + FileExtension;

                FileUpload1.SaveAs(filePath);
            }
            else
            {
                imgPath = "./images/menu0.jpg";
            }

            String strCheckbox = "0";

            if (cbPromotion.Checked)
            {
                strCheckbox = "1";
            }

            db.UpdateMenu(menuID, tbMenuName.Text, Double.Parse(tbMenuPrice.Text), tbMenuDesc.Text, strCheckbox, Double.Parse(tbPromoPrice.Text), imgPath);
            db.closeConnection();
            Response.Redirect("Menu.aspx?shopID=" + shopID);
        }