Ejemplo n.º 1
0
        public ActionResult AddPackage(PackagePurchase packagePurchase)
        {
            var purchaseView = Session["purchaseView"] as PurchaseView;
            var packageid    = int.Parse(Request["PackageID"]);

            if (packageid == 0)
            {
                var list = db.Packages.ToList();
                list.Add(new PackagePurchase {
                    PackageID = 0, Description = "[Seleccione un Paquete]"
                });
                list = list.OrderBy(C => C.Description).ToList();
                ViewBag.PackageID = new SelectList(list, "PackageID", "Description");
                ViewBag.Error     = "Seleccione un Alimento";
            }
            //Validar existencia de producto

            var package = db.Packages.Find(packageid);

            if (package == null)
            {
                var list = db.Packages.ToList();
                list.Add(new PackagePurchase {
                    PackageID = 0, Description = "[Seleccione un Paquete]"
                });
                list = list.OrderBy(C => C.Description).ToList();
                ViewBag.PackageID = new SelectList(list, "PackageID", "Description");
                ViewBag.Error     = "Paquete no Existe";
                return(View(packagePurchase));
            }

            //Adicionar el producto a la orden
            packagePurchase = purchaseView.PackagePurchase1.Find(p => p.PackageID == packageid);

            if (packagePurchase == null)
            {
                packagePurchase = new PackagePurchase
                {
                    Description = package.Description,
                    PackageID   = package.PackageID,
                    Quantity    = float.Parse(Request["Quantity"]),
                };

                purchaseView.PackagePurchase1.Add(packagePurchase);
            }
            else
            {
                packagePurchase.Quantity += float.Parse(Request["Quantity"]);
            }

            var listC = db.Customers.ToList();

            listC.Add(new Customer {
                CustomerId = 0, FirstName = "[Seleccione un Cliente]"
            });
            listC = listC.OrderBy(C => C.FullName).ToList();
            ViewBag.CustomerId = new SelectList(listC, "CustomerId", "FullName");

            return(View("NewPackage", purchaseView));
        }
Ejemplo n.º 2
0
 protected override void OnOpenNew()
 {
     Purchase = new PackagePurchase
     {
         Date     = DateTime.Now,
         Account  = ContextManager.ActiveAccounts.FirstOrDefault(),
         Supplier = ContextManager.ActiveSuppliers.FirstOrDefault(),
         Package  = ContextManager.ActivePackages.FirstOrDefault()
     };
 }
Ejemplo n.º 3
0
 protected override void OnOpenEdit(object argEntity)
 {
     Purchase = argEntity as PackagePurchase;
 }