protected void Upload_Click(object sender, EventArgs e)
        {
            string pName        = Name.Text;
            string pDescription = Description.Text;
            int    pPrice       = Int32.Parse(Price.Text);
            int    pQuantity    = Int32.Parse(Quantity.Text);
            string pImage       = Image.FileName.ToString();

            Image.SaveAs(Request.PhysicalApplicationPath + "./Images/" + Image.FileName.ToString());
            CakeBO cakeBO = new CakeBO()
            {
                Name        = pName,
                Description = pDescription,
                Price       = pPrice,
                Quantity    = pQuantity,
                Image       = pImage
            };
            CakeBL cakeBL = new CakeBL();

            if (!cakeBL.AddNewCake(cakeBO))
            {
                Response.Redirect("invalid.aspx");
            }
            else
            {
                Response.Redirect("add_product.aspx");
            }
        }
Exemplo n.º 2
0
        public bool AddCake(CakeBO cakeBO)
        {
            string        sql = "insert into cakes values(@Name,@Description,@Price,@Quantity,@Image)";
            SqlConnection cnn = new SqlConnection(strConnection);
            SqlCommand    cmd = new SqlCommand(sql, cnn);

            cmd.Parameters.AddWithValue("@Name", cakeBO.Name);
            cmd.Parameters.AddWithValue("@Description", cakeBO.Description);
            cmd.Parameters.AddWithValue("@Price", cakeBO.Price);
            cmd.Parameters.AddWithValue("@Quantity", cakeBO.Quantity);
            cmd.Parameters.AddWithValue("@Image", cakeBO.Image);
            try
            {
                if (cnn.State == ConnectionState.Closed)
                {
                    cnn.Open();
                }
                return(cmd.ExecuteNonQuery() > 0);
            }
            catch (SqlException e)
            {
                throw new Exception(e.Message);
            }
        }
Exemplo n.º 3
0
        public bool AddNewCake(CakeBO cakeBO)
        {
            CakeDA cakeDA = new CakeDA();

            return(cakeDA.AddCake(cakeBO));
        }