public void deleteItem(string ProductName) { SaleItemClass selectedSaleItem = null; foreach (var item in currentSaleObject.SaleItems) { if (item.ProductName.CompareTo(ProductName) == 0) { selectedSaleItem = item; continue; } } if (selectedSaleItem != null) { currentSaleObject.SaleItems.Remove(selectedSaleItem); refreshSaleItemsList(); } }
public void AddItemToCart() { string ProductName = ""; decimal Quantity = 0; decimal Price = 0; decimal Discount = 0; decimal itemtax = 0; if (ProductList.Text != null) { ProductName = ProductList.Text; } else { MessageBox.Show("Select a product"); return; } if (QuantityField.Text.Length > 0) { try { Quantity = Decimal.Parse(QuantityField.Text); } catch (Exception e3) { MessageBox.Show("Enter Numeric Values only"); } } else { MessageBox.Show("Enter Quantity"); return; } if (PriceField.Text.Length > 0) { try { Price = Decimal.Parse(PriceField.Text); } catch (Exception e1) { MessageBox.Show("Enter Numeric Values only"); } } else { MessageBox.Show("Enter Price"); return; } if (DiscountField.Text.Length == 0) { Discount = 0; } else { try { Discount = Decimal.Parse(DiscountField.Text); } catch (Exception e2) { MessageBox.Show("Enter Numeric Values only"); } } if (ItemTaxField.Text.Length == 0) { itemtax = 0; } else { try { itemtax = Decimal.Parse(ItemTaxField.Text); } catch (Exception e2) { MessageBox.Show("Enter Numeric Values only"); } } SaleItemClass saleItem = new SaleItemClass(); saleItem.ProductName = ProductName; saleItem.ProductID = getProductID2(ProductName); saleItem.Quantity = Quantity; saleItem.PriceApplied = Price; saleItem.TaxPercentage = itemtax; saleItem.Discount = Discount; saleItem.PurchasePrice = getPurchasePrice(saleItem.ProductID); currentSaleObject.SaleItems.Add(saleItem); refreshSaleItemsList(); clearFields(); }