Esempio n. 1
0
        public IActionResult ManageInvItem(string itemId, string inputupdateQty)
        {
            if (!(HttpContext.Session.GetString("role") == Enums.EmployeeRole.STORECLERK || HttpContext.Session.GetString("role") == Enums.EmployeeRole.STORESUPERVISOR || HttpContext.Session.GetString("role") == Enums.EmployeeRole.STOREMANAGER))
            {
                return(RedirectToAction(HttpContext.Session.GetString("role"), "Home"));
            }
            bool isNum = int.TryParse(inputupdateQty, out int updateQty);

            if (!(inputupdateQty != null))
            {
                TempData["alertMsg"] = "Please enter update quantity!";
                return(RedirectToAction("EditDeleteItem", new { cmd = "manage", itemId = itemId }));
            }
            else if (!isNum)
            {
                TempData["alertMsg"] = "Update quantity must be a number!";
                return(RedirectToAction("EditDeleteItem", new { cmd = "manage", itemId = itemId }));
            }
            else if (updateQty <= 0)
            {
                TempData["alertMsg"] = "Update quantity must be a positive number!";
                return(RedirectToAction("EditDeleteItem", new { cmd = "manage", itemId = itemId }));
            }
            else
            {
                int empId = Convert.ToInt32(HttpContext.Session.GetString("id"));
                invService.CreateInvMgmt(itemId, updateQty, empId);
                invService.CheckIfPendingStockRequestCanBeFufilled();
                TempData["alertMsg"] = "Item has been updated!";
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 2
0
        public IActionResult saveAdjustmentVoucher(string itemname, int AdjustQty, double AdjustAmt, string reason)
        {
            if (HttpContext.Session.GetString("role") == EmployeeRole.STORESUPERVISOR || HttpContext.Session.GetString("role") == EmployeeRole.STOREMANAGER)
            {
                int employeeId = int.Parse(HttpContext.Session.GetString("id"));
                if (itemname == null || AdjustQty == 0)
                {
                    TempData["Msg"] = "Please enter all information (Reason is optional)";
                    return(RedirectToAction("AddAdjustmentVoucher"));
                }

                else if (HttpContext.Session.GetString("role") == EmployeeRole.STORESUPERVISOR && System.Math.Abs(AdjustAmt) > 250)
                {
                    TempData["Msg"] = "Adjust amount has exceeded $250! Please direct to your manager for item adjustment.";
                    return(RedirectToAction("AddAdjustmentVoucher"));
                }

                else
                {
                    avService.createAdjustmentVoucher(itemname, AdjustQty, AdjustAmt, reason, employeeId);
                    invService.CheckIfPendingStockRequestCanBeFufilled();
                    TempData["Msg"] = "Adjustment voucher form has been created!";
                    return(RedirectToAction("AddAdjustmentVoucher"));
                    // return RedirectToAction("Index", "AdjustmentVoucher");
                }
            }
            return(RedirectToAction("Index", "Home"));
        }