public bool Add_Item(OrderItem item) { try { if (!Orderitem_list.Contains(item)) { Orderitem_list.Add(item); Order_total_consumption += item.total_price; return(true); } else { return(false); } } catch (Exception e) { throw new Exception("添加商品失败", e); } }
public bool Delete_Item(string name_of_item) { bool flag = false; try { for (int i = 0; i < Orderitem_list.Count; i++) { if (Orderitem_list[i].name_of_item == name_of_item) { Orderitem_list.Remove(Orderitem_list[i]); flag = true; } } return(flag); } catch (Exception e) { throw new Exception("删除商品失败", e); } }