Esempio n. 1
0
        void RunSetup()
        {
            using (IContainer container = NestedContainer)
            {
                IDiscountProWorkflow _discountProService = Using<IDiscountProWorkflow>(container);

                IProductRepository _productService = Using<IProductRepository>(container);
                AllProducts.Clear();
                Products.Clear();
                var product = new POLineItemProductLookupItem()
                                  {
                                      ProductId = Guid.Empty,
                                      ProductDesc =GetLocalText("sl.order.addlineitems.modal.selectProduct"),
                                      /*"--Please Select a Product--",*/
                                      ProductCode = " "
                                  };
                Products.Add(product);
                SelectedProduct = product;

                AllProducts = _productService.GetAll().ToList();
                var allproduct =
                    AllProducts.Where(n => n is ConsolidatedProduct || n is SaleProduct).OrderBy(o => o.Description);
                allproduct.Where(n => !_discountProService.IsProductFreeOfCharge(n.Id)).ToList().ForEach(
                    n => Products.Add(new POLineItemProductLookupItem
                                          {
                                              ProductId = n.Id,
                                              ProductDesc = n.Description,
                                              ProductCode = n.ProductCode
                                          }));
            }
        }
Esempio n. 2
0
        public void Setup(bool loadForEditing = false, Guid? productId = null)
        {
            using (StructureMap.IContainer cont = NestedContainer)
            {
                //SellInUnits = true;
                Products.Clear();
                AvailableInventory.Clear();
                var product = new POLineItemProductLookupItem
                                  {
                                      ProductId = Guid.Empty,
                                      ProductDesc = "--Please Select a Product--"
                                  };
                Products.Add(product);
                SelectedProduct = product;
                if (loadForEditing)
                {
                    var editproduct = Using<IProductRepository>(cont).GetById(productId.Value);
                    LoadedProducts = new List<Product> {editproduct};
                    Products.Add(new POLineItemProductLookupItem
                                     {
                                         ProductId = editproduct.Id,
                                         ProductDesc = editproduct.Description,
                                         ProductCode = editproduct.ProductCode
                                     });
                }
                else
                {
                    switch (ProductTypeToLoad)
                    {
                        case ProducTypeToLoad.AllProducts:
                            LoadedProducts.Clear();
                            AvailableInventory = Using<IInventoryRepository>(cont).GetByWareHouseId(Using<IConfigService>(cont).Load().CostCentreId)
                                                                  .Where(n => n.Balance > 0).ToList();

                            AvailableInventory.OrderBy(n => n.Product.Description).ToList()
                                              .ForEach(n => LoadedProducts.Add(n.Product));
                            LoadedProducts.Where(n => !Using<IDiscountProWorkflow>(cont).IsProductFreeOfCharge(n.Id))
                                          .ToList()
                                          .ForEach(n => Products.Add(new POLineItemProductLookupItem
                                                                         {
                                                                             ProductId = n.Id,
                                                                             ProductDesc = n.Description,
                                                                             ProductCode = n.ProductCode
                                                                         }));
                            break;
                        case ProducTypeToLoad.NonReturnables:
                            LoadedProducts.Clear();

                            AvailableInventory = Using<IInventoryRepository>(cont).GetByWareHouseId(Using<IConfigService>(cont).Load().CostCentreId)
                                                                  .Where(
                                                                      n =>
                                                                      n.Product.GetType() != typeof (ReturnableProduct))
                                                                  .Where(n => n.Balance > 0)
                                                                  .OrderBy(n => n.Product.Description).ToList();
                            AvailableInventory.ForEach(n => LoadedProducts.Add(n.Product));
                            LoadedProducts.Where(n => !Using<IDiscountProWorkflow>(cont).IsProductFreeOfCharge(n.Id))
                                          .ToList()
                                          .ForEach(n => Products.Add(new POLineItemProductLookupItem
                                                                         {
                                                                             ProductId = n.Id,
                                                                             ProductDesc = n.Description,
                                                                             ProductCode = n.ProductCode
                                                                         }));
                            break;
                        case ProducTypeToLoad.Returnables:
                            LoadedProducts.Clear();
                            Using<IProductRepository>(cont).GetAll()
                                           .OfType<ReturnableProduct>()
                                           .Where(p => ReturnableIn.ContainsKey(p.Id))
                                           .OrderBy(n => n.Description).ToList().ForEach(n => LoadedProducts.Add(n));
                            LoadedProducts.ToList().ForEach(n => Products.Add(new POLineItemProductLookupItem
                                                                                  {
                                                                                      ProductId = n.Id,
                                                                                      ProductDesc = n.Description,
                                                                                      ProductCode = n.ProductCode
                                                                                  }));
                            break;
                    }
                }
                if (ProductTypeToLoad == ProducTypeToLoad.Returnables)
                    ModalCrumbs = "Distributr: Receive Returnable Products from " + Salesman.Username + "";
                else if (ProductTypeToLoad == ProducTypeToLoad.NonReturnables)
                {
                    if (Products.Count == 1 && mesCn == 0)
                    {
                        MessageBox.Show("Adjust product inventory to load Product");
                        mesCn += 1;
                    }
                }

                CapacityValueApplied = false;
            }
        }