Пример #1
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);
        }
Пример #2
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));
        }