private void ItemButton_Click(object sender, RoutedEventArgs e) { if (tbQuantity.Text == "") { MessageBox.Show("Please Enter Product Quantity!"); return; } PosModel item = (PosModel)itemData.ElementAt(Convert.ToInt16(((Button)sender).Tag)); Double subtotalProcess = item.productPrice * Convert.ToDouble(tbQuantity.Text); lvPurchaseList.ItemsSource = null; foreach (PosModel tmp in basketData) { if (tmp.productID == item.productID) { tmp.productQuantity += Convert.ToInt16(tbQuantity.Text); tmp.productSubtotal = Convert.ToDouble(tmp.productPrice) * tmp.productQuantity; lvPurchaseList.ItemsSource = basketData; computation(); return; } } basketData.Add(new PosModel() { productID = item.productID, productName = item.productName, productPrice = item.productPrice, productQuantity = Convert.ToInt16(tbQuantity.Text), productSubtotal = subtotalProcess }); lvPurchaseList.ItemsSource = basketData; computation(); }
private void btnDeleteProduct_Click(object sender, RoutedEventArgs e) { if (lvPurchaseList.SelectedIndex == -1) { MessageBox.Show("Please Select an Item!"); return; } PosModel item = (PosModel)lvPurchaseList.SelectedItem; lvPurchaseList.ItemsSource = null; basketData.Remove(item); lvPurchaseList.ItemsSource = basketData; computation(); }