public ResponseResult <GridResponse <MaterialReceptionItem> > SearchCriteria(string prcOrdNo, string parDelivery, jsGrid.MVC.GridSettings gridSettings)
        {
            var result = _unitOfWork.ReceptionRepository.GetAll();

            if (!string.IsNullOrEmpty(prcOrdNo) && !string.IsNullOrEmpty(parDelivery))
            {
                result = result.Where(i => i.F30_PrcOrdNo.ToUpper().StartsWith(prcOrdNo.ToUpper()) && i.F30_PrtDvrNo.ToUpper().StartsWith(parDelivery.ToUpper()));
            }

            var itemCount = result.Count();

            OrderByAndPaging(ref result, gridSettings);

            var lstMaterialCode = result.Select(i => i.F30_MaterialCode);
            var listMaterial    = _unitOfWork.MaterialRepository.GetAll().Where(i => lstMaterialCode.Contains(i.F01_MaterialCode));
            var lstResult       = new List <MaterialReceptionItem>();

            foreach (var reception in result)
            {
                var materialReceptionItem = new MaterialReceptionItem();
                var lstMaterialItem       = listMaterial.FirstOrDefault(i => i.F01_MaterialCode == reception.F30_MaterialCode);
                if (lstMaterialItem != null)
                {
                    materialReceptionItem.Name = lstMaterialItem.F01_MaterialDsp;
                }
                materialReceptionItem.F30_PrcOrdNo       = reception.F30_PrcOrdNo;
                materialReceptionItem.F30_PrtDvrNo       = reception.F30_PrtDvrNo;
                materialReceptionItem.F30_MaterialCode   = reception.F30_MaterialCode;
                materialReceptionItem.F30_ExpectAmount   = reception.F30_ExpectAmount;
                materialReceptionItem.F30_StoragedAmount = reception.F30_StoragedAmount;
                materialReceptionItem.F30_AcceptClass    = reception.F30_AcceptClass;
                materialReceptionItem.F30_ExpectDate     = reception.F30_ExpectDate;
                lstResult.Add(materialReceptionItem);
            }
            var resultModel = new GridResponse <MaterialReceptionItem>(lstResult, itemCount);

            return(new ResponseResult <GridResponse <MaterialReceptionItem> >(resultModel, true));
        }
        public ResponseResult <jsGrid.MVC.GridResponse <SubMaterialItem> > SearchCriteria(string code,
                                                                                          jsGrid.MVC.GridSettings gridSettings)
        {
            var result = _unitOfWork.SubMaterialRepository.GetAll();

            if (!string.IsNullOrEmpty(code))
            {
                result = result.Where(i => i.F15_SubMaterialCode.ToUpper().Contains(code.ToUpper()));
            }

            var itemCount = result.Count();

            OrderByAndPaging(ref result, gridSettings);
            result = result.Skip((gridSettings.PageIndex - 1) * gridSettings.PageSize).Take(gridSettings.PageSize);
            var lstSubMaterialCode = result.Select(i => i.F15_SubMaterialCode);
            var listSubMaterial    =
                _unitOfWork.SupMaterialStockRepository.GetAll()
                .Where(i => lstSubMaterialCode.Contains(i.F46_SubMaterialCode));
            var lstResult = new List <SubMaterialItem>();

            foreach (var supMaterial in result)
            {
                var subMaterialItem = new SubMaterialItem();
                subMaterialItem.F15_SubMaterialCode = supMaterial.F15_SubMaterialCode;
                subMaterialItem.F15_MaterialDsp     = supMaterial.F15_MaterialDsp;
                subMaterialItem.F15_Unit            = supMaterial.F15_Unit;
                subMaterialItem.F15_PackingUnit     = supMaterial.F15_PackingUnit;
                var submaterial =
                    listSubMaterial.FirstOrDefault(i => i.F46_SubMaterialCode == supMaterial.F15_SubMaterialCode);
                if (submaterial != null)
                {
                    subMaterialItem.Quantity = submaterial.F46_Amount;
                    subMaterialItem.Comment  = submaterial.F46_Comment;
                }
                lstResult.Add(subMaterialItem);
            }


            var resultModel = new GridResponse <SubMaterialItem>(lstResult, itemCount);

            return(new ResponseResult <GridResponse <SubMaterialItem> >(resultModel, true));
        }
        public ResponseResult <GridResponse <ProductMasterManagementItem> > SearchCriteria(string location,
                                                                                           jsGrid.MVC.GridSettings gridSettings)
        {
            var f80Type   = Constants.TypeOfTable.CALC_TE81_TEMP.ToString("D");
            var teEnvMesp =
                _unitOfWork.EnvMespRepository.GetMany(
                    i => i.F80_Name.Trim().Equals(location.Trim()) && i.F80_Type.Equals(f80Type));

            if (!teEnvMesp.Any())
            {
                return(null);
            }

            var te85EnvProds = _unitOfWork.EnvProdRepository.GetAll();
            var products     = _unitOfWork.ProductRepository.GetAll();
            var te80EnvMesps = _unitOfWork.EnvMespRepository.GetAll();

            var lstResult = from te85EnvProd in te85EnvProds
                            from product in products
                            from te80EnvMesp in te80EnvMesps
                            where (
                te85EnvProd.F85_Code == product.F09_ProductCode &&
                te85EnvProd.F85_Type == te80EnvMesp.F80_Type &&
                te85EnvProd.F85_Id == te80EnvMesp.F80_Id &&
                te80EnvMesp.F80_Name == location
                )
                            select new ProductMasterManagementItem()
            {
                F85_Code    = te85EnvProd.F85_Code,
                F85_M_Usl   = te85EnvProd.F85_M_Usl,
                F85_M_Lsl   = te85EnvProd.F85_M_Lsl,
                F85_M_Ucl   = te85EnvProd.F85_M_Ucl,
                F85_M_Lcl   = te85EnvProd.F85_M_Lcl,
                F85_R_Usl   = te85EnvProd.F85_R_Usl,
                F85_R_Lsl   = te85EnvProd.F85_R_Lsl,
                F85_No_Lot  = te85EnvProd.F85_No_Lot,
                F85_Type    = te85EnvProd.F85_Type,
                F85_Id      = te85EnvProd.F85_Id,
                F85_From    = te85EnvProd.F85_From,
                F85_To      = te85EnvProd.F85_To,
                ProductName = product.F09_ProductDesp
            };

            var itemCount = lstResult.Count();

            OrderByAndPaging(ref lstResult, gridSettings);

            var resultModel = new GridResponse <ProductMasterManagementItem>(lstResult, itemCount);

            return(new ResponseResult <GridResponse <ProductMasterManagementItem> >(resultModel, true));
        }