Exemple #1
0
        private ArrayList GetTop10(ArrayList allProducts)
        {
            ArrayList mostPopular = new ArrayList();
            int       tempq       = 0;
            int       tempi       = 0;

            if (allProducts.Count <= 10)
            {
                return(allProducts);
            }
            else
            {
                while (mostPopular.Count < 10)
                {
                    for (int i = 0; i < allProducts.Count; i++)
                    {
                        ProductRow tempRow = allProducts[i] as ProductRow;
                        if (tempRow.quantity > tempq)
                        {
                            tempq = tempRow.quantity;
                            tempi = i;
                        }
                    }
                    mostPopular.Add(allProducts[tempi]);
                    allProducts.RemoveAt(tempi);
                }
            }
            return(mostPopular);
        }
Exemple #2
0
        public void removeProduct(Product product)
        {
            ProductRow tmp = null;

            foreach (ProductRow row in products)
            {
                if (row.product.Equals(product))
                {
                    tmp = row;
                    break;
                }
            }

            products.Remove(tmp);
        }
Exemple #3
0
 private void AddIfNotExist(ProductRow purchaseRow, ArrayList list)
 {
     if (list.Count > 0)
     {
         foreach (ProductRow p in list)
         {
             if (p.product.productID == purchaseRow.product.productID)
             {
                 p.quantity += purchaseRow.quantity;
                 return;
             }
         }
     }
     list.Add(purchaseRow);
 }
Exemple #4
0
        public void addProduct(Product product, int quantity)
        {
            ProductRow tmp = new ProductRow(product, quantity);

            for (int i = 0; i < products.Count; i++)
            {
                ProductRow temp = products[i] as ProductRow;
                if (product.productID == temp.product.productID)
                {
                    temp.quantity += quantity;
                    return;
                }
            }
            products.Add(tmp);
        }