public async Task <IActionResult> PutUserAccount(int id, UserAccount userAccount)
        {
            if (id != userAccount.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(userAccount).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserAccountExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#2
0
        public async Task <IActionResult> Edit(string id, [Bind("ItemNumber,Category,ItemName,ReorderLevel,ReorderQty,UnitOfMeasure,Stock,Supplier1,Supplier2,Supplier3,Supplier1Price,Supplier2Price,Supplier3Price,Location")] Catalogue catalogue)
        {
            if (id != catalogue.ItemNumber)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(catalogue);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CatalogueExists(catalogue.ItemNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Supplier1"] = new SelectList(_context.Supplier, "SupplierCode", "SupplierCode", catalogue.Supplier1);
            ViewData["Supplier2"] = new SelectList(_context.Supplier, "SupplierCode", "SupplierCode", catalogue.Supplier2);
            ViewData["Supplier3"] = new SelectList(_context.Supplier, "SupplierCode", "SupplierCode", catalogue.Supplier3);
            return(View(catalogue));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("SupplierCode,SupplierName,GstregistrationNo,TitleOfCourtesy,ContactName,PhoneNo,FaxNo,Address,City,PostalCode")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                _context.Add(supplier);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplier));
        }
        public async Task <IActionResult> RequestItemDelete(string itemName, string rrid)
        {
            var    q          = context.Catalogue.Where(x => x.ItemName == itemName).FirstOrDefault();
            string itemNumber = q.ItemNumber;

            var q3 = context.RecordDetails.Where(x => x.Rrid == rrid && x.ItemNumber == itemNumber).FirstOrDefault();

            context.RecordDetails.Remove(q3);
            await context.SaveChangesAsync();

            return(RedirectToAction("Edit", "ViewRequest", new { id = rrid }));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("UserId,TitleOfCourtesy,Name,DepartmentCode,Telephone,Fax,EmailAddress")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentCode"] = new SelectList(_context.Department, "DepartmentCode", "DepartmentCode", user.DepartmentCode);
            return(View(user));
        }
        public async Task <IActionResult> Create([Bind("Dlid,StartDate,EstDeliverDate,CompleteDate,DepartmentCode,RepId,CollectionPointId,Status")] DisbursementList disbursementList)
        {
            if (ModelState.IsValid)
            {
                _context.Add(disbursementList);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CollectionPointId"] = new SelectList(_context.CollectionPoint, "CollectionPointId", "CollectionPointName", disbursementList.CollectionPointId);
            ViewData["DepartmentCode"]    = new SelectList(_context.Department, "DepartmentCode", "DepartmentCode", disbursementList.DepartmentCode);
            //ViewData["RepId"] = new SelectList(_context.User, "UserId", "DepartmentCode", disbursementList.RepId);
            return(View(disbursementList));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Rdid,Rrid,ItemNumber,Quantity,Remark")] RecordDetails recordDetails)
        {
            if (id != recordDetails.Rdid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(recordDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RecordDetailsExists(recordDetails.Rdid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ItemNumber"] = new SelectList(_context.Catalogue, "ItemNumber", "ItemNumber", recordDetails.ItemNumber);
            return(View(recordDetails));
        }
        public async Task <IActionResult> PutRecordDetails(int id, RecordDetails recordDetails)
        {
            if (id != recordDetails.Rdid)
            {
                return(BadRequest());
            }

            _context.Entry(recordDetails).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RecordDetailsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#9
0
        public async Task <string> saveVoucherAsync(details source)
        {
            RecordDetails k = new RecordDetails();
            var           h = _context.Catalogue.Where(s => s.ItemName == source.ItemName).First().ItemNumber;

            k.ItemNumber = h;
            k.Rrid       = source.VoNo;
            k.Remark     = source.Remark;
            k.Quantity   = source.Quantity;
            _context.RecordDetails.Add(k);
            await _context.SaveChangesAsync();

            return("ok");
        }
示例#10
0
        public async Task <IActionResult> Create([Bind("ItemNumber,Category,ItemName,ReorderLevel,ReorderQty,UnitOfMeasure,Stock,Out,Supplier1,Supplier2,Supplier3,Supplier1Price,Supplier2Price,Supplier3Price")] Catalogue catalogue)
        {
            //Viewbag for supplier1 dropdown list, need to post back
            List <Supplier> supplier1List = _context.Supplier.ToList();

            supplier1List.Insert(0, new Supplier {
                SupplierCode = "---Select Supplier---", SupplierName = "---Select Supplier---"
            });
            ViewBag.Supplier1 = supplier1List;
            List <Supplier> supplier2List = _context.Supplier.ToList();

            supplier1List.Insert(0, new Supplier {
                SupplierCode = "---Select Supplier---", SupplierName = "---Select Supplier---"
            });
            ViewBag.Supplier2 = supplier2List;
            List <Supplier> supplier3List = _context.Supplier.ToList();

            supplier3List.Insert(0, new Supplier {
                SupplierCode = "---Select Supplier---", SupplierName = "---Select Supplier---"
            });
            ViewBag.Supplier3 = supplier3List;


            if (ModelState.IsValid)
            {
                _context.Add(catalogue);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                TempData["EmptyError"] = "Please fill in all details!";
                return(RedirectToAction("Create"));
            }
            //return View(catalogue);
        }
        public async Task <IActionResult> Index(CollectionPoint cp)
        {
            if (ModelState.IsValid)
            {
                int c1 = cp.CollectionPointId;
                var q  = b.findDisbursementListStatus(dept);
                Models.DisbursementList d1 = q;
                d1.CollectionPointId = c1;
                await context.SaveChangesAsync();

                TempData["Alert1"] = "Collection Point Changed Successfully";
                return(RedirectToAction("Index"));
            }
            TempData["Alert2"] = "Please Try Again";
            return(RedirectToAction("Index"));
        }
示例#12
0
        public async Task <IActionResult> Index(CollectionPoint cp)
        {
            if (ModelState.IsValid)
            {
                int newCollectionPoint = cp.CollectionPointId;
                var q1 = context.Department.Where(x => x.DepartmentCode == dept).First();
                Models.Department d2 = q1;
                d2.CollectionPointId = newCollectionPoint;

                TimeSpan cutoff = TimeSpan.Parse("17:30"); // 5.30 PM
                TimeSpan now    = DateTime.Now.TimeOfDay;

                if (DateTime.Now.DayOfWeek == DayOfWeek.Tuesday || DateTime.Now.DayOfWeek == DayOfWeek.Wednesday || DateTime.Now.DayOfWeek == DayOfWeek.Thursday || (DateTime.Now.DayOfWeek == DayOfWeek.Friday && now <= cutoff))
                {
                    var t = context.DisbursementList.Where(x => x.DepartmentCode == dept && x.Status == "Pending Delivery");
                    if (t.Any())
                    {
                        DisbursementList dl = new DisbursementList();
                        dl = t.First();
                        dl.CollectionPointId = newCollectionPoint;
                    }
                }
                await context.SaveChangesAsync();

                TempData["Alert1"] = "Collection Point Changed Successfully";

                //send success email to dept rep
                var    deptrep = context.User.Where(x => x.UserId == userid).First();
                string email   = deptrep.EmailAddress;
                await _emailSender.SendEmailAsync(email, "Change in Stationery Collection Point", "Dear " + deptrep.Name + ",<br>Stationery collection point for " + deptrep.DepartmentCode + "department has successfully been changed.");

                return(RedirectToAction("Index"));
            }
            TempData["Alert2"] = "Please Try Again";
            return(RedirectToAction("Index"));
        }