/// <summary>
        /// Processes a return request given a receipt.
        /// </summary>
        /// <param name="receiptID"></param>
        /// <param name="itemID"></param>
        /// <param name="itemAmount"></param>
        public void ProcessReturn(int receiptID, int itemID, int itemAmount)
        {
            status = State.Return;
            if (receiptID > TransactionDB.GetTransactionInt() || receiptID < 0)
            {
                throw new Exception();
            }
            Transaction receipt = TransactionDB.GetTransaction(receiptID);

            for (int i = 0; i < receipt.GetItems.Count; i++)
            {
                List <Tuple <Product, int> > temp = receipt.GetItems;
                if (temp[i].Item1.ID == itemID)
                {
                    if (itemAmount > temp[i].Item2)
                    {
                        returnval = "Error. Cannot return more items than purchased.";
                        update(returnval, status);
                        return;
                    }
                    else
                    {
                        temp[i]   = new Tuple <Product, int>(temp[i].Item1, temp[i].Item2 - itemAmount);
                        returnval = "Success! Items returned.";
                        update(returnval, status);
                        return;
                    }
                }
            }
            returnval = "Error. Item Not Found.";
            update(returnval, status);
        }
예제 #2
0
 /// <summary>
 /// Adds a Transaction to the Rebate DataBase.
 /// </summary>
 /// <param name="Date"></param>
 /// <param name="ID"></param>
 public void AddToRebateList(DateTime Date, int ID)
 {
     status = State.Rebate;
     if ((ID) <= 0 || (ID--) >= TransactionDB.GetTransactionInt())
     {
         update("Transaction ID does not exist.", status);
     }
     else
     {
         Transaction temp = TransactionDB.GetTransaction(ID);
         returnval = RebateDB.AddRebateToList(temp, Date);
         update(returnval, status);
     }
 }