コード例 #1
0
        public ActionResult AjaxTypeUpdate(string row)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                ScrimTypeModel scrimType = JsonConvert.DeserializeObject <ScrimTypeModel>(row);
                if (scrimType != null)
                {
                    scrimType.LastModified = DateTime.Now;
                    ScrimTypeDto dto = new ScrimTypeDto();
                    using (ScrimTypeService service = new ScrimTypeService())
                    {
                        Mapper.Map(scrimType, dto);
                        if (scrimType.ID > 0)
                        {
                            service.Update(dto);
                        }
                        else
                        {
                            dto.PlantID = CurrentPlantId;
                            service.Add(dto);
                        }
                    }
                }

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

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public JsonResult AjaxTypeDelete(string row)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                ScrimTypeModel scrimType = JsonConvert.DeserializeObject <ScrimTypeModel>(row);
                if (scrimType != null)
                {
                    ScrimTypeDto dto = new ScrimTypeDto();
                    using (ScrimTypeService service = new ScrimTypeService())
                    {
                        Mapper.Map(scrimType, dto);
                        if (scrimType.ID > 0)
                        {
                            service.Delete(dto.ID);
                        }
                    }
                }

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

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetScrimTypeList()
        {
            var scrimTypes = new List <ScrimTypeModel>();

            using (var svc = new ScrimTypeService())
            {
                var dtos = svc.GetAllByPlantId(CurrentPlantId, false);
                scrimTypes.AddRange(Mapper.Map <List <ScrimTypeDto>, List <ScrimTypeModel> >(dtos));
            }
            return(Json(scrimTypes, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public JsonResult GetAllScrimTypeResult(bool isLiner)
        {
            List <ScrimTypeModel> scrimTypes = new List <ScrimTypeModel>();

            using (ScrimTypeService svc = new ScrimTypeService())
            {
                var dtos = svc.GetAllByPlantId(CurrentPlantId, isLiner);
                scrimTypes.AddRange(Mapper.Map <List <ScrimTypeDto>, List <ScrimTypeModel> >(dtos));
            }
            return(Json(scrimTypes, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public JsonResult GetScrimTypeResult()
        {
            List <ScrimTypeModel> model = new List <ScrimTypeModel>();

            using (ScrimTypeService svc = new ScrimTypeService())
            {
                var dtos = svc.GetAll();
                model.AddRange(Mapper.Map <List <ScrimTypeDto>, List <ScrimTypeModel> >(dtos));
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        private double GetArea(decimal length, decimal width)
        {
            string  areaUnitCode    = ScrimType.AreaUoM.Substring(2);
            int     areaUoMID       = GetUnitOfMeasure(areaUnitCode).Id;
            decimal convertedLength = Convert(length, ScrimRoll.LengthUoMID, areaUoMID);
            decimal convertedWidth  = Convert(width, ScrimType.WidthUoMID, areaUoMID);

            using (ScrimTypeService service = new ScrimTypeService())
            {
                return((double)(convertedLength * convertedWidth));
            }
        }
コード例 #7
0
        private double GetArea()
        {
            string  areaUnitCode = AreaUoM.Substring(2);
            int     areaUoMID    = (new UnitOfMeasureService().GetByCode(areaUnitCode)).ID;
            decimal length       = Convert(Length, LengthUoMID, areaUoMID);
            decimal width        = Convert(Width, WidthUoMID, areaUoMID);

            using (ScrimTypeService service = new ScrimTypeService())
            {
                return((double)(length * width));
            }
        }
コード例 #8
0
        private void GetRollTypesList()
        {
            List <ScrimTypeDto> dtos = new List <ScrimTypeDto>();

            using (ScrimTypeService service = new ScrimTypeService())
            {
                dtos.AddRange(service.GetAll());
            }
            ViewBag.ScrimType = new SelectList(dtos.Select(s => new
            {
                ID          = s.ID,
                Description = string.Format("{0} | {1}", s.Code, s.Description)
            }).ToList(), "ID", "Description");
            // return RedirectToAction("Details", new { id = model.Id });
        }
コード例 #9
0
 //private Dictionary<int, ScrimTypeModel> _scrimTypes = new Dictionary<int, ScrimTypeModel>();
 private ScrimTypeModel GetScrimType(int typeId)
 {
     //if (!_scrimTypes.ContainsKey(typeId))
     {
         ScrimTypeModel type = null;
         using (ScrimTypeService service = new ScrimTypeService())
         {
             var dto = service.Get(typeId);
             type = Mapper.Map <ScrimTypeDto, ScrimTypeModel>(dto);
             //_scrimTypes.Add(typeId, type);
         }
         return(type);
     }
     //return _scrimTypes[typeId];
 }
コード例 #10
0
        protected void CalcArea()
        {
            int areaUoMId = 0;

            using (ScrimTypeService service = new ScrimTypeService())
            {
                _area = 0.0;
                ScrimTypeDto dto = service.Get(TypeID);
                _area     = (double)Length * dto.Width;
                areaUoMId = dto.AreaUoMID;
            }
            using (UnitOfMeasureService service = new UnitOfMeasureService())
            {
                _areaUom = service.Get(areaUoMId).Code;
            }
        }
コード例 #11
0
        ////needs work
        //public CurrentScrimViewModel CurrentScrimViewModelViewModel_Get(int? ID)
        //{
        //    ScrimTypeService scrimTypeBL = new ScrimTypeService();
        //    List<ScrimTypeDto> scrimTypes = scrimTypeBL.GetAll();
        //    scrimTypes.Insert(0, new ScrimTypeDto() { Code = "N/A" });
        //    GetRollTypesList();
        //    ViewBag.ScrimRoll = new SelectList(new List<TPOCurrentScrimModel>());

        //    ProductionLineService prodLineBL = new ProductionLineService();
        //    List<ProductionLinesDto> lines = prodLineBL.GetAll();
        //    ViewBag.ProductionLine = new SelectList(lines, "Code", "Code");

        //    TPOCurrentScrimService bl = new TPOCurrentScrimService();

        //    CurrentScrimViewModel model = new CurrentScrimViewModel();

        //    TPOCurrentScrimDto tpoCurrentModel = bl.Get(ID != null ? ID.Value : 0);

        //    if (tpoCurrentModel == null)
        //    {
        //        tpoCurrentModel = new TPOCurrentScrimDto();
        //        model.TPOCurrentScrim = tpoCurrentModel;
        //    }
        //    else
        //    {
        //        model.TPOCurrentScrim = tpoCurrentModel;
        //    }
        //    model.LineID = ID.ToString();



        //    // TODO: refactor this area



        //    //List<TPOCurrentRawMaterialDto> currentDTOList = GetRawMaterailListing(model.LineID);

        //    //if (!currentDTOList.Any())
        //    //{
        //    //    currentDTOList = new List<TPOCurrentRawMaterialDto>();
        //    //    model.CurrentRawMaterialList = currentDTOList;
        //    //}
        //    //else
        //    //{
        //    //    model.CurrentRawMaterialList = currentDTOList;
        //    //}

        //    //if (!model.CurrentRawMaterialList.Any())
        //    //{
        //    //    model.CurrentRawMaterial = new TPOCurrentRawMaterialDto();



        //    //    // TODO: Refactor this area


        //    //    //model.CurrentRawMaterial.LineID = "1";
        //    //    //model.TPOCurrentScrim.LineID = "1";
        //    //}
        //    //else
        //    //{
        //    //    model.CurrentRawMaterialList = currentDTOList;
        //    //}

        //    return model;
        //}

        private void GetRollTypesList()
        {
            ScrimTypeService stBL = new ScrimTypeService();

            ViewBag.ScrimType = new SelectList(stBL.GetAll().Select(s => new { ID = s.ID, Description = string.Format("{0} | {1}", s.Code, s.Description) }).ToList(), "ID", "Description");
        }