public ActionResult Save(StockAdjustment stockAdjustment)
        {
            StockAdjustment sa = new StockAdjustment
            {
                CreatedBy = User.Identity.GetUserId(),
                Remarks   = stockAdjustment.Remarks,
                Status    = CustomStatus.PendingApproval
            };

            stockAdjustmentService.Save(sa);

            foreach (ItemStockAdjustment item in stockAdjustment.ItemStockAdjustments)
            {
                ItemStockAdjustment itemStockAdjustment = new ItemStockAdjustment
                {
                    StockAdjustmentId = sa.Id,
                    ItemId            = item.ItemId,
                    StockMovement     = item.StockMovement,
                    OldQuantity       = stockAdjustmentService.GetItemQuantity(item.ItemId),
                    NewQuantity       = stockAdjustmentService.GetItemQuantity(item.ItemId) + item.StockMovement
                };
                itemStockAdjustmentService.Save(itemStockAdjustment);
            }
            return(Json(new { res = sa }));
        }
예제 #2
0
        public IHttpActionResult createStockAdjustment([FromBody] MobileStockAdjustment viewModel)
        {
            //Create new stock adjustment and update to pending approval
            StockAdjustment sa = new StockAdjustment
            {
                CreatedBy = viewModel.CreatedBy,
                Remarks   = viewModel.Remarks,
                Status    = CustomStatus.PendingApproval
            };

            stockAdjustmentService.Save(sa);

            //Create new itemStockAdjustment
            ItemStockAdjustment itemStockAdjustment = new ItemStockAdjustment
            {
                StockAdjustmentId = sa.Id,
                ItemId            = viewModel.ItemId,
                StockMovement     = viewModel.Movement,
                OldQuantity       = stockAdjustmentService.GetItemQuantity(viewModel.ItemId),
                NewQuantity       = stockAdjustmentService.GetItemQuantity(viewModel.ItemId) + viewModel.Movement
            };

            itemStockAdjustmentService.Save(itemStockAdjustment);

            return(Ok());
        }
        public void Save(ItemStockAdjustment itemStockAdjustment)
        {
            ItemStockAdjustment item = itemStockAdjustmentContext.Get(itemStockAdjustment.Id);

            if (item == null)
            {
                itemStockAdjustmentContext.Add(itemStockAdjustment);
            }
            else
            {
                item.OldQuantity   = itemStockAdjustment.OldQuantity;
                item.NewQuantity   = itemStockAdjustment.NewQuantity;
                item.StockMovement = itemStockAdjustment.StockMovement;
            }
            itemStockAdjustmentContext.Commit();
        }
예제 #4
0
    protected void btnSaveAdj_Click(object sender, EventArgs e)
    {
        try
        {
            if (seQuantity.Text == "0")
            {
                lblError.Visible = true;
                lblError.Text    = "Invalid Quantity";
                return;
            }
            else
            {
                lblError.Visible = false;
                lblError.Text    = "";
            }

            ItemStockAdjustment stock = new ItemStockAdjustment();
            stock.Description = txtDescription.Text.Trim();
            stock.Qty         = Int32.Parse(seQuantity.Text);
            stock.ItemId      = ObjItem.ItemId;
            stock.UserId      = Master.LoggedUser.UserId;

            if (new ItemsDAO().AddItemsAdjustment(stock))
            {
                txtDescription.Text = string.Empty;
                seQuantity.Text     = "0";

                LoadAlterations();
            }
        }
        catch (Exception ex)
        {
            ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void btnSaveAdj_Click(object sender, EventArgs e)");
            if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty)
            {
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false);
            }
            else
            {
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false);
            }
        }
    }