コード例 #1
0
        public ConsolidatedCurrentRawMaterialsAndRollsViewModel ConsolidatedCurrentRawMaterialsAndRollsViewModel_Get(string lineID)
        {
            ScrimType             scrimTypeBL = new ScrimType();
            List <ScrimTypeModel> scrimTypes  = scrimTypeBL.GetScrimTypeModels();

            scrimTypes.Insert(0, new ScrimTypeModel()
            {
                Code = "N/A"
            });
            GetRollTypesList();
            ViewBag.ScrimRoll = new SelectList(new List <TPO.Model.Scrim.TPOCurrentScrimModel>());
            ProductionLine prodLineBL = new ProductionLine();

            List <TPO.Model.Production.ProductionLineModel> lines = prodLineBL.GetProductionLines();

            //lines.Insert(0, new TPO.Model.Production.ProductionLineModel() { Code = "Select Line" });
            ViewBag.ProductionLine = new SelectList(lines, "Code", "Code");
            //ViewBag.productionLineSelectList = new SelectList(lines, "Code", "Code");
            TPOCurrentScrim bl = new TPOCurrentScrim();

            ConsolidatedCurrentRawMaterialsAndRollsViewModel model = new ConsolidatedCurrentRawMaterialsAndRollsViewModel();

            TPOCurrentScrimModel tpoCurrentModel = bl.GetTPOCurrentScrimModelByLineID(lineID);

            if (tpoCurrentModel == null)
            {
                tpoCurrentModel       = new TPOCurrentScrimModel();
                model.TPOCurrentScrim = tpoCurrentModel;
            }
            else
            {
                model.TPOCurrentScrim = tpoCurrentModel;
            }

            List <CurrentRawMaterialDTO>       currentDTOList = GetRawMaterailListing(lineID);
            List <CurrentRawMaterialViewModel> model2         = currentDTOList.Select(MapCurrentRawMaterialDTOToViewModel).ToList();

            if (!model2.Any())
            {
                model2 = new List <CurrentRawMaterialViewModel>();
                model.CurrentRawMaterialList = model2;
            }
            else
            {
                model.CurrentRawMaterialList = model2;
            }

            if (!model.CurrentRawMaterialList.Any() && model.TPOCurrentScrim.LineID == null)
            {
                model.CurrentRawMaterial        = new CurrentRawMaterialViewModel();
                model.CurrentRawMaterial.LineId = "1";
                model.TPOCurrentScrim.LineID    = "1";
            }
            else
            {
                model.CurrentRawMaterialList = model2;
            }

            return(model);
        }
コード例 #2
0
        public ActionResult Create(TPOCurrentScrimModel model)
        {
            TPOCurrentScrim bl = new TPOCurrentScrim();

            model = bl.InsertTPOCurrentScrimModel(model);
            TempData["ActionMessage"]     = MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave);
            TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess);
            return(RedirectToAction("Edit", model.ID));
        }
コード例 #3
0
        public ActionResult Edit(ConsolidatedCurrentRawMaterialsAndRollsViewModel model)
        {
            TPOCurrentScrim bl     = new TPOCurrentScrim();
            string          lineID = model.LineID;

            model.TPOCurrentScrim.LineID = lineID;
            if (model.TPOCurrentScrim.ID > 0)
            {
                bl.UpdateTPOCurrentScrimModel(model.TPOCurrentScrim);
            }
            else
            {
                bl.InsertTPOCurrentScrimModel(model.TPOCurrentScrim);
            }
            TempData["ActionMessage"]     = MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave);
            TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess);
            return(RedirectToAction("Edit", new { lineID = lineID }));
        }
コード例 #4
0
        public int Add(TPOCurrentScrimDto dto)
        {
            int result = 0;

            var entity = new TPOCurrentScrim();

            try
            {
                Mapper.Map(dto, entity);
                entity.ScrimPos = "NA";
                _repository.Repository <TPOCurrentScrim>().Insert(entity);
                _repository.Save();
                result = entity.ID;
            }
            catch (DbEntityValidationException valEx)
            {
                var sb = new StringBuilder();

                foreach (var failure in valEx.EntityValidationErrors)
                {
                    sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType());
                    foreach (var error in failure.ValidationErrors)
                    {
                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                        sb.AppendLine();
                    }
                }

                throw new DbEntityValidationException(
                          "Entity Validation Failed - errors follow:\n" +
                          sb.ToString(), valEx
                          ); // Add the original exception as the innerException
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw;
            }

            return(result);
        }
コード例 #5
0
        public int Add(ProductionLinesDto dto)
        {
            var entity = Mapper.Map <ProductionLinesDto, ProdLine>(dto);


            //TODO:  Set fields on ProdLinesPerform based on values in ProdLine
            //ProdLinesPerform plp = new ProdLinesPerform();
            //plp.LocID = entity.LocID;

            //TODO:  Handle setting current work order to Line based on its type (see usp_WO_UpdateRCRWWorkOrders in old DB for reference)

            #region Line Type Checks
            //Get the type of production line
            ProdLineType type = _repository.Repository <ProdLineType>().GetById(entity.LineTypeID);
            if (type != null)
            {
                //If type is not reclaim or rework, make sure a WOLineUse record is present
                if (type.ProdLineTypeCode != "RW" && type.ProdLineTypeCode != "RC")
                {
                    //TODO:  Once WOLineUse table has been created, create a new instance of that Entity here and assign to newly created ProdLine
                }

                if (type.ProdLineTypeCode == "TPO" || type.ProdLineTypeCode == "RW" || type.ProdLineTypeCode == "WI" || type.ProdLineTypeCode == "CO")
                {
                    //Create TPOCurrentScrim record
                    if (type.ProdLineTypeCode == "TPO" || type.ProdLineTypeCode == "CO")
                    {
                        TPOCurrentScrim currScrim = new TPOCurrentScrim();
                        entity.TPOCurrentScrims.Add(currScrim);
                        currScrim.PlantID      = entity.PlantID;
                        currScrim.DateEntered  = entity.DateEntered;
                        currScrim.EnteredBy    = entity.EnteredBy;
                        currScrim.LastModified = entity.LastModified;
                        currScrim.ModifiedBy   = entity.ModifiedBy;
                        currScrim.ScrimPos     = "NA";

                        if (type.ProdLineTypeCode == "TPO")
                        {
                            //TODO:  Create TPOFormLineProd for this line for all products for the
                            //current plant in TPOProducts where IsRepel is false
                            //See usp_SA_LineProdFormCheck in old database
                        }

                        //TODO:  Once TPOCurrentBatch table has been created, create a new instance of that Entity here
                    }
                }
            }
            #endregion

            //Create ProductionShiftUse records for each available shift
            var prodShifts = _repository.Repository <ProductionShiftDto>().GetAllBy(s => s.PlantID == entity.PlantID).ToList();
            for (int i = 0; i < prodShifts.Count; i++)
            {
                var minutes = 0;
                if (prodShifts[i].StartTime > prodShifts[i].EndTime)
                {
                    minutes = prodShifts[i].StartTime.Subtract(prodShifts[i].EndTime).Minutes + 1440;
                }
                else
                {
                    minutes = minutes = prodShifts[i].StartTime.Subtract(prodShifts[i].EndTime).Minutes;
                }
                ProductionShiftUse use = new ProductionShiftUse()
                {
                    ShiftID     = prodShifts[i].ID,
                    PlantID     = entity.PlantID,
                    Day1Minutes = minutes,
                    Day2Minutes = minutes,
                    Day3Minutes = minutes,
                    Day4Minutes = minutes,
                    Day5Minutes = minutes,
                    Day6Minutes = minutes,
                    Day7Minutes = minutes,

                    DateEntered  = entity.DateEntered,
                    EnteredBy    = entity.EnteredBy,
                    LastModified = entity.LastModified,
                    ModifiedBy   = entity.ModifiedBy
                };
                entity.ProductionShiftUses.Add(use);

                //Need to create config line now since FK is non-nullable
                ProdLineRollConfig config = new ProdLineRollConfig()
                {
                    RollName = type.ProdLineTypeCode,
                    TypeID   = type.ID,
                    Order    = 0
                };
                entity.ProdLineRollConfig = config;
            }

            //TODO:  Create new ProdDteChng record
            ProdDateChange change = new ProdDateChange()
            {
                DateChange    = DateTime.Now,
                RotationStart = DateTime.Now,
                PlantID       = entity.PlantID,
                DateEntered   = entity.DateEntered,
                EnteredBy     = entity.EnteredBy,
                LastModified  = entity.LastModified,
                ModifiedBy    = entity.ModifiedBy
            };
            entity.ProdDateChanges.Add(change);


            try
            {
                _repository.Repository <ProdLine>().Insert(entity);
                _repository.Save();
            }
            catch (DbEntityValidationException valEx)
            {
                var sb = new StringBuilder();

                foreach (var failure in valEx.EntityValidationErrors)
                {
                    sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType());
                    foreach (var error in failure.ValidationErrors)
                    {
                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                        sb.AppendLine();
                    }
                }

                throw new DbEntityValidationException(
                          "Entity Validation Failed - errors follow:\n" +
                          sb.ToString(), valEx
                          ); // Add the original exception as the innerException
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw;
            }
            return(entity.ID);
        }
コード例 #6
0
 public void InsertTPOCurrentScrim(TPOCurrentScrim entity)
 {
     Entities.TPOCurrentScrims.Add(entity);
     Entities.SaveChanges();
 }