public JsonResult AjaxTypeUpdate(string row)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                TPOFormulationLineProductModel formulationLineProduct = JsonConvert.DeserializeObject <TPOFormulationLineProductModel>(row);
                if (formulationLineProduct != null)
                {
                    formulationLineProduct.LastModified = DateTime.Now;
                    TPOFormulationLineProductDto dto = new TPOFormulationLineProductDto();
                    using (TPOFormulationLineProductService service = new TPOFormulationLineProductService())
                    {
                        Mapper.Map(formulationLineProduct, dto);
                        if (formulationLineProduct.Id > 0)
                        {
                            service.Update(dto);
                        }
                    }
                }

                responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave);
            }
            catch (Exception exc)
            {
                responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message);
            }

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AjaxTypeUpdate(string row)
        {
            TPOFormulationLineProductModel formulationLineProduct = JsonConvert.DeserializeObject <TPOFormulationLineProductModel>(row);

            if (formulationLineProduct != null)
            {
                formulationLineProduct.LastModified = DateTime.Now;
                TPOFormulationLineProductDto dto = new TPOFormulationLineProductDto();
                using (TPOFormulationLineProductService service = new TPOFormulationLineProductService())
                {
                    Mapper.Map(formulationLineProduct, dto);
                    if (formulationLineProduct.Id > 0)
                    {
                        service.Update(dto);
                    }
                }
            }

            return(RedirectToAction("Edit", "TPOProduct"));
        }
Пример #3
0
        public int GetBatchNumber(IProductEntryDto tpoCProductRollDto)
        {
            int batchNumber = 0;

            if (tpoCProductRollDto.MasterRollID.HasValue)
            {
                TPOCProductRollDto masterRoll = Get(tpoCProductRollDto.MasterRollID.Value);
                return(masterRoll.BatchNumber);
            }
            else
            {
                bool               newBatch     = false;
                TPOBatchService    batchService = new TPOBatchService();
                List <TPOBatchDto> batch        = batchService.GetByLineID(tpoCProductRollDto.LineID);
                if (batch == null || batch.Count == 0)
                {
                    newBatch = true;
                }
                else
                {
                    batchNumber = batch[0].BatchNumber;
                }

                TPOFormulationLineProductDto formulationLineProduct = GetFormulationLineProduct(tpoCProductRollDto);
                newBatch = CheckNewBatchRequirements(tpoCProductRollDto, newBatch, batchService, batch, formulationLineProduct);

                if (newBatch)
                {
                    return(GetNewBatch(tpoCProductRollDto, ++batchNumber, formulationLineProduct.TPOFormulationID));
                }
                else
                {
                    return(batch[0].BatchNumber);
                }
            }
        }
Пример #4
0
 private bool CheckFormulationForBatch(bool newBatch, List <TPOBatchDto> batch, TPOFormulationLineProductDto formulationLineProduct)
 {
     if (formulationLineProduct.TPOFormulationID != batch[0].FormulationID)
     {
         newBatch = true;
     }
     return(newBatch);
 }
Пример #5
0
        private bool CheckNewBatchRequirements(IProductEntryDto tpoCProductRollDto, bool newBatch, TPOBatchService batchService, List <TPOBatchDto> batch, TPOFormulationLineProductDto formulationLineProduct)
        {
            if (!newBatch)
            {
                newBatch = CheckFormulationForBatch(newBatch, batch, formulationLineProduct);
            }

            if (!newBatch)
            {
                newBatch = CheckScrimRollCountsForBatch(tpoCProductRollDto, newBatch, batchService, batch);
            }

            if (!newBatch)
            {
                newBatch = CheckScrimRollsForBatch(tpoCProductRollDto, newBatch);
            }

            if (!newBatch)
            {
                newBatch = CheckRawMaterialCountsForBatch(tpoCProductRollDto, newBatch, batchService, batch);
            }

            if (!newBatch)
            {
                newBatch = CheckRawMaterialsForBatch(tpoCProductRollDto, newBatch);
            }
            return(newBatch);
        }