Exemple #1
0
        public ActionResult Create(ScrimRollModel model)
        {
            if (ModelState.IsValid)
            {
                var dto = Mapper.Map <ScrimRollModel, ScrimRollDto>(model);
                dto.EnteredBy    = CurrentUser;
                dto.ModifiedBy   = CurrentUser;
                dto.DateEntered  = DateTime.Now;
                dto.LastModified = DateTime.Now;
                //dto.DateReceived = date ?? DateTime.Now;
                using (var service = new ScrimRollService())
                {
                    service.Add(dto);
                }

                SetResponseMesssage(ActionTypeMessage.SuccessfulSave);

                return(RedirectToAction("Details", new { id = model.Id }));
            }
            else
            {
                ////  ModelState.AddModelError(string.Empty, "Please enter required fields.");

                GetRollTypesList();
                //GetUoMList();

                return(View(model));
            }
        }
Exemple #2
0
        public ActionResult Edit(DateTime?date, DateTime?wovendate, int id, ScrimRollModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError(string.Empty, "Please enter required fields.");
                GetRollTypesList();
                //GetUoMList();

                return(View(model));
            }
            var dto = Mapper.Map <ScrimRollModel, ScrimRollDto>(model);

            dto.EnteredBy    = CurrentUser;
            dto.ModifiedBy   = CurrentUser;
            dto.DateEntered  = DateTime.Now;
            dto.LastModified = DateTime.Now;
            dto.DateReceived = date ?? DateTime.Now;
            dto.WovenDate    = wovendate ?? DateTime.Now;
            //ScrimRoll bl = new ScrimRoll();
            //bl.UpdateScrimRoll(model);
            using (var service = new ScrimRollService())
            {
                service.Update(dto);
            }
            // TempData["ActionMessage"] = Responses.ResponseMessages["SuccessfulSave"];
            //TempData["ActionMessageType"] = Responses.ResponseTypes["success"];
            return(RedirectToAction("Details", new { id = model.Id }));
        }
        public ActionResult Create(DateTime?date, ScrimRollModel model)
        {
            if (date == null)
            {
                ModelState.AddModelError(string.Empty, "The Received Date field is required");
            }
            if (ModelState.IsValid)
            {
                ScrimRoll bl = new ScrimRoll();
                model.EnteredBy    = CurrentUser;
                model.ModifiedBy   = CurrentUser;
                model.DateEntered  = DateTime.Now;
                model.LastModified = DateTime.Now;
                model.DateReceived = date ?? DateTime.Now;
                model = bl.InsertScrimRoll(model);
                TempData["ActionMessage"]     = TPO.BL.Repositories.Message.MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave);
                TempData["ActionMessageType"] = TPO.BL.Repositories.Message.MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess);

                return(RedirectToAction("Details", new { id = model.ID }));
                //return RedirectToAction("Edit", new { id = model.ID });
            }
            else
            {
                //  ModelState.AddModelError(string.Empty, "Please enter required fields.");
                GetRollTypesList();
                GetUoMList();

                return(View(model));
            }
        }
Exemple #4
0
        //
        // GET: /ScrimRoll/Edit/5
        public ActionResult Edit(int id = 0)
        {
            if (id == 0)
            {
                ////removed to keep from initial load of scrim page from displaying error.
                ////TempData["ActionMessage"] = Responses.ResponseMessages["FailNoId"];
                ////TempData["ActionMessageType"] = Responses.ResponseTypes["error"];
                return(RedirectToAction("Details"));
            }
            GetRollTypesList();
            //GetUoMList();
            //ScrimRoll bl = new ScrimRoll();
            //ViewBag.ScrimRoll = bl.GetScrimRollModels();
            //ScrimRollModel model = bl.GetScrimRollModelByID(id);
            ScrimRollModel model;

            using (var service = new ScrimRollService())
            {
                model = Mapper.Map <ScrimRollDto, ScrimRollModel>(service.Get(id));
            }

            if (model == null)
            {
                model = new ScrimRollModel();
            }

            return(View(model));
        }
        //
        // GET: /ScrimRoll/Create
        public ActionResult Create()
        {
            GetRollTypesList();
            GetUoMList();
            ScrimRollModel model = new ScrimRollModel();

            return(View(model));
        }
Exemple #6
0
        //
        // GET: /ScrimRoll/Create
        public ActionResult Create()
        {
            GetRollTypesList();
            //GetUoMList();
            ViewBag.LengthUoM = GetLengthUoMOptions();
            ViewBag.WeightUoM = GetWeightUoMOptions();
            ScrimRollModel model = new ScrimRollModel();

            return(View(model));
        }
        public ScrimRollModel InsertScrimRoll(ScrimRollModel model)
        {
            ScrimRollModel returnModel = null;

            using (ScrimRepository repo = new ScrimRepository())
            {
                TPO.DL.Models.ScrimRoll entity = Bind(model, new TPO.DL.Models.ScrimRoll());
                repo.InsertScrimRoll(entity);
                returnModel = Bind(entity, new ScrimRollModel());
            }
            return(returnModel);
        }
 public void UpdateScrimRoll(ScrimRollModel model)
 {
     using (ScrimRepository repo = new ScrimRepository())
     {
         TPO.DL.Models.ScrimRoll entity = repo.GetScrimRollByID(model.ID);
         if (entity != null)
         {
             entity = Bind(model, entity);
             repo.SaveChanges();
         }
     }
 }
        public ScrimRollModel GetScrimRollModelByID(int id)
        {
            ScrimRollModel model = null;

            using (ScrimRepository repo = new ScrimRepository())
            {
                TPO.DL.Models.ScrimRoll entity = repo.GetScrimRollByID(id);
                if (entity != null)
                {
                    model = Bind(entity, new ScrimRollModel());
                }
            }
            return(model);
        }
        public ActionResult ScrimRollAjaxCreate(string id)
        {
            dynamic d = JObject.Parse(id);

            ScrimRollModel model = new ScrimRollModel();
            ScrimRoll      bl    = new ScrimRoll();

            if (d["ID"] != null)
            {
                model.ID = d["ID"];
            }

            model.ScrimRollCode   = d["ScrimRollCode"]; //required
            model.ScrimRollTypeID = d["ScrimRollTypeID"];
            model.Length          = d["Length"];
            model.DateReceived    = d["DateReceived"]; //required
            model.ReceivedLength  = d["ReceivedLength"];


            // TODO: set values
            model.WeightUnitOfMeasureID = 1; //required
            model.LengthUnitOfMeasureID = 1; //required

            //model.LotCode = string.Empty;
            //model.WovenLotCode = string.Empty;
            //model.Weight = 0;
            //model.TareWeight = 0;
            //model.ReceivedWeight = 0;
            //model.ReceivedTareWeight = 0;
            //model.LengthUsed = 0;
            //model.WeightUsed = 0;

            model.EnteredBy    = CurrentUser;
            model.ModifiedBy   = CurrentUser;
            model.DateEntered  = DateTime.Now;
            model.LastModified = DateTime.Now;


            if (model.ID == -1)
            {
                model = bl.InsertScrimRoll(model);
            }
            else
            {
                bl.UpdateScrimRoll(model);
            }

            return(RedirectToAction("Details"));
        }
        private static TPO.DL.Models.ScrimRoll Bind(ScrimRollModel model, TPO.DL.Models.ScrimRoll to)
        {
            to.Code = model.ScrimRollCode;
            //to.PlantID = model.PlantID;

            //TODO:  Implement retrieving PlantID
            to.PlantID = 1;
            if (model.ScrimRollTypeID != ScrimRollModel.INVALID_ID)
            {
                to.TypeID = model.ScrimRollTypeID;
            }
            else
            {
                to.TypeID = null;
            }
            to.WeightUoMID = model.WeightUnitOfMeasureID;
            to.LengthUoMID = model.LengthUnitOfMeasureID;
            if (model.WovenDate != DateTime.MinValue)
            {
                to.WovenDate = model.WovenDate;
            }
            else
            {
                to.WovenDate = null;
            }
            to.DateReceived       = model.DateReceived;
            to.Length             = (double)model.Length;
            to.Weight             = (double)model.Weight;
            to.TareWeight         = (double)model.TareWeight;
            to.ReceivedLength     = (double)model.ReceivedLength;
            to.ReceivedWeight     = (double)model.ReceivedWeight;
            to.ReceivedTareWeight = (double)model.ReceivedTareWeight;
            to.LengthUsed         = (double)model.LengthUsed;
            to.WeightUsed         = (double)model.WeightUsed;

            to.DateEntered  = (DateTime)model.DateEntered;
            to.EnteredBy    = (string)model.EnteredBy;
            to.ModifiedBy   = (string)model.ModifiedBy;
            to.LastModified = (DateTime)model.LastModified;

            to.WovenLotNumber = model.WovenLotCode;

            return(to);
        }
        public ActionResult Edit(DateTime?date, int id, ScrimRollModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError(string.Empty, "Please enter required fields.");
                GetRollTypesList();
                GetUoMList();

                return(View(model));
            }

            model.EnteredBy    = CurrentUser;
            model.ModifiedBy   = CurrentUser;
            model.DateEntered  = DateTime.Now;
            model.LastModified = DateTime.Now;
            model.DateReceived = date ?? DateTime.Now;
            ScrimRoll bl = new ScrimRoll();

            bl.UpdateScrimRoll(model);
            TempData["ActionMessage"]     = TPO.BL.Repositories.Message.MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave);
            TempData["ActionMessageType"] = TPO.BL.Repositories.Message.MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess);
            return(RedirectToAction("Details", new { id = model.ID }));
        }
        //
        // GET: /ScrimRoll/Edit/5
        public ActionResult Edit(int id = 0)
        {
            if (id == 0)
            {
                //removed to keep from initial load of scrim page from displaying error.
                //TempData["ActionMessage"] = TPO.BL.Constants.Responses.ResponseMessages["FailNoId"];
                //TempData["ActionMessageType"] = TPO.BL.Constants.Responses.ResponseTypes["error"];
                return(RedirectToAction("Details"));
            }
            GetRollTypesList();
            GetUoMList();
            ScrimRoll bl = new ScrimRoll();

            ViewBag.ScrimRoll = bl.GetScrimRollModels();
            ScrimRollModel model = bl.GetScrimRollModelByID(id);

            if (model == null)
            {
                model = new ScrimRollModel();
            }

            return(View(model));
        }
Exemple #14
0
        public JsonResult AjaxUpdateScrimRoll(ScrimRollModel model)
        {
            var dto = Mapper.Map <ScrimRollModel, ScrimRollDto>(model);

            dto.ModifiedBy   = CurrentUser;
            dto.LastModified = DateTime.Now;

            using (ScrimRollService svc = new ScrimRollService())
            {
                if (dto.ID > 0)
                {
                    svc.Update(dto);
                }
                else
                {
                    dto.EnteredBy   = CurrentUser;
                    dto.DateEntered = DateTime.Now;
                    dto.PlantID     = CurrentPlantId;
                    dto.ID          = svc.Add(dto);
                }
            }
            model = Mapper.Map <ScrimRollDto, ScrimRollModel>(dto);
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        private static ScrimRollModel Bind(TPO.DL.Models.ScrimRoll entity, ScrimRollModel to)
        {
            to.ID                    = entity.ID;
            to.ScrimRollCode         = entity.Code;
            to.PlantID               = entity.PlantID;
            to.ScrimRollTypeID       = entity.TypeID.HasValue ? entity.TypeID.Value : ScrimRollModel.INVALID_ID;
            to.WeightUnitOfMeasureID = entity.WeightUoMID;
            to.LengthUnitOfMeasureID = entity.LengthUoMID;
            to.WovenDate             = entity.WovenDate.HasValue ? entity.WovenDate.Value : DateTime.MinValue;
            to.DateReceived          = entity.DateReceived;
            to.Length                = (decimal)entity.Length;
            to.Weight                = (decimal)entity.Weight;
            to.TareWeight            = (decimal)entity.TareWeight;
            to.ReceivedLength        = (decimal)entity.ReceivedLength;
            to.ReceivedWeight        = (decimal)entity.ReceivedWeight;
            to.ReceivedTareWeight    = (decimal)entity.ReceivedTareWeight;
            to.LengthUsed            = (decimal)entity.LengthUsed;
            to.WeightUsed            = (decimal)entity.WeightUsed;

            to.WovenLotCode = entity.WovenLotNumber;
            to.WovenDate    = entity.WovenDate ?? DateTime.MinValue;

            return(to);
        }
Exemple #16
0
        public JsonResult ScrimRollAjaxCreate(string id)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                ScrimRollService srsrv = new ScrimRollService();

                ScrimRollModel model = JsonConvert.DeserializeObject <ScrimRollModel>(id);
                if (model != null)
                {
                    var x = srsrv.GetAll().Where(q => q.Code == model.Code).ToList();

                    if (!x.Any())
                    {
                        ScrimRollDto dto = new ScrimRollDto();

                        using (ScrimRollService service = new ScrimRollService())
                        {
                            Mapper.Map(model, dto);

                            dto.WovenDate = null;

                            dto.PlantID      = CurrentPlantId;
                            dto.LastModified = DateTime.Now;
                            dto.ModifiedBy   = CurrentUser;


                            if (model.Id > 0)
                            {
                                service.Update(dto);
                            }
                            else
                            {
                                dto.DateEntered = dto.LastModified;
                                dto.EnteredBy   = CurrentUser;
                                service.Add(dto);
                            }
                        }
                    }
                    else
                    {
                        ScrimRollDto dto = new ScrimRollDto();

                        using (ScrimRollService service = new ScrimRollService())
                        {
                            Mapper.Map(model, dto);

                            dto.WovenDate = null;

                            dto.PlantID      = CurrentPlantId;
                            dto.LastModified = DateTime.Now;
                            dto.ModifiedBy   = CurrentUser;
                            dto.DateEntered  = DateTime.Now;
                            dto.EnteredBy    = CurrentUser;

                            service.Update(dto);
                        }
                    }
                }

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

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }