コード例 #1
0
        public ActionResult History()
        {
            string token = GetToken();
            List <AdjustmentModel> adjlist = new List <AdjustmentModel>();
            SupplierItemModel      supp    = new SupplierItemModel();

            try
            {
                adjlist = APIAdjustment.GetAdjustmentByStatus(token, ConAdjustment.Active.APPROVED, out string error);
                if (adjlist != null)
                {
                    foreach (AdjustmentModel ad in adjlist)
                    {
                        foreach (AdjustmentDetailModel add in ad.Adjds)
                        {
                            supp           = APISupplier.GetOneSupplierItemByItemId(add.Itemid, token, out error);
                            add.Price      = supp.Price * Math.Abs(add.Adjustedqty);
                            ad.TotalPrice += add.Price;
                        }
                    }
                }
                TempData["history"] = adjlist;
            }
            catch (Exception ex)
            {
                RedirectToAction("Index", "Error", new { error = ex.Message });
            }


            return(View(adjlist));
        }
        public ActionResult Approve()
        {
            string token = GetToken();
            List <AdjustmentModel>       adjlist   = new List <AdjustmentModel>();
            List <AdjustmentDetailModel> adjdetail = new List <AdjustmentDetailModel>();
            SupplierItemModel            supp      = new SupplierItemModel();

            try
            {
                //get pending status adjustments
                adjlist = APIAdjustment.GetAdjustmentByStatus(token, ConAdjustment.Active.PENDING, out string error);
                if (adjlist != null)
                {
                    foreach (AdjustmentModel ad in adjlist)
                    {
                        //to divide according to raised to user role
                        ad.RaiseToRole = (APIUser.GetUserByUserID((int)ad.Raisedto, token, out error)).Role;
                        foreach (AdjustmentDetailModel adj in ad.Adjds)
                        {
                            try
                            {
                                //to show each item adjusted price and total pirce of adjustment form
                                supp           = APISupplier.GetOneSupplierItemByItemId(adj.Itemid, token, out error);
                                adj.Price      = supp.Price * Math.Abs(adj.Adjustedqty);
                                ad.TotalPrice += adj.Price;
                            }
                            catch (Exception)
                            {
                                if (supp == null)
                                {
                                    ad.TotalPrice += 0;
                                }
                            }
                        }
                    }
                    //separate adjustment pending list by reported to roles (supervisor/manager)
                    ViewBag.manager = adjlist.Where(x => x.RaiseToRole == ConUser.Role.MANAGER).ToList();
                    adjlist         = adjlist.Where(x => x.RaiseToRole == ConUser.Role.SUPERVISOR).ToList();
                }
                else
                {
                    adjlist         = new List <AdjustmentModel>();
                    ViewBag.manager = adjlist;
                }
            }
            catch (Exception ex)
            {
                RedirectToAction("Index", "Error", new { error = ex.Message });
            }
            return(View(adjlist));
        }
        public ActionResult Index()
        {
            string             token      = GetToken();
            UserModel          um         = GetUser();
            string             error      = "";
            List <POCountList> reportData = new List <POCountList>();

            List <AdjustmentModel> adjs = new List <AdjustmentModel>();

            List <SupplierModel> sups = new List <SupplierModel>();

            List <PurchaseOrderModel> pos = new List <PurchaseOrderModel>();

            List <InventoryDetailModel> invs = new List <InventoryDetailModel>();

            try
            {
                reportData = APIReport.GetPoForfiveMonths(token, out error);

                // adjustment count
                adjs = APIAdjustment.GetAdjustmentByStatus(token, ConAdjustment.Active.PENDING, out error);
                if (adjs == null)
                {
                    ViewBag.AdjCount = 0;
                }
                else
                {
                    ViewBag.AdjCount = adjs.Where(x => x.Raisedto == um.Userid).Count();
                }

                sups = APISupplier.GetSupplierByStatus(ConSupplier.Active.ACTIVE, token, out error);
                if (sups == null)
                {
                    ViewBag.SupCount = 0;
                }
                else
                {
                    ViewBag.SupCount = sups.Count;
                }

                // purchase order count
                pos = APIPurchaseOrder.GetPurchaseOrderByStatus(ConPurchaseOrder.Status.PENDING, token, out error);
                if (pos == null)
                {
                    ViewBag.POCount = 0;
                }
                else
                {
                    ViewBag.POCount = pos.Count;
                }

                // item restock level needed count
                invs = APIInventory.GetAllInventoryDetails(token, out error);
                if (invs == null)
                {
                    ViewBag.RestockCount = 0;
                }
                else
                {
                    ViewBag.RestockCount = invs.Where(x => x.RecommendedOrderQty > 0).Count();
                }
                return(View("Index", reportData));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
        }