Exemplo n.º 1
0
        /// <summary>
        /// manages adding a POSItem to an order. If the POSItem already exists, the quantity is just incremented
        /// </summary>
        /// <param name="i"></param>
        /// <param name="quantity"></param>
        /// <returns>The POSLineItem for the POSItem. Will either return a new one, or an existing with its quantity incremented</returns>
        /// <summary>
        /// Adds the item.
        /// </summary>
        /// <param name="i">The i.</param>
        /// <param name="quantity">The quantity.</param>
        /// <returns>POSLineItem.</returns>
        public POSLineItem AddItem(POSItem i, int quantity)
        {
            bool        exists     = false;
            POSLineItem targetItem = null;

            foreach (POSLineItem lineI in Items)
            {
                if (lineI.Item.ID == i.ID)
                {
                    exists          = true;
                    lineI.Quantity += quantity;
                    targetItem      = lineI;
                    break;
                }
            }
            if (!exists)
            {
                POSLineItem li = new POSLineItem();
                li.Quantity = quantity;
                li.Item     = i;
                targetItem  = li;
                Items.Add(li);
            }
            onOrderChange(this, OrderChangeTarget.ITEM);
            return(targetItem);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Values the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>System.Int64.</returns>
 public long Value(POSItem item)
 {
     if (AmountOff > 0)
     {
         return(AmountOff);
     }
     else
     {
         return((int)(item.Price * PercentageOff));
     }
 }