Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ProductId,ProductName,ProductCode,Remark,Description,PriceExVAT,Reprobel,Bebat,Recupel,Auvibel,PurchasePrice,Brand,CategoryId,VATPercId,Stock,EAN")] ProductCreateViewModel product)
        {
            if (ModelState.IsValid)
            {
                Product prod = new Product();
                prod.ProductName = product.ProductName;
                prod.ProductCode = product.ProductCode;
                prod.Remark = product.Remark;
                prod.Description = product.Description;
                prod.PriceExVAT = product.PriceExVAT;
                prod.Reprobel = product.Reprobel;
                prod.Bebat = product.Bebat;
                prod.Recupel = product.Recupel;
                prod.Auvibel = product.Auvibel;
                prod.PurchasePrice = product.PurchasePrice;
                prod.Brand = product.Brand;
                prod.CategoryId = product.CategoryId;
                prod.VATPercId = product.VATPercId;
                prod.Stock = product.Stock;
                prod.EAN = product.EAN;
                prod.Active = true;

                db.Products.Add(prod);
                db.SaveChanges();
                return RedirectToAction("Index");

            }

            return View(product);
        }
Ejemplo n.º 2
0
        public ActionResult Edit([Bind(Include = "OrderDetailId,Quantity,OrderId,ProductId,ProductName,ProductCode,Description,PriceExVAT,Reprobel,Bebat,Recupel,Auvibel,Brand,CategoryId,VATPercId,TotalExVat,TotalIncVat")] OrderDetail orderDetail, string returnUrl)
        {
            Product prod = new Product();
            prod = db.Products.Find(orderDetail.ProductId);
            VAT tempod = db.VATs.Find(orderDetail.VATPercId);

            orderDetail.ProductName = prod.ProductName;
            orderDetail.TotalExVat = (orderDetail.PriceExVAT + orderDetail.Auvibel + orderDetail.Bebat + orderDetail.Recupel + orderDetail.Reprobel) * orderDetail.Quantity;
            orderDetail.TotalIncVat = orderDetail.TotalExVat * (1 + (tempod.VATValue / 100));

            if (ModelState.IsValid)
            {
                db.Entry(orderDetail).State = EntityState.Modified;
                db.SaveChanges();
                return Redirect(returnUrl);
            }
            ViewBag.OrderId = new SelectList(db.Orders, "OrderId", "Annotation", orderDetail.OrderId);
            ViewBag.VATPercId = new SelectList(db.VATs, "VATPercId", "VATPercId", orderDetail.VATPercId);
            return Redirect(returnUrl);
        }
        public ActionResult Edit([Bind(Include = "QuotationDetailId,Quantity,QuotationId,ProductId,ProductName,ProductCode,Description,PriceExVAT,Reprobel,Bebat,Recupel,Auvibel,Brand,CategoryId,VATPercId")] QuotationDetail quotationDetail, int editValue)
        {
            Product prod = new Product();
            prod = db.Products.Find(quotationDetail.ProductId);

            //aangezien VAT obj niet 100% mee linkt vanuit de edit halen we deze opnieuw op via QD id
            VAT tempqd = db.VATs.Find(quotationDetail.VATPercId);

            quotationDetail.ProductName = prod.ProductName;
            quotationDetail.TotalExVat = (quotationDetail.PriceExVAT + quotationDetail.Auvibel + quotationDetail.Bebat + quotationDetail.Recupel + quotationDetail.Reprobel) * quotationDetail.Quantity;
            quotationDetail.TotalIncVat = quotationDetail.TotalExVat * (1 + (tempqd.VATValue / 100));

            if (ModelState.IsValid)
            {
                db.Entry(quotationDetail).State = EntityState.Modified;
                db.SaveChanges();
                if (editValue == 1)
                {
                    return RedirectToAction("Edit", "Quotations", new { id = quotationDetail.QuotationId });
                }
                return RedirectToAction("AddProducts", "Quotations", new { id = quotationDetail.QuotationId });
            }
            return View(quotationDetail);
        }