public void insert(ListView listView) { if (listView.Items.Count == 0) { return; } else { locationClothesContent = new LocationClothesContent(); locationClothesContentDB = new LocationClothesContentDB(); locationClothesControl = new LocationClothesControl(); clothesStoreControl = new ClothesStoreControl(); int locationClothesID = locationClothesControl.getLastID(); foreach (ListViewItem lvi in listView.Items) { string name = lvi.SubItems[0].Text; double price = double.Parse(lvi.SubItems[1].Text); double quantity = double.Parse(lvi.SubItems[2].Text); double total = double.Parse(lvi.SubItems[3].Text); locationClothesContent.setName(name); locationClothesContent.setPrice(price); locationClothesContent.setQuantity(quantity); locationClothesContent.setTotal(total); locationClothesContent.setLocationClothesID(locationClothesID); clothesStoreControl.updateQuantityMinus(name, quantity); locationClothesContentDB.insert(locationClothesContent); } } }
public void deleteCheckedItems(ListView listView, string locationName) { clothesStoreControl = new ClothesStoreControl(); locationClothesContent = new LocationClothesContent(); locationClothesContentDB = new LocationClothesContentDB(); if (listView.CheckedItems.Count == 0) { return; } else { foreach (ListViewItem item in listView.CheckedItems) { string name = item.SubItems[0].Text; double price = double.Parse(item.SubItems[1].Text); double quantity = double.Parse(item.SubItems[2].Text); double total = double.Parse(item.SubItems[3].Text); item.Remove(); this.deletedClothesItems(name, locationName); bool flag = clothesStoreControl.insertClothes(name, price, quantity, total); if (flag == true) { //inserted in store } else { //update quantity in store clothesStoreControl.updateQuantityPlus(name, quantity); } } } }