Exemple #1
0
        private void GenerateItem(int kanbanReqId, int partFGId, int lotNumber)
        {
            List <MsPartStructure> partStructs = DbContext.MsPartStructure.Where(a => a.PartFGId == partFGId).ToList();

            foreach (MsPartStructure partStruct in partStructs)
            {
                KanbanReqItem item = new KanbanReqItem();
                item.KanbanReqId = kanbanReqId;
                item.PartId      = partStruct.PartId;

                double usage   = partStruct.Usage;
                double partNum = lotNumber * usage;

                item.EstKanban = 0;
                item.ReqKanban = 0;

                MsPart part = DbContext.MsPart.Where(a => a.PartId == partStruct.PartId).FirstOrDefault();
                if (part != null)
                {
                    item.EstKanban = (int)Math.Ceiling(partNum / part.LotSize);

                    StockWH stock = DbContext.StockWH.Where(a => a.PartNo == part.PartNo).FirstOrDefault();
                    if (stock != null)
                    {
                        item.ReqKanban = partNum < stock.StockQty ? item.EstKanban : (int)Math.Floor(stock.StockQty / part.LotSize);
                    }
                }

                DbContext.KanbanReqItem.Add(item);
                DbContext.SaveChanges();
            }
        }
Exemple #2
0
        private void SetViewBagItem(KanbanReqItem data)
        {
            MsPart part = DbContext.MsPart.Where(a => a.PartId == data.PartId).FirstOrDefault();

            if (part != null)
            {
                ViewBag.PartName = part.PartName;
                ViewBag.PartNo   = part.PartNo;
                ViewBag.Supplier = part.Supplier;
            }
        }
Exemple #3
0
 public IActionResult ItemDetail(int id, int kanbanReqId)
 {
     try
     {
         KanbanReqItem data = DbContext.KanbanReqItem.Where(a => a.ReqItemId == id).FirstOrDefault();
         if (data == null)
         {
             data             = new KanbanReqItem();
             data.KanbanReqId = kanbanReqId;
         }
         SetViewBagItem(data);
         return(View(data));
     }
     catch (Exception e)
     {
         LogHelp.WriteErrorLog(e);
     }
     return(View());
 }
Exemple #4
0
        public IActionResult ItemSave(KanbanReqItem model)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                KanbanReqItem data = DbContext.KanbanReqItem.Where(a => a.ReqItemId == model.ReqItemId).FirstOrDefault();
                data.ReqKanban = model.ReqKanban;
                data.EditDate  = DateTime.Now;
                data.EditBy    = LoginInfo.UserId;
                DbContext.KanbanReqItem.Update(data);
                DbContext.SaveChanges();
                status = true;
                return(Json(new { status }));
            }
            else
            {
                SetViewBagItem(model);
                return(Json(new { status, html = ViewHelper.RenderRazorViewToString(this, "ItemDetail", model) }));
            }
        }