示例#1
0
        public JsonResult RawMaterialAjaxDelete(string id)
        {
            ResponseMessage responseMessage;

            try
            {
                TPOCurrentRawMaterial tpoCurrentRawMaterial = JsonConvert.DeserializeObject <TPOCurrentRawMaterial>(id);
                if (tpoCurrentRawMaterial != null)
                {
                    TPOCurrentRawMaterialDto dto = new TPOCurrentRawMaterialDto();
                    using (TPOCurrentRawMaterialService service = new TPOCurrentRawMaterialService())
                    {
                        Mapper.Map(tpoCurrentRawMaterial, dto);
                        if (tpoCurrentRawMaterial.ID > 0)
                        {
                            service.Delete(dto.ID);
                        }
                    }
                }

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

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public List <TPOCurrentRawMaterialDto> GetRawMaterailListing(int lineId)
        {
            List <TPOCurrentRawMaterialDto> currentRawMaterials;

            if (lineId != 0)
            {
                TPOCurrentRawMaterialService bl = new TPOCurrentRawMaterialService();
                currentRawMaterials = bl.GetAll().Where(q => q.LineID == lineId).ToList();
            }
            else
            {
                currentRawMaterials = new List <TPOCurrentRawMaterialDto>();
            }

            return(currentRawMaterials);
        }
示例#3
0
        public JsonResult GridByType(int lineID, int?rows, int?page)
        {
            rows = rows ?? DefaultPageSize;
            page = page ?? DefaultPage;

            int lineDescription;

            List <CurrentScrimViewModel>    list          = new List <CurrentScrimViewModel>();
            List <TPOCurrentRawMaterialDto> materialslist = new List <TPOCurrentRawMaterialDto>();

            if (lineID != null)
            {
                using (var service = new ProductionLineService())
                {
                    lineDescription = service.Get(lineID).ID;
                }

                using (var service = new TPOCurrentRawMaterialService())
                {
                    materialslist = service.GetAll().Where(q => q.LineID == lineDescription).ToList();
                }

                foreach (var dto in materialslist)
                {
                    RawMaterialReceivedDto rawMaterialReceivedDto = new RawMaterialReceivedDto();
                    RawMaterialDto         rawMaterialDto         = new RawMaterialDto();

                    CurrentScrimViewModel csvm = new CurrentScrimViewModel();

                    csvm.Id      = dto.ID;
                    csvm.PlantId = CurrentPlantId;

                    using (var service = new RawMaterialReceivedService())
                    {
                        rawMaterialReceivedDto = service.Get(dto.RawMaterialReceivedID ?? 0);
                        csvm.LotNumber         = rawMaterialReceivedDto.LotNumber;
                        csvm.RawMaterialID     = rawMaterialReceivedDto.Id;
                    }

                    using (var service = new RawMaterialService())
                    {
                        rawMaterialDto       = service.Get(Convert.ToInt32(rawMaterialReceivedDto.RawMaterialId));
                        csvm.RawMaterialCode = rawMaterialDto.Code;
                    }

                    csvm.EnteredBy    = dto.EnteredBy;
                    csvm.ModifiedBy   = dto.ModifiedBy;
                    csvm.DateEntered  = dto.DateEntered;
                    csvm.LastModified = dto.LastModified;

                    list.Add(csvm);
                }
            }

            int total;

            total = list.Count();
            List <CurrentScrimViewModel> currentPageDtos = new List <CurrentScrimViewModel>();

            if (rows.HasValue)
            {
                currentPageDtos.AddRange(list.OrderByDescending(r => r.DateEntered).Skip((page.Value - 1) * rows.Value).Take(rows.Value).ToList());
            }
            else
            {
                currentPageDtos.AddRange(list);
            }

            return(BuildJsonResult(currentPageDtos, total));
        }
示例#4
0
        public JsonResult CurrentScrimAjaxCreate(string id, int lineId)
        {
            ResponseMessage responseMessage;

            try
            {
                CurrentScrimViewModel currentSrimViewModel = JsonConvert.DeserializeObject <CurrentScrimViewModel>(id);

                if (currentSrimViewModel != null)
                {
                    TPOCurrentRawMaterialDto tpoCurrentRawMaterialdto = new TPOCurrentRawMaterialDto();

                    if (currentSrimViewModel.Id > 0)
                    {
                        using (TPOCurrentRawMaterialService service = new TPOCurrentRawMaterialService())
                        {
                            tpoCurrentRawMaterialdto = service.Get(currentSrimViewModel.Id);
                        }

                        using (RawMaterialReceivedService service = new RawMaterialReceivedService())
                        {
                            RawMaterialReceivedDto rawMaterialDto = new RawMaterialReceivedDto();
                            rawMaterialDto =
                                service.GetAll()
                                .Where(q => q.Id == Convert.ToInt32(currentSrimViewModel.LotNumber))
                                .ToList()
                                .FirstOrDefault();

                            tpoCurrentRawMaterialdto.RawMaterialReceivedID = rawMaterialDto.Id;
                        }
                    }
                    else
                    {
                        tpoCurrentRawMaterialdto.PlantID = CurrentPlantId;

                        using (ProductionLineService service = new ProductionLineService())
                        {
                            tpoCurrentRawMaterialdto.LineID = service.Get(lineId).ID;
                        }

                        using (RawMaterialReceivedService service = new RawMaterialReceivedService())
                        {
                            RawMaterialReceivedDto rawMaterialDto = new RawMaterialReceivedDto();
                            rawMaterialDto =
                                service.GetAll()
                                .Where(q => q.Id == Convert.ToInt32(currentSrimViewModel.LotNumber))
                                .ToList()
                                .FirstOrDefault();

                            tpoCurrentRawMaterialdto.RawMaterialReceivedID = rawMaterialDto.Id;
                        }
                    }

                    using (TPOCurrentScrimService service = new TPOCurrentScrimService())
                    {
                        if (currentSrimViewModel.Id > 0)
                        {
                            service.UpdateTPOCurrentRawMaterial(tpoCurrentRawMaterialdto);
                        }
                        else
                        {
                            service.AddTPOCurrentRawMaterial(tpoCurrentRawMaterialdto);
                        }
                    }
                }
                responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave);
            }
            catch (Exception exc)
            {
                responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message);
            }

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