Exemple #1
0
 static void CheckGenerator(RebateManager rm)
 {
     while (true)
     {
         Console.WriteLine("How many checks would you like generated? 1. One   2. All");
         int n;
         Int32.TryParse(Console.ReadLine(), out n);
         if (n == 1)
         {
             Console.WriteLine("Please enter the transaction ID: ");
             int nn;
             Int32.TryParse(Console.ReadLine(), out nn);
             Rebate r = rm.RebateNumberSearch(nn);
             if (r != null)
             {
                 Console.WriteLine(rm.GenerateOneCheck(nn));
             }
             else
             {
                 Console.WriteLine("This rebate is not recorded.");
             }
             break;
         }
         else if (n == 2)
         {
             Console.WriteLine(rm.GenerateAllChecks());
         }
         else
         {
             Console.WriteLine("Your input must be 1 or 2.");
         }
     }
 }
Exemple #2
0
        }   //END OF RemoveItemFromReceipt METHOD

        /// <summary>
        /// This method begins the process for creating a rebate
        /// </summary>
        public static void createRebate()
        {
            Console.WriteLine("What receipt would you like to create a rebate for? ");
            string receiptName = Console.ReadLine();
            if (_receiptList.ContainsKey(receiptName))
            {
                if(_receiptList[receiptName].Month < 6 || _receiptList[receiptName].Month > 6)
                {
                    Console.WriteLine("Purchase was not made in the month of June, cannot create rebate");
                    return;
                }
                else if (!_receiptList[receiptName].RebateCreated)
                {
                    _rebateList.Add(Rebate.getInformation(_receiptList[receiptName]), _receiptList[receiptName]);
                }
                else
                {
                    Console.WriteLine("Rebate could not be made beacuse a rebate has already been made");
                }
            }
            else
            {
                Console.WriteLine("Receipt does not exist");
            }
        }   //END OF createRebate METHOD
Exemple #3
0
        public void itemReturn(Item item, int date)
        {
            Rebate rebates = new Rebate(date);
            double rebate  = rebates.rebates / 100;

            _totalCost -= item.cost;
            _numItemReturns++;
            _rebateAmount = (item.cost * rebate);
        }
Exemple #4
0
 /// <summary>
 /// used to add a rebate
 /// </summary>
 /// <param name="transaction">the transaction to add a rebate to</param>
 /// <param name="rebate">the rebate object</param>
 static public void AddRebate(Transaction transaction, Rebate rebate)
 {
     if (!CheckRebate(transaction.ID))
     {
         Rebates.Add(transaction, rebate);
     }
     else
     {
         Console.WriteLine("That transaction already has a rebate.");
     }
 }
Exemple #5
0
        static private Dictionary <Transaction, Rebate> Rebates = new Dictionary <Transaction, Rebate>(); //holds all rebates

        /// <summary>
        /// test rebates
        /// </summary>
        static public void test()
        {
            Transaction t1 = AllTransactions.Transactions[1234];
            Rebate      r1 = new Rebate(t1.Name, "123 Street, Manhanttan, KS", "*****@*****.**", new DateTime(2018, 06, 16), (decimal)0.20);

            Rebates.Add(t1, r1);

            Transaction t2 = AllTransactions.Transactions[1235];
            Rebate      r2 = new Rebate(t2.Name, "321 Street, Manhanttan, KS", "*****@*****.**", new DateTime(2018, 02, 16), (decimal)0.11);

            Rebates.Add(t2, r2);
        }
Exemple #6
0
        /// <summary>
        /// Used to make strings for generating checks
        /// </summary>
        /// <param name="t">The transaction that the rebate is used on</param>
        /// <param name="r">The rebate</param>
        /// <returns>a string containing the customer name, amount owed, transaction info and rebate info</returns>
        static public string ToString(Transaction t, Rebate r)
        {
            decimal total      = t.Total;
            decimal discount   = r.Discount;
            decimal rebatePaid = discount * total;
            string  check      = "Pay to the Order of " + r.Name + " the amount of " + rebatePaid.ToString("C2") + "\n" +
                                 "Transaction ID: " + t.ID +
                                 "\nTotal: " + total.ToString("C2") + " Discount: " + String.Format("{0:P0}\n", discount) +
                                 "Address: " + r.Address +
                                 "\nEmail: " + r.Email + "\n";

            return(check);
        }
Exemple #7
0
        /// <summary>
        /// Used to enter a rebate
        /// </summary>
        static public void EnterRebate()
        {
            DateTime date;

            while (true)
            {
                Console.Write("Enter the date(mm/dd/yyyy): ");
                try
                {
                    string[] tempDate = Console.ReadLine().Split('/');
                    date = new DateTime(Convert.ToInt32(tempDate[2]), Convert.ToInt32(tempDate[0]), Convert.ToInt32(tempDate[1]));
                    break;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Invalid Entry");
                }
            }

            Console.Write("Enter the transaction ID: ");
            int ID = Convert.ToInt32(Console.ReadLine());

            while (!AllTransactions.CheckID(ID, AllTransactions.Transactions))
            {
                Console.Write("That ID does not exist, try again: ");
                ID = Convert.ToInt32(Console.ReadLine());
            }

            string      name = AllTransactions.Transactions[ID].Name;
            Transaction rebateTransaction = AllTransactions.Transactions[ID];

            Console.Write("Enter customer's address: ");
            string address = Console.ReadLine();

            Console.Write("Enter customer's email: ");
            string email = Console.ReadLine();

            decimal discount;

            Console.Write("Enter the discount precent: ");
            discount = Convert.ToDecimal(Console.ReadLine());
            discount = discount / 100;
            Rebate rebate = new Rebate(name, address, email, date, discount);

            AllRebates.AddRebate(rebateTransaction, rebate);
            Console.WriteLine();
        }
Exemple #8
0
        static void DealRebate(TransactionManager tm, RebateManager rm)
        {
            while (true)
            {
                Console.WriteLine("Rebate \n Date must be before 7/15: ");

                Console.WriteLine("Please enter rebate year: ");
                int year;
                Int32.TryParse(Console.ReadLine(), out year);
                Console.WriteLine("Please enter transaction ID: ");
                int n;
                Int32.TryParse(Console.ReadLine(), out n);

                Transaction trans = tm.GetTransaction(n);
                if (trans == null)
                {
                    Console.WriteLine("This transaction doesn't exist.");
                }
                else
                {
                    if (tm.CheckTransactionStatus(n))
                    {
                        Console.WriteLine("This Transaction has been rebated.");
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Please enter customer name: ");
                        string name = Console.ReadLine();
                        Console.WriteLine("Please enter customer address: ");
                        string add    = Console.ReadLine();
                        Rebate rebate = null;
                        if (trans.Year == year && trans.Month == 6)
                        {
                            double amount = trans.GetTotal() * 0.11;
                            rebate = new Rebate(year, name, add, n, amount);
                        }
                        if (rebate != null)
                        {
                            string s = "Rebated";
                            trans.ChangeStatus(s);
                            rm.AddRebate(rebate);
                            Console.WriteLine(trans.ToString() + "\n" + "the rebate amount: " + rebate.Amount);
                        }
                        else
                        {
                            Console.WriteLine("At this date, the rebate is not valid.");
                        }
                    }
                }

                Console.WriteLine("\n");
                Console.WriteLine("What do you plan to do next:  1. Rabate another transaction 2. return previous step");
                int nn;
                Int32.TryParse(Console.ReadLine(), out nn);
                if (nn == 2)
                {
                    break;
                }
            }
        }
Exemple #9
0
        public string GenerateOneCheck(int n)
        {
            Rebate rb = RebateNumberSearch(n);

            return(rb.ToString());
        }
Exemple #10
0
 public void AddRebate(Rebate r)
 {
     _rebates.Add(r);
 }