Example #1
0
 public ActionResult DeleteConfirmed(int id)
 {
     productdetail productdetail = db.productdetails.Find(id);
     db.productdetails.Remove(productdetail);
     db.SaveChanges();
     return RedirectToAction("Index");
 }
Example #2
0
        public ActionResult deleteproductdetail(int productid)
        {
            productdetail p = (from p1 in db.productdetails
                               where p1.productid == productid
                               select p1).Single();

            db.productdetails.Remove(p);
            db.SaveChanges();
            return(RedirectToAction("products"));
        }
        public ProductDetail(productdetail productdetail)
        {
            this.id     = productdetail.id;
            this.spec   = new Spec(productdetail.spec);
            this.color  = new Color(productdetail.color);
            this.price  = productdetail.price;
            this.imgUrl = productdetail.imgUrl;

            this.product = productdetail.product;
            this.hasSale = true;
        }
Example #4
0
 public ActionResult Edit([Bind(Include = "p_id,p_name,p_price,p_qty,p_detail,cat_id")] productdetail productdetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productdetail).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.cat_id = new SelectList(db.categories, "cat_id", "cat_name", productdetail.cat_id);
     return View(productdetail);
 }
Example #5
0
 // GET: product/Delete/5
 public ActionResult Delete(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     productdetail productdetail = db.productdetails.Find(id);
     if (productdetail == null)
     {
         return HttpNotFound();
     }
     return View(productdetail);
 }
Example #6
0
 // GET: product/Edit/5
 public ActionResult Edit(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     productdetail productdetail = db.productdetails.Find(id);
     if (productdetail == null)
     {
         return HttpNotFound();
     }
     ViewBag.cat_id = new SelectList(db.categories, "cat_id", "cat_name", productdetail.cat_id);
     return View(productdetail);
 }
        public ActionResult Saveproductdetails(int productstockid, int productcode, int price, DateTime manufacturing_date)
        {
            productdetail d = new productdetail();

            d.productcode        = productcode;
            d.price              = price;
            d.manufacturing_date = manufacturing_date;
            d.product_stock_id   = productstockid;

            db.productdetails.Add(d);
            db.SaveChanges();

            return(RedirectToAction("showproductdetails"));
        }
Example #8
0
 public ActionResult editproductaction(int productid, int productcode, int price, DateTime manufacturing_date)
 {
     try
     {
         productdetail p = (from p1 in db.productdetails where p1.productid == productid select p1).Single();
         p.productcode        = productcode;
         p.price              = price;
         p.manufacturing_date = manufacturing_date;
         db.SaveChanges();
         ViewData["message"] = "Succesfully updated";
     }
     catch (Exception ex)
     {
         ViewData["message"] = ex.Message;
     }
     return(RedirectToAction("products"));
 }
Example #9
0
 public ActionResult Saveproduct(int productcode, int price, DateTime manufacturing_date)
 {
     try
     {
         productdetail p = new productdetail();
         p.productcode        = productcode;
         p.price              = price;
         p.manufacturing_date = manufacturing_date;
         db.productdetails.Add(p);
         db.SaveChanges();
         ViewData["message"] = "Succesfully added";
     }
     catch (Exception ex)
     {
         ViewData["message"] = ex.Message;
     }
     return(RedirectToAction("products"));
 }
Example #10
0
        public ActionResult Add([Bind(Include = "id,activeFlag,createDate,updateDate")] productdetail productdetail, int productId, int colorId, decimal price, HttpPostedFileBase imgUrl)
        {
            string fileName = System.IO.Path.GetFileName(imgUrl.FileName);
            String date     = DateTime.Now.ToString();

            System.Diagnostics.Debug.WriteLine("date " + date);
            string urlImage = Server.MapPath("~/Content/client/img/product/" + fileName);

            imgUrl.SaveAs(urlImage);
            productdetail.imgUrl = fileName;
            int countSpec = Convert.ToInt32(Request.Form["countSpec"]);

            System.Diagnostics.Debug.WriteLine("product id " + productId);
            System.Diagnostics.Debug.WriteLine("color id " + colorId);
            System.Diagnostics.Debug.WriteLine("price " + price);
            System.Diagnostics.Debug.WriteLine("file name " + fileName);

            System.Diagnostics.Debug.WriteLine("count " + countSpec);

            spec spec = new spec();

            spec.activeFlag = 1;
            spec.createDate = DateTime.Now;
            spec.updateDate = DateTime.Now;
            db.specs.Add(spec);
            db.SaveChanges();

            for (int i = 0; i < countSpec; i++)
            {
                specdetail sd = new specdetail();
                sd.spec = db.specs.Find(spec.id);
                String paramName  = "name_" + i;
                String paramValue = "value_" + i;
                String name       = Convert.ToString(Request.Form[paramName]);
                String value      = Convert.ToString(Request.Form[paramValue]);

                sd.name       = name;
                sd.value      = value;
                sd.activeFlag = 1;
                sd.createDate = DateTime.Now;
                sd.updateDate = DateTime.Now;

                db.specdetails.Add(sd);
                db.SaveChanges();
            }


            productdetail.product    = db.products.Find(productId);
            productdetail.spec       = db.specs.Find(spec.id);
            productdetail.color      = db.colors.Find(colorId);
            productdetail.price      = price;
            productdetail.activeFlag = 1;
            productdetail.createDate = DateTime.Now;
            productdetail.updateDate = DateTime.Now;

            db.productdetails.Add(productdetail);
            db.SaveChanges();


            return(RedirectToAction("productDetailList", "AdminProductDetail", new { productId = productId }));
        }