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); }
public int add_product_by_barcode(string barcode_d) { cls_product prod = new cls_product(barcode_d); if (prod.getSyncId() == 0) { return(-1); } return(this.add_product(prod)); }