/// <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);
     }
 }
예제 #3
0
        /// <summary>
        /// Prompts the user for return data.
        /// Passes a return request to the Return Controller.
        /// </summary>
        /// <param name="ID">item ID of the item to be returned</param>
        /// <param name="returnval">the receipt itself</param>
        public void ProcessReturn()
        {
            try
            {
                status = State.Return;
                int  itemNum = 0, itemAmount = 0, receipt_num = 0;
                bool cont = true;

                Console.Write("Please enter in your receipt number: ");
                receipt_num = Convert.ToInt32(Console.ReadLine());
                Transaction items = TransactionDB.GetTransaction(receipt_num);
                Console.WriteLine(items.FormatReceipt() + "\n");

                while (cont)
                {
                    Console.Write("What item number would you like to return?: ");
                    itemNum = Convert.ToInt32(Console.ReadLine());
                    Console.Write("How many would you like to return?: ");
                    itemAmount = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Would you like to continue returning more items? (Y/N): ");
                    string answer = Console.ReadLine().ToUpper();
                    if (answer == "Y")
                    {
                        cont = true;
                    }
                    else if (answer == "N")
                    {
                        cont = false;
                    }
                    else
                    {
                        Console.WriteLine("Invalid input. Start over.\n");
                        status = State.Default;
                        cont   = false;
                    }
                }
                return_handler(receipt_num, itemNum, itemAmount);
            }
            catch
            {
                Console.WriteLine("\nInvalid Entry. Please try again.\n");
            }
            Menu();
        }