private string GetIMRollNumber(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto) { bool old = false; string newLotNumber = GetNewLotNumber(tpoCProductRollDto); if (tpoCProductRollDto.RawMaterialReceivedID != 0) { try { RawMaterialReceived rm = _repository.Repository <RawMaterialReceived>().GetById(tpoCProductRollDto.RawMaterialReceivedID); if (rm.LotNumber.Substring(0, 7) != newLotNumber) { old = true; } } catch { old = true; } } WorkOrder workOrder = _repository.Repository <WorkOrder>().GetById(tpoCProductRollDto.WorkOrderID); string newProdCode = string.Empty; if (old) { newProdCode = FillOldIMLot(newLotNumber, workOrder); } else { newProdCode = FillCurrentIMLot(newLotNumber, workOrder); } return(newProdCode); }
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); }
private string GetMasterChildRollNumber(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto) { int count = _repository.Repository <TPOCProductRoll>().GetAllBy(pr => pr.MasterRollID == tpoCProductRollDto.MasterRollID).Count(); count++; return(GetMasterRollNumber(tpoCProductRollDto, prodLineDto) + count.ToString("00")); }
public string GetNewRollOrCartonCode(IProductEntryDto dto) { ProductionLinesDto productionLinesDto = GetProdLineDto(dto.LineID); ProdLineTypeDto prodLineTypeDto = GetProdLineTypeDto(productionLinesDto.LineTypeID); return(GetNewRollOrCartonCode(dto, productionLinesDto, prodLineTypeDto)); }
private string GetChildRollNumber(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto) { // TODO: FIXME string masterRollNumber = GetMasterRollNumber(tpoCProductRollDto, prodLineDto); int count = _repository.Repository <TPOCProductRoll>().GetAllBy(pr => pr.Code.StartsWith(masterRollNumber)).Count(); count++; return(masterRollNumber + count.ToString("00")); }
private bool CheckScrimRollsForBatch(IProductEntryDto tpoCProductRollDto, bool newBatch) { int scrimsOfThisLot = GetCurrentScrimCountForThisLot(tpoCProductRollDto); if (scrimsOfThisLot == 0) { newBatch = true; } return(newBatch); }
private bool CheckRawMaterialsForBatch(IProductEntryDto tpoCProductRollDto, bool newBatch) { int rawMaterialsOfThisLot = GetCurrentRawMaterialCountForThisLot(tpoCProductRollDto); if (rawMaterialsOfThisLot == 0) { newBatch = true; } return(newBatch); }
private int GetCurrentScrimCountForThisLot(IProductEntryDto tpoCProductRollDto) { TPOEntities context = new TPOEntities(); var x = from b in context.TPOBatches join cs in context.TPOCurrentScrims on b.ScrimRollID equals cs.Scrim1RollID select cs; return(x.Count()); }
private bool CheckScrimRollCountsForBatch(IProductEntryDto tpoCProductRollDto, bool newBatch, TPOBatchService batchService, List <TPOBatchDto> batch) { int oldScrimCount = GetScrimCountForBatch(batchService, batch); int newScrimCount = GetTPOCurrentScrimCount(tpoCProductRollDto); if (oldScrimCount != newScrimCount) { newBatch = true; } return(newBatch); }
private int GetCurrentRawMaterialCountForThisLot(IProductEntryDto tpoCProductRollDto) { TPOEntities context = new TPOEntities(); var x = from b in context.TPOBatches join cr in context.TPOCurrentRawMaterials on new { l = b.LineID, rr = b.RawMaterialReceivedID.Value } equals new { l = cr.LineID, rr = cr.RawMaterialReceivedID.Value } select cr; return(x.Count()); }
public int GetIMProductId(IProductEntryDto tpoCProductRollDto) { WorkOrderDto workOrder = (new WorkOrderService()).Get(tpoCProductRollDto.WorkOrderID); if (workOrder.IMProductID.HasValue) { return(workOrder.IMProductID.Value); } else { return(workOrder.TPOProductID.Value); } }
public string GetNewRollOrCartonCode(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto, ProdLineTypeDto prodLineTypeDto) { switch (prodLineTypeDto.ProdLineTypeCode) { case "TPO": if (prodLineDto.TPOMorC == "M") { return(GetMasterRollNumber(tpoCProductRollDto, prodLineDto)); } else if (!tpoCProductRollDto.MasterRollID.HasValue) { return(GetChildRollNumber(tpoCProductRollDto, prodLineDto)); } else { return(GetMasterChildRollNumber(tpoCProductRollDto, prodLineDto)); } break; case "WI": return(GetMasterChildRollNumber(tpoCProductRollDto, prodLineDto)); break; case "RW": return(GetChildRollNumber(tpoCProductRollDto, prodLineDto)); break; case "IM": return(GetIMRollNumber(tpoCProductRollDto, prodLineDto)); break; case "CO": return(GetChildRollNumber(tpoCProductRollDto, prodLineDto)); break; default: throw new ArgumentOutOfRangeException("Unknown Production Line Type"); } }
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); } } }
private string GetMasterRollNumber(IProductEntryDto tpoCProductRollDto, ProductionLinesDto prodLineDto) { return(prodLineDto.LabelID.ToString("00") + (tpoCProductRollDto.ProductionDate.Year % 100).ToString("00") + tpoCProductRollDto.ProductionDate.DayOfYear.ToString("000") + "01"); }
private int GetNewBatch(IProductEntryDto tpoCProductRollDto, int batchNumber, int formulationID) { List <TPOCurrentRawMaterial> rmList = _repository.Repository <TPOCurrentRawMaterial>().GetAllBy(r => r.LineID == tpoCProductRollDto.LineID).ToList(); DateTime now = DateTime.Now; foreach (TPOCurrentRawMaterial rm in rmList) { TPOBatch batch = new TPOBatch() { BatchNumber = batchNumber, DateEntered = now, EnteredBy = tpoCProductRollDto.ModifiedBy, FormulationID = formulationID, IsScrim = false, LastModified = now, LineID = tpoCProductRollDto.LineID, ModifiedBy = tpoCProductRollDto.ModifiedBy, PlantID = tpoCProductRollDto.PlantID, RawMaterialID = rm.RawMaterialReceived.RawMaterialID, RawMaterialReceivedID = rm.RawMaterialReceivedID.Value, ScrimRollID = null }; _repository.Repository <TPOBatch>().Insert(batch); } List <TPOCurrentScrim> scrimList = _repository.Repository <TPOCurrentScrim>().GetAllBy(s => s.ProdLineID == tpoCProductRollDto.LineID && s.ScrimPos != "NA").ToList(); foreach (TPOCurrentScrim scrim in scrimList) { if (scrim.Scrim1RollID != null) { TPOBatch batch = new TPOBatch() { BatchNumber = batchNumber, DateEntered = now, EnteredBy = tpoCProductRollDto.ModifiedBy, FormulationID = formulationID, IsScrim = true, LastModified = now, LineID = tpoCProductRollDto.LineID, ModifiedBy = tpoCProductRollDto.ModifiedBy, PlantID = tpoCProductRollDto.PlantID, ScrimRollID = scrim.Scrim1RollID.Value, RawMaterialID = null, RawMaterialReceivedID = null }; _repository.Repository <TPOBatch>().Insert(batch); } if (scrim.Scrim2RollID != null) { TPOBatch batch = new TPOBatch() { BatchNumber = batchNumber, DateEntered = now, EnteredBy = tpoCProductRollDto.ModifiedBy, FormulationID = formulationID, IsScrim = true, LastModified = now, LineID = tpoCProductRollDto.LineID, ModifiedBy = tpoCProductRollDto.ModifiedBy, PlantID = tpoCProductRollDto.PlantID, ScrimRollID = scrim.Scrim2RollID.Value, RawMaterialID = null, RawMaterialReceivedID = null }; _repository.Repository <TPOBatch>().Insert(batch); } } return(batchNumber); }
private int GetTPOCurrentRawMaterialsCount(IProductEntryDto tpoCProductRollDto) { return((new TPOCurrentRawMaterialService()).GetAllByLineID(tpoCProductRollDto.LineID).Count()); }
private string GetNewLotNumber(IProductEntryDto tpoCProductRoll) { return(tpoCProductRoll.ProductionDate.DayOfYear.ToString("000")); }
private int GetTPOCurrentScrimCount(IProductEntryDto tpoCProductRollDto) { return((new TPOCurrentScrimService()).GetByLineID(tpoCProductRollDto.LineID).Where(s => s.ScrimPos != "NA").Count()); }
private TPOFormulationLineProductDto GetFormulationLineProduct(IProductEntryDto tpoCProductRollDto) { return((new TPOFormulationLineProductService()).GetByPlantIdProductId(tpoCProductRollDto.PlantID, tpoCProductRollDto.ProductID)); }