示例#1
0
 public ActionResult Create(HttpPostedFileBase ProductImage, ProductTB NewProduct)
 {
     try
     {
         string _FileName = "";
         if (ProductImage.ContentLength > 0)
         {
             _FileName = Path.GetFileName(ProductImage.FileName);
             string path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName);
             ProductImage.SaveAs(path);
         }
         NewProduct.Image = _FileName;
         objdc.ProductTBs.InsertOnSubmit(NewProduct);
         objdc.SubmitChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#2
0
        public ActionResult AddCart(CartTB c, FormCollection fc)
        {
            int proid = Convert.ToInt32(fc["pid"]);

            c.ProductId = proid;
            c.UserId    = int.Parse(Session["userid"].ToString());
            c.Qty       = Convert.ToInt32(fc["txtqty"]);
            c.Price     = Convert.ToInt32(fc["Price"]);
            dc.CartTBs.InsertOnSubmit(c);
            dc.SubmitChanges();
            Response.Write("<script>alert(Successfully Product Add To Cart)</script>");
            return(RedirectToAction("index", "User"));
        }