/// <summary> /// generate the rebate check /// </summary> /// <returns>the content for rebate transaction</returns> public static string GenerateRebateCheck() { string check = ""; foreach (int id in _DBofRebate.Keys) { Rebate reb = _DBofRebate[id]; reb.minusRebate(id); Transaction tran = GetTransaction(id); double rebateAmount = tran.Total - reb.CostWithRebate; check += "First Name: " + tran.firstName + "\nLast Name: " + tran.lastName + "\nAddress: " + tran.Address + "Email: " + tran.Email + "\nItems List: \n" + PrintItemsAndCost(id) + "\nCost Total: " + tran.Total + "\nCost after rebate: " + reb.CostWithRebate + "\nRebate Amount: " + rebateAmount + ".\n"; check += "Check is mailing to " + tran.Address + " and the email is sending to " + tran.Email + ".\n"; } return(check); }
/// <summary> /// the Enter rebate menu which can interact with Users /// </summary> private static void UIofAddRebate() { bool back = false; do { try { string input; Console.WriteLine("\nEnter Rebate: "); do { Console.Write("Enter transaction ID you want to add rebate: "); input = Console.ReadLine(); int id = Int32.Parse(input); if (!DataBase.TransactionExist(id)) { Console.WriteLine("This transaction does not exist."); } else { if (DataBase.GetTransaction(id).Month != 6) { Console.WriteLine("This transaction is not established on June."); } else { bool redo = false; string[] date; do { Console.Write("Date of today(MM/DD/YYYY): "); input = Console.ReadLine(); date = input.Split('/'); if (!checkDateformat(Int32.Parse(date[0]), Int32.Parse(date[1]), Int32.Parse(date[2]))) { Console.WriteLine("Date invalid!"); redo = true; } else { redo = false; } } while (redo); if (Int32.Parse(date[0]) > 7) { Console.WriteLine("Exceed the rebate date."); } else if (Int32.Parse(date[0]) == 7 && Int32.Parse(date[1]) > 15) { Console.WriteLine("Exceed the rebate date."); } else if (!Rebate.RebateAllowed(id, Int32.Parse(date[2]))) { Console.WriteLine("This transaction is not allowed to rebate!"); } else { Console.Write("Enter the amount you would like to rebate(ex: if rebate 11%, enter 11): "); input = Console.ReadLine(); double rebate = Convert.ToDouble(input); Rebate reb = new Rebate(rebate, Int32.Parse(date[0]), Int32.Parse(date[1]), Int32.Parse(date[2])); DataBase.AddRebate(id, reb); Console.WriteLine("Rebate complete."); } } do { Console.Write("Would you like rebate another transaction? (y/n) "); input = Console.ReadLine().ToLower(); } while (confirm(input)); } } while (input == "y"); back = true; } catch (Exception e) { Console.WriteLine(e.ToString()); Console.WriteLine("Error! Back to top."); } } while (back == false); }
/// <summary> /// add new rebate to database /// </summary> /// <param name="id"> the id of rebated transaction</param> /// <param name="reb"> the rebate we would like to add for this transaction</param> public static void AddRebate(int id, Rebate reb) { _DBofRebate.Add(id, reb); }