Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, int?nameinput, DateTime dateinput, int?storageinput, string catinput, int?costinput, int?amtinput, string supplierinput, string commentinput)
        {
            PhyDisposables phyDisposables = await _context.PhyDisposables.SingleOrDefaultAsync(p => p.PhyDisposablesPK == id);

            if (id != phyDisposables.PhyDisposablesPK)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    phyDisposables.DispoID    = nameinput;
                    phyDisposables.OrderDate  = dateinput;
                    phyDisposables.LocationID = storageinput;
                    phyDisposables.CAT        = catinput;
                    phyDisposables.Cost       = costinput;
                    phyDisposables.AmtOrdered = amtinput;
                    phyDisposables.Supplier   = supplierinput;
                    phyDisposables.Comments   = commentinput;
                    var temp = _context.Locations.First(m => m.LocationID == storageinput);
                    phyDisposables.NormalizedLocation = temp.StorageCode;
                    var temp2 = _context.Disposable.First(n => n.DispoID == nameinput);
                    phyDisposables.ItemName = temp2.DispoName;

                    _context.Update(phyDisposables);
                    await _context.SaveChangesAsync();

                    Sp_Logging("2-Change", "Edit", "User edited a Disposable inventory item where ID= " + id.ToString(), "Success");
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhyDisposablesExists(phyDisposables.PhyDisposablesPK))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["DispoID"]      = new SelectList(_context.Disposable, "DispoID", "DispoName", phyDisposables.DispoID);
            ViewData["LocationName"] = new SelectList(_context.Locations, "LocationID", "StorageCode", phyDisposables.LocationID);
            return(View(phyDisposables));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(int?nameinput, DateTime dateinput, int?storageinput, string cat, int?costinput, int?amtinput, string supplierinput, string commentsinput)
        {
            ViewData["ItemName"]    = nameinput;
            ViewData["OrderDate"]   = dateinput;
            ViewData["StorageCode"] = storageinput;
            ViewData["CAT"]         = cat;
            ViewData["Cost"]        = costinput;
            ViewData["AmtOrdered"]  = amtinput;
            ViewData["Supplier"]    = supplierinput;
            ViewData["Comments"]    = commentsinput;

            PhyDisposables phyDisposables = null;

            if (ModelState.IsValid)
            {
                phyDisposables            = new PhyDisposables();
                phyDisposables.DispoID    = nameinput;
                phyDisposables.OrderDate  = dateinput;
                phyDisposables.LocationID = storageinput;
                phyDisposables.CAT        = cat;
                phyDisposables.Cost       = costinput;
                phyDisposables.AmtOrdered = amtinput;
                phyDisposables.Supplier   = supplierinput;
                phyDisposables.Comments   = commentsinput;
                var temp = _context.Locations.First(m => m.LocationID == storageinput);
                phyDisposables.NormalizedLocation = temp.StorageCode;
                var temp2 = _context.Disposable.First(n => n.DispoID == nameinput);
                phyDisposables.ItemName = temp2.DispoName;

                _context.Add(phyDisposables);
                await _context.SaveChangesAsync();

                phyDisposables.PhyDisposablesID = phyDisposables.PhyDisposablesPK;
                _context.Update(phyDisposables);
                await _context.SaveChangesAsync();

                Sp_Logging("2-Change", "Create", "User created a disposable inventory item where ItemName=" + phyDisposables.ItemName, "Success");
                return(RedirectToAction("Index", new { barcodeFlag = true }));
            }
            ViewData["DispoID"]      = new SelectList(_context.Disposable, "DispoID", "DispoName", phyDisposables.DispoID);
            ViewData["LocationName"] = new SelectList(_context.Locations, "LocationID", "StorageCode", phyDisposables.LocationID);
            return(View(phyDisposables));
        }