Exemplo n.º 1
0
        private async void SaveSelectedProducts()
        {
            IsExporting      = true;
            _ctsSaveProducts = new CancellationTokenSource();

            var products = SelectedProducts.ToList();

            try
            {
                var task = Export.SaveCollection(products, _ctsSaveProducts.Token);
                CriticalTasks.Add(task);
                await task.ConfigureAwait(false);
            }
            catch (TaskCanceledException)
            {
            }
            catch (System.Exception e)
            {
                _logger.Error(e);
                await MessageBox.ShowAsync("Произошла ошибка во время экспорта.", "Ошибка", MessageBoxButton.OK,
                                           MessageBoxImage.Error).ConfigureAwait(false);
            }
            CriticalTasks.Cleanup();

            IsExporting = false;
        }
Exemplo n.º 2
0
        private async void RefreshSelectedProducts()
        {
            if (IsRefreshing)
            {
                _ctsRefreshProducts?.Cancel();
                IsRefreshing = false;
                return;
            }

            IsRefreshing = true;

            _ctsRefreshProducts = new CancellationTokenSource();

            try
            {
                var products = SelectedProducts.ToList();
                await RefreshProductsAsync(products, _ctsRefreshProducts).ConfigureAwait(false);

                RefreshCounters();
            }
            catch (OperationCanceledException)
            {
            }

            IsRefreshing = false;
        }
Exemplo n.º 3
0
 private void SaveSelectedProducts()
 {
     if (grid.EnabledMultipleSelection)
     {
         foreach (GridViewRow r in grid.Rows)
         {
             string   ProductITL = grid.DataKeys[r.RowIndex].Value.ToString();
             var      product    = Products.Single(x => x.ProductITL == ProductITL);
             CheckBox cb         = r.FindControl("cbSelect") as CheckBox;
             if (cb.Checked)
             {
                 // Add product
                 if (!SelectedProducts.Any(x => x.ProductITL == product.ProductITL))
                 {
                     SelectedProducts.Add(product);
                     _isMultipleSelectionActived = true;
                 }
             }
             else
             {
                 // Remove product
                 if (SelectedProducts.Any(x => x.ProductITL == product.ProductITL))
                 {
                     SelectedProducts.RemoveAll(x => x.ProductITL == product.ProductITL);
                     _isMultipleSelectionActived = true;
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        public void AddProduct(int ID)
        {
            Products p = AllProducts.Where(x => x.ID == ID).First();

            TotalCost += p.Price;
            CheckBalance();
            SelectedProducts.Add(p);
        }
Exemplo n.º 5
0
        private void RemoveProducts()
        {
            var products = SelectedProducts.ToList();

            foreach (var product in products)
            {
                _products.Remove(product);
            }
        }
Exemplo n.º 6
0
        //public delegate void ShoppingCartAlert(string message);

        //private int MoveItemToShoppingCart(int code, ShoppingCartAlert cartAlert)
        private int MoveItemToShoppingCart(int code, Action <string> cartAlert)
        {
            Product product = ProductListing.Products.First(a => a.Code == code);

            SelectedProducts.Add(product);

            cartAlert($"\n{product.Name} is Added to cart. ");

            return(product.Price);
        }
Exemplo n.º 7
0
        private async void ResetColor()
        {
            var products = SelectedProducts.Select(p =>
            {
                p.Color = "#00FFFFFF";
                return(p.Model);
            }).ToList();

            await AsyncHelper.ProcessCollectionAsync(products, Db.Products.UpdateColorAsync).ConfigureAwait(false);
        }
Exemplo n.º 8
0
        public void SelectItemsByIDs(List <String> ids)
        {
            ClearSelectedValues();

            foreach (var productITL in ids)
            {
                var product = Products.Single(x => x.ProductITL == productITL);
                SelectedProducts.Add(product);
            }
            SetSelectedProducts();
        }
Exemplo n.º 9
0
        public void DeleteProduct(int ID)
        {
            Products p = SelectedProducts.Where(x => x.ID == ID).First();

            TotalCost -= p.Price;
            if (TotalCost < 0)
            {
                TotalCost = 0;
            }
            CheckBalance();
            SelectedProducts.Remove(p);
        }
Exemplo n.º 10
0
        private void SetSelectedProducts()
        {
            if (grid.EnabledMultipleSelection)
            {
                foreach (GridViewRow r in grid.Rows)
                {
                    string   ProductITL = grid.DataKeys[r.RowIndex].Value.ToString();
                    var      product    = Products.Single(x => x.ProductITL == ProductITL);
                    CheckBox cb         = r.FindControl("cbSelect") as CheckBox;

                    cb.Checked = SelectedProducts.Any(x => x.ProductITL == product.ProductITL);
                }
            }
        }
Exemplo n.º 11
0
 private void ProductOpen(object parametr)
 {
     if (parametr is ListViewItem productItem)
     {
         SelectedProducts.Clear();
         var tmp = new ListViewItem();
         var id  = (int)productItem.Tag;
         tmp.Content += $"Name: {manager.Repository.GetProduct(id).Name}\n" +
                        $"Product number {manager.Repository.GetProduct(id).ProductNumber}\n" +
                        $"Size: {manager.Repository.GetProduct(id).Size}\n" +
                        $"Published {manager.Repository.GetProduct(id).SellStartDate}";
         SelectedProducts.Add(tmp);
     }
 }
        /// <summary>
        /// Fyller listan med redan existerande placeringar
        /// </summary>
        private void LoadExistingPlacements()
        {
            foreach (Employee e in EmployeeList)
            {
                foreach (ProductPlacement pp in ProductManagement.Instance.GetProductPlacementsByEmployeeAndDepartment(e, DepartmentID))
                {
                    foreach (DataItemProduct DIP in MyList)
                    {
                        if (DIP.EmployeeID.Equals(e.EmployeeID))
                        {
                            DIP.DataList.Add(pp);

                            //Create column if it doesn't exist
                            if (!ColumnExists(pp.Product.ProductName))
                            {
                                DataGridTextColumn productColumn = new DataGridTextColumn {
                                    Header = pp.Product.ProductName
                                };
                                productColumn.Binding = new Binding("DataList[" + dgProductPlacements.Columns.Count + "].ProductAllocate");
                                dgProductPlacements.Columns.Add(productColumn);
                                SelectedProducts.Add(pp.Product);
                            }
                        }
                    }
                }
            }

            foreach (DataItemProduct DIP in MyList)
            {
                foreach (DataGridTextColumn DGTC in dgProductPlacements.Columns)
                {
                    ProductPlacement tempPP = DIP.DataList.SingleOrDefault(p => p.Product.ProductName.Equals(DGTC.Header.ToString()));

                    if (tempPP == null)
                    {
                        Product          tempProd     = ProductManagement.Instance.GetProductByName(DGTC.Header.ToString());
                        ProductPlacement newPlacement = new ProductPlacement
                        {
                            EmployeeID      = DIP.EmployeeID,
                            Product         = tempProd,
                            ProductID       = tempProd.ProductID,
                            ExpenseBudgetID = DateTime.Now.Year,
                            ProductAllocate = 0
                        };
                        DIP.DataList.Add(newPlacement);
                        ProductPlacementList.Add(newPlacement);
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void Select()
        {
            var productInOrderCollection = new ObservableCollection <ProductInOrder>(_SelectedProducts.
                                                                                     Select(o => new ProductInOrder
            {
                ID        = ((Product)o).ProductID,
                Name      = ((Product)o).ProductName,
                Discount  = 1,
                Quantity  = 1,
                UnitPrice = ((Product)o).UnitPrice.Value
            }));

            ProductInOrderCollection = productInOrderCollection;
            SelectedProducts.Clear();
        }
Exemplo n.º 14
0
        private void CopyLinks()
        {
            var products = SelectedProducts.ToList();
            var sb       = new StringBuilder();

            foreach (var product in products)
            {
                var url = "https://skladchik.com/threads/" + product.Model.Id;
                sb.Append(url + Environment.NewLine);
            }

            var text = sb.ToString().TrimEnd();

            Clipboard.SetText(text);
        }
Exemplo n.º 15
0
        public List <Product> ImportSelectedProducts()
        {
            SaveSelectedProducts();

            var arrayOfProductItsl = SelectedProducts.Select(x => x.ProductITL).ToArray();

            var dict = ImportAbdaProductIndb(arrayOfProductItsl);

            // Set product id
            foreach (var product in SelectedProducts)
            {
                product.ProductId = dict.Single(x => x.Key == product.ProductITL).Value;
            }

            return(SelectedProducts);
        }
        private void LoadEmployees()
        {
            dgProductPlacements.Columns.Clear();
            EmployeeList.Clear();
            MyList.Clear();
            ProductPlacementList.Clear();
            SelectedProducts.Clear();

            foreach (Employee e in EmployeeManagement.Instance.GetEmployeeAtributes(DepartmentID))
            {
                m_EmployeeList.Add(e);
            }

            CreateRow();
            LoadExistingPlacements();
        }
        private void btnChooseProduct_Click(object sender, RoutedEventArgs e)
        {
            ProductRegister productRegister = new ProductRegister(true, DepartmentID);

            if (productRegister.ShowDialog() == true)
            {
                if (SelectedProducts.Contains(productRegister.SelectedProduct))
                {
                    MessageBox.Show("Du kan inte välja samma produkt flera gånger");
                }
                else
                {
                    SelectedProducts.Add(productRegister.SelectedProduct);
                    CreateColumn(productRegister.SelectedProduct);
                }
            }
        }
Exemplo n.º 18
0
        private void RefreshList(bool isadd, Product p)
        {
            if (p == null || p.Id == 0)
            {
                ScanNoFoundMessage.Text = "No found barcode";
                return;
            }
            var existingProduct = SelectedProducts.FirstOrDefault(d => d.Id == p.Id);

            if (isadd)
            {
                if (existingProduct == null)
                {
                    p.Quantity = 1;
                    SelectedProducts.Add(p);
                }
                else
                {
                    existingProduct.Quantity++;
                }
            }
            else
            {
                if (existingProduct == null)
                {
                    return;
                }
                else
                {
                    if (existingProduct.Quantity > 1)
                    {
                        existingProduct.Quantity--;
                    }
                    else
                    {
                        SelectedProducts.Remove(existingProduct);
                    }
                }
            }
            Total.Text = SelectedProducts.Sum(d => d.Price * d.Quantity).ToString();
            SelectedProductsListView.ItemsSource = null;
            SelectedProductsListView.ItemsSource = SelectedProducts;
        }
        private void Select()
        {
            ProductInOrderCollection = new ObservableCollection <ProductInOrder>(_SelectedProducts.
                                                                                 Select(o => new ProductInOrder
            {
                ID        = (o as Product).ProductID,
                Name      = (o as Product).ProductName,
                Discount  = 0,
                Quantity  = 1,
                UnitPrice = (o as Product).UnitPrice.Value
            }));
            foreach (var productInOrder in ProductInOrderCollection)
            {
                (productInOrder as ProductInOrder).PropertyChanged += ProductInOrder_PropertyChanged;
            }
            ProductInOrderCollection.CollectionChanged += OnProductInOrderCollectionChanged;

            TotalSum = GetTotalSum();

            SelectedProducts.Clear();
            OrderDate = DateTime.Now.ToLongDateString();
        }
Exemplo n.º 20
0
        private async void OpenProduct()
        {
            var products = SelectedProducts.ToList();

            if (products.Count > 10)
            {
                var result = await MessageBox.ShowAsync(
                    $"Вы собираетесь открыть {products.Count} складчин в браузере. Это может сильно замедлить его работу. \r\n Хотите продолжить?",
                    "", MessageBoxButton.YesNo, MessageBoxImage.Warning).ConfigureAwait(false);

                if (result != MessageBoxResult.Yes)
                {
                    return;
                }
            }

            foreach (ProductVM p in products)
            {
                string link = Products.GetProductLink(p.Model);
                Process.Start(link);
            }
        }
Exemplo n.º 21
0
        public ActionResult Edit(int id)
        {
            CatalogModels model = new CatalogModels();

            model.catalog = _catalog.GetById(id);

            IEnumerable <Product> products = _product.GetAll();

            List <SelectedProducts> selProds = new List <SelectedProducts>();

            foreach (var pro in products)
            {
                SelectedProducts prods = new SelectedProducts();
                prods.Checked     = _productscatalogs.GetAll().Where(c => c.Catalog.Id == id).Where(c => c.Product.Id == pro.Id).Any()?1:0;
                prods.Id          = pro.Id;
                prods.Code        = pro.Code;
                prods.Description = pro.Description;
                selProds.Add(prods);
            }

            model._SelectedProducts = selProds;

            return(View(model));
        }
        private void FilterExecute()
        {
            PageNumber = 1;
            AllOrder   = UnitOfWork.get().Orders.GetAll().Where(o =>
                                                                o.OrderLines.Any(ol => SelectedProducts.Contains(ol.Product)) &&
                                                                o.Payments.Any(p => SelectedPaymentsType.Contains(p.PaymentTypeName)) &&
                                                                o.PurchaseDate >= DateFrom && o.PurchaseDate <= DateTo &&
                                                                (o.IsCloseInZ == SelectedCloseInZList.Contains("פתוחה") ||
                                                                 o.IsCloseInZ != SelectedCloseInZList.Contains("סגורה"))
                                                                ).OrderByDescending(o => o.ID);
            ResultCount   = AllOrder.Count();
            NumberOfPages = ResultCount / PageSize +
                            (ResultCount % PageSize == 0?0:1);

            RefreshOrders();
        }
Exemplo n.º 23
0
 public void ClearSelectedValues()
 {
     SelectedProducts.Clear();
     grid.SelectedValues.Clear();
 }
Exemplo n.º 24
0
 public bool IsSelectedProductsExists() => SelectedProducts != null && SelectedProducts.Any();
Exemplo n.º 25
0
 public void EmptyCart(Action <string> cartAlert)
 {
     SelectedProducts.Clear();
     Total = 0;
     cartAlert("Shopping Cart is empty.");
 }