protected override Expression <Func <ProductDetail, bool> > GetExpression()
        {
            if (!string.IsNullOrWhiteSpace(Keyword))
            {
                ExpressionObj = x =>
                                x.ProductCategory.Name.ToLower().Contains(Keyword) ||
                                x.Name.ToLower().Contains(Keyword) ||
                                x.BarCode.ToLower().Contains(Keyword) ||
                                x.ProductCode.ToLower().Contains(Keyword);
            }

            if (IsProductActive)
            {
                ExpressionObj = ExpressionObj.And(x => x.IsActive == IsProductActive);
            }

            if (IsFinishedProduct)
            {
                ExpressionObj = ExpressionObj.And(x => x.IsRawProduct == false);
            }

            if (ParentId.IdIsOk())
            {
                ExpressionObj = ExpressionObj.And(x => x.ProductCategoryId == ParentId);
            }

            if (OnHand > 0)
            {
                ExpressionObj = ExpressionObj.And(x => x.OnHand <= OnHand);
            }

            ExpressionObj = ExpressionObj.And(x => x.ShopId == ShopId);
            ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression());
            return(ExpressionObj);
        }
Example #2
0
        protected override Expression <Func <Purchase, bool> > GetExpression()
        {
            if (!string.IsNullOrWhiteSpace(Keyword))
            {
                ExpressionObj = x =>
                                x.OrderNumber.ToLower().Contains(Keyword) || x.ShipmentTrackingNo.ToLower().Contains(Keyword);
            }

            if (ParentId.IdIsOk())
            {
                ExpressionObj = ExpressionObj.And(x => x.SupplierId == ParentId);
            }

            if (SupplierId.IdIsOk() && SupplierId != new Guid().ToString())
            {
                ExpressionObj = ExpressionObj.And(x => x.SupplierId == SupplierId);
            }

            if (WarehouseId.IdIsOk() && WarehouseId != new Guid().ToString())
            {
                this.ExpressionObj = this.ExpressionObj.And(x => x.WarehouseId == WarehouseId);
            }

            ExpressionObj = ExpressionObj.And(x => x.ShopId == ShopId);
            ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression());
            return(ExpressionObj);
        }
Example #3
0
 protected override Expression <Func <Student, bool> > GetExpression()
 {
     if (!string.IsNullOrWhiteSpace(Keyword))
     {
         ExpressionObj = x => x.Name.ToLower().Contains(Keyword) || x.Phone.ToLower().Contains(Keyword);
     }
     if (ParentId.IdIsOk())
     {
         ExpressionObj = ExpressionObj.And(x => x.DepartmentId == ParentId);
     }
     ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression());
     return(ExpressionObj);
 }
        protected override Expression <Func <ProductSerial, bool> > GetExpression()
        {
            if (!string.IsNullOrWhiteSpace(Keyword))
            {
                ExpressionObj = x => x.SerialNumber.ToLower().Contains(Keyword);
            }

            if (ParentId.IdIsOk())
            {
                ExpressionObj = ExpressionObj.And(x => x.ProductDetailId == ParentId);
            }

            ExpressionObj = ExpressionObj.And(x => x.ShopId == ShopId);
            ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression());
            return(ExpressionObj);
        }
        protected override Expression <Func <SupplierProduct, bool> > GetExpression()
        {
            if (!string.IsNullOrWhiteSpace(Keyword))
            {
                ExpressionObj = x =>
                                x.ProductDetailId.Contains(Keyword) ||
                                x.SupplierId.Contains(Keyword);
            }

            if (ParentId.IdIsOk())
            {
                this.ExpressionObj = this.ExpressionObj.And(x => x.SupplierId == ParentId);
            }

            ExpressionObj = ExpressionObj.And(x => x.ShopId == ShopId);
            ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression());
            return(ExpressionObj);
        }
        protected override Expression <Func <Sale, bool> > GetExpression()
        {
            if (!string.IsNullOrWhiteSpace(Keyword))
            {
                ExpressionObj = x =>
                                x.OrderNumber.ToLower().Contains(Keyword) || x.OrderReferenceNumber.ToLower().Contains(Keyword) ||
                                x.CustomerPhone.ToLower().Contains(Keyword) || x.CustomerName.ToLower().Contains(Keyword);
            }

            if (this.SaleChannel != SaleChannel.All)
            {
                ExpressionObj = ExpressionObj.And(x => x.SaleChannel == this.SaleChannel);
            }

            if (this.SaleFrom != SaleFrom.All)
            {
                ExpressionObj = ExpressionObj.And(x => x.SaleFrom == this.SaleFrom);
            }

            if (this.OrderState != All)
            {
                OrderState state = (OrderState)Enum.Parse(typeof(OrderState), this.OrderState);
                ExpressionObj = ExpressionObj.And(x => x.OrderState == state);
            }

            if (!string.IsNullOrWhiteSpace(DeliverymanId))
            {
                this.ExpressionObj = this.ExpressionObj.And(x => x.DeliverymanId == DeliverymanId);
            }

            if (!string.IsNullOrWhiteSpace(Thana) && Thana != All)
            {
                this.ExpressionObj = this.ExpressionObj.And(x => x.Address.Thana == Thana);
            }

            this.ExpressionObj = this.ExpressionObj.And(x => x.IsDealerSale == this.IsDealerSale);

            if (OnlyDues)
            {
                this.ExpressionObj =
                    this.ExpressionObj.And(x => x.DueAmount >= 1 && x.OrderState != Model.OrderState.Cancel);
            }

            if (IsDealerSale)
            {
                if (ParentId.IdIsOk())
                {
                    this.ExpressionObj = this.ExpressionObj.And(x => x.DealerId == ParentId);
                }
            }
            else
            {
                if (ParentId.IdIsOk())
                {
                    this.ExpressionObj = this.ExpressionObj.And(x => x.CustomerId == ParentId);
                }
            }

            if (SalesmanId.IdIsOk())
            {
                this.ExpressionObj = this.ExpressionObj.And(x => x.EmployeeInfoId == SalesmanId);
            }

            if (WarehouseId.IdIsOk() && WarehouseId != new Guid().ToString())
            {
                this.ExpressionObj = this.ExpressionObj.And(x => x.WarehouseId == WarehouseId);
            }

            //if (WarehouseId == new Guid().ToString())
            //{
            //    this.ExpressionObj = this.ExpressionObj.And(x => x.WarehouseId == null);
            //}


            this.ExpressionObj = this.ExpressionObj.And(x => x.IsTaggedSale == IsTaggedSale);
            if (IsTaggedSale)
            {
                this.ExpressionObj = this.ExpressionObj.And(x => x.SaleTag == SaleTag);
            }


            ExpressionObj = ExpressionObj.And(x => x.ShopId == ShopId);
            ExpressionObj = ExpressionObj.And(GenerateBaseEntityExpression());

            if (!string.IsNullOrWhiteSpace(DateSearchColumn))
            {
                switch (DateSearchColumn)
                {
                case "Created":
                    ExpressionObj = ExpressionObj.And(x => DbFunctions.TruncateTime(x.Created) >= StartDate && DbFunctions.TruncateTime(x.Created) <= EndDate);
                    break;

                case "OrderDate":
                    ExpressionObj = ExpressionObj.And(x => DbFunctions.TruncateTime(x.OrderDate) >= StartDate && DbFunctions.TruncateTime(x.OrderDate) <= EndDate);
                    break;

                case "DeliveryDate":
                    ExpressionObj = ExpressionObj.And(x => DbFunctions.TruncateTime(x.RequiredDeliveryDateByCustomer) >= StartDate && DbFunctions.TruncateTime(x.RequiredDeliveryDateByCustomer) <= EndDate);
                    break;

                default:
                    ExpressionObj = ExpressionObj.And(x => DbFunctions.TruncateTime(x.Modified) >= StartDate && DbFunctions.TruncateTime(x.Modified) <= EndDate);
                    break;
                }
            }

            return(ExpressionObj);
        }