Beispiel #1
0
        public int add_offline_product(cls_product prod)
        {
            for (int i = 0; i < list_product.Count; i++)
            {
                Console.WriteLine(prod.getBarcode() + " == " + prod.getBarcode());
                if (list_product[i].getBarcode() == prod.getBarcode())
                {
                    decimal qty = list_product[i].getQty() + prod.getQty();
                    if (qty == 0)
                    {
                        this.remove_product(i);
                        return(i);
                    }
                    list_product[i].setQty(qty);
                    list_product[i].setPrice(prod.getPrice());
                    return(i);
                }
            }
            int row_index = this.list_product.Count;

            this.list_product.Add(prod);
            this.dtproducts.Rows.Add(dtproducts.NewRow());
            this.sync_product_row(row_index);
            return(row_index);
        }
Beispiel #2
0
        public int add_product(cls_product prod)
        {
            //prod.reset_data_by_mode(this.isnonvat, this.issenior, this.iswholesale, this.pricingtype);
            if (prod.getQty() == 0)
            {
                return(-1);
            }
            for (int i = 0; i < list_product.Count; i++)
            {
                if (list_product[i].getSyncId() == prod.getSyncId() &&
                    prod.getSyncId() != 0 &&
                    prod.getBarcode() != "-")
                {
                    decimal qty = list_product[i].getQty() + prod.getQty();
                    if (qty == 0)
                    {
                        this.remove_product(i);
                        return(i);
                    }
                    list_product[i].setQty(qty);
                    list_product[i].reset_data_by_mode(this.isnonvat, this.issenior, this.iswholesale, this.pricingtype, this.pricingrate, this.customer);
                    this.sync_product_row(i);
                    return(i);
                }
            }

            int row_index = this.list_product.Count;

            this.list_product.Add(prod);
            this.dtproducts.Rows.Add(dtproducts.NewRow());
            this.sync_product_row(row_index);
            return(row_index);
        }