Пример #1
0
        public IQueryable <ComboBoxResult> GetCustomProducts(int Id, string term)
        {
            var SaleOrder = new SaleOrderHeaderService(_unitOfWork).Find(Id);

            var settings = new SaleOrderSettingsService(_unitOfWork).GetSaleOrderSettings(SaleOrder.DocTypeId, SaleOrder.DivisionId, SaleOrder.SiteId);

            string[] ProductTypes = null;
            if (!string.IsNullOrEmpty(settings.filterProductTypes))
            {
                ProductTypes = settings.filterProductTypes.Split(",".ToCharArray());
            }
            else
            {
                ProductTypes = new string[] { "NA" };
            }

            string[] Products = null;
            if (!string.IsNullOrEmpty(settings.filterProducts))
            {
                Products = settings.filterProducts.Split(",".ToCharArray());
            }
            else
            {
                Products = new string[] { "NA" };
            }

            string[] ProductGroups = null;
            if (!string.IsNullOrEmpty(settings.filterProductGroups))
            {
                ProductGroups = settings.filterProductGroups.Split(",".ToCharArray());
            }
            else
            {
                ProductGroups = new string[] { "NA" };
            }

            return(from p in db.Product
                   where (string.IsNullOrEmpty(settings.filterProductTypes) ? 1 == 1 : ProductTypes.Contains(p.ProductGroup.ProductTypeId.ToString())) &&
                   (string.IsNullOrEmpty(settings.filterProducts) ? 1 == 1 : Products.Contains(p.ProductId.ToString())) &&
                   (string.IsNullOrEmpty(settings.filterProductGroups) ? 1 == 1 : ProductGroups.Contains(p.ProductGroupId.ToString())) &&
                   (string.IsNullOrEmpty(term) ? 1 == 1 : p.ProductName.ToLower().Contains(term.ToLower()))
                   orderby p.ProductName
                   select new ComboBoxResult
            {
                id = p.ProductId.ToString(),
                text = p.ProductName,
            });
        }
Пример #2
0
        public string GetBuyerSKU(int ProductId, int SaleOrderHEaderId)
        {
            int BuyerID = new SaleOrderHeaderService(_unitOfWork).Find(SaleOrderHEaderId).SaleToBuyerId;

            string BuyerSku = (from p in db.ProductBuyer
                               where p.BuyerId == BuyerID && p.ProductId == ProductId
                               select p.BuyerSku
                               ).FirstOrDefault();

            if (BuyerSku == null)
            {
                BuyerSku = "";
            }

            return(BuyerSku);
        }