Esempio n. 1
0
        private void addProductToList(ProductModel model, string quantity)
        {
            bool found = false;
            int  int_quantity;

            try { int_quantity = Convert.ToInt32(quantity); }
            catch (Exception) { int_quantity = 1; }
            ObservableCollection <SaleProductModel> temp_list = new ObservableCollection <SaleProductModel>();

            foreach (SaleProductModel sp_model in SaleProducts)
            {
                temp_list.Add(sp_model);
            }
            for (int i = 0; i < temp_list.Count; i++)
            {
                if (temp_list[i].ProductID.value == model.ID.value && temp_list[i].Discount.value == 0)
                {
                    SaleProductModel temp_model = temp_list[i];
                    SaleProducts.Remove(temp_list[i]);
                    temp_model.Qunatity.value = int_quantity;
                    temp_model.SubTotal.value = temp_model.Price.value * temp_model.Qunatity.value;
                    SaleProducts.Insert(i, temp_model);
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                SaleProductModel sale_product_model = new SaleProductModel();
                sale_product_model.ProductName.value = model.Name.value;
                sale_product_model.ProductID.value   = model.ID.value;
                sale_product_model.Qunatity.value    = int_quantity;
                sale_product_model.Price.value       = model.Price.value;
                sale_product_model.SubTotal.value    = model.Price.value * sale_product_model.Qunatity.value;
                SaleProducts.Add(sale_product_model);
            }
            SearchedModel = null;
            calculateTotal();
        }
Esempio n. 2
0
 public void AddSaleProduct(SaleProduct saleProduct)
 {
     SaleProducts.Add(saleProduct);
 }