public ActionResult AllAdjVouchers(string sessionId) { long totalAdjNumber = (long)AdjVoucherService.GetLastId(); List <string> dates = new List <string>(); List <string> authorisedBys = new List <string>(); List <string> statuses = new List <string>(); List <string> adjIds = new List <string>(); for (long i = 1; i <= totalAdjNumber; i++) { string adjId = i.ToString("000/000/00"); adjIds.Add(adjId); AdjVoucher adj = AdjVoucherService.GetAdjByAdjId(i)[0]; string date = adj.Date.Day.ToString("00") + "/" + adj.Date.Month.ToString("00") + "/" + adj.Date.Year; dates.Add(date); string authorisedBy = "Nil"; if (adj.AuthorisedBy != 0) { authorisedBy = EmployeeService.GetEmployeeById(adj.AuthorisedBy).EmpName; } authorisedBys.Add(authorisedBy); string status = null; switch (adj.status) { case 0: status = "Pending submit reason by Clerk"; break; case 1: status = "Authorised"; break; case 2: status = "Pending authorisation by Supervisor"; break; case 3: status = "Pending authorisation by Manager"; break; } statuses.Add(status); } ViewData["sessionId"] = sessionId; ViewData["dates"] = dates; ViewData["authorisedBys"] = authorisedBys; ViewData["statuses"] = statuses; ViewData["adjIds"] = adjIds; return(View()); }
/* * public ActionResult Generate(List<Inventory> inventories, string sessionId) * { * long adjId = (long)AdjVoucherService.GetLastId() + 1; * int flag = 0; * foreach (Inventory inventory in inventories) * { * int qty = inventory.ActualStock - inventory.StockLevel; * if (qty != 0) * { * flag = 1; * AdjVoucherService.CreateAdjVoucher(adjId, inventory.ItemId, qty); * StockService.UpdateInventoryStockById(inventory.ItemId, inventory.ActualStock); * } * } * if(flag == 0) * { * TempData["errorMsg"] = "<script>alert('There are no discrepancies in stock.');</script>"; * ViewData["userName"] = EmployeeService.GetUserBySessionId(sessionId).EmpName; * ViewData["sessionId"] = sessionId; * return View("~/Views/StoreLandingPage/Home.cshtml"); * } * * * return RedirectToAction("PutReason", new { sessionId}); * }*/ public ActionResult Generate(Inventory item, FormCollection formCollection, string sessionId) { List <int> itemsQuantities = new List <int>(); List <long> itemIds = new List <long>(); long adjId = (long)AdjVoucherService.GetLastId() + 1; int flag = 0; string counter = formCollection["counter"]; for (int i = 0; i < int.Parse(counter); i++) { int actualStock = int.Parse(formCollection["actualStock_" + i]); int lastStock = int.Parse(formCollection["lastStock_" + i]); int qty = actualStock - lastStock; if (qty != 0) { flag = 1; long itemId = long.Parse(formCollection["itemId_" + i]); AdjVoucherService.CreateAdjVoucher(adjId, itemId, qty); //Update Inventory with new stock level StockService.UpdateInventoryStockById(itemId, actualStock); //The function below is for update stock card //By the time authorise adjustment voucher, update StockCard table with itemId and date, souceType = 1 StockCardService.CreateStockCardFromAdj(adjId, itemId, qty); } } if (flag == 0) { TempData["errorMsg"] = "<script>alert('There are no discrepancies in stock.');</script>"; ViewData["userName"] = EmployeeService.GetUserBySessionId(sessionId).EmpName; ViewData["sessionId"] = sessionId; return(View("~/Views/StoreLandingPage/Home.cshtml")); } return(RedirectToAction("PutReason", new { sessionId })); }