示例#1
0
        // Add aditional results to the search
        public void SearchItem(ItemRequest request, ItemResponse response)
        {
            var maximunResultRows = Convert.ToInt32(Resources.MaximunSearchResults);

            // Apply the search with the pattern given
            var searchResults = Asgard._Foreing.INV_INVENTARIO
                .Where(x => x.INV_Nombre.ToUpper().Contains(request.SearchItemQuery.ToUpper()) ||
                            x.INV_Codigo.ToUpper().Contains(request.SearchItemQuery.ToUpper()))
                            .OrderBy(y => y.INV_Nombre)
                            .Take(maximunResultRows).ToList();

            // Fill the response with the result found
            foreach (var item in searchResults)
            {
                // Check if the item is already binded
                var bindedItem = response.ItemList.Where(x => x.Code == item.INV_Codigo).FirstOrDefault();
                if (bindedItem == null)
                {
                    // Add item to response
                    var itemDto = new ItemDto
                    {
                        Code = item.INV_Codigo.Trim(),
                        Name = item.INV_Nombre.Trim(),
                        Cost = item.INV_Costo,
                        Price = new decimal(item.INV_Precio),
                        Stocks = new Collection<StockDto>()
                    };
                    // Todo Give a real value of the quantity in stocks
                    itemDto.Stocks.Add(new StockDto { Quantity = item.INV_Disponible });
                    response.ItemList.Add(itemDto);
                }
                else
                {
                    // Update item in response
                    bindedItem.Name = item.INV_Nombre.Trim();
                    bindedItem.Cost = item.INV_Costo;
                    bindedItem.Stocks = new Collection<StockDto>();
                    bindedItem.Stocks.Add(new StockDto { Quantity = item.INV_Disponible });
                }
            }
        }
示例#2
0
        private void FixupItem(ItemDto previousValue)
        {
            if (previousValue != null && previousValue.BudgetRequestDetails.Contains(this))
            {
                previousValue.BudgetRequestDetails.Remove(this);
            }

            if (Item != null)
            {
                if (!Item.BudgetRequestDetails.Contains(this))
                {
                    Item.BudgetRequestDetails.Add(this);
                }
                if (ItemId != Item.Id)
                {
                    ItemId = Item.Id;
                }
            }
        }
示例#3
0
 private void LoadItem(ItemDto item)
 {
     if (item != null)
     {
         viewResources.SetRowCellValue(viewResources.FocusedRowHandle, viewResources.Columns["Code"], item.Code);
         viewResources.SetRowCellValue(viewResources.FocusedRowHandle, viewResources.Columns["Name"], item.Name);
         viewResources.SetRowCellValue(viewResources.FocusedRowHandle, viewResources.Columns["Cost"], item.Cost);
     }
 }