Example #1
0
        private void btn_Apply_Click(object sender, EventArgs e)
        {
            //make the newly created item
            item = new Item(item.ID, item.OrderID, item.Name, item.Type, item.Price, amount, comment);

            //check if it is in the list already
            if (itemInList)
            {
                //we replace the old item for the new one and update the database
                for (int i = 0; i < order.items.Count; i++)
                {
                    if (order.items[i].ID == item.ID)
                    {
                        order.items[i] = item;
                    }
                }
                service.UpdateItemInOrderContent(item, order);
            }
            else
            {
                //else we add this item to the list and insert into the database
                order.items.Add(item);
                service.AddItemToOrderContent(item, order);
            }
            Close();
        }