public string generateRebateCheck(Transaction t)
        {
            if (t.rebate)
            {
                MessageBox.Show("Rebate already Printed");
                return(null);
            }
            t.rebate = true;
            double total = 0;

            foreach (Product p in t.products)
            {
                total += p.price;
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("Rebate checks for customer who have mailed in their rebate listed below: " + "\n" + "\n");

            /*sb.Append("Customer: " + t.name);
             * sb.Append("Date of Purchase" + t.date + "\n");
             * ///sb.Append("Date rebate was mailed:" +);
             * /// sb.Append("\n");
             * sb.Append("Payments: " +"\n");
             * sb.Append()
             * sb.Append("\n");
             * sb.Append("Order Total: $" + Math.Round(total, 2).ToString() + "\n");*/
            sb.Append(ReceiptGenerator.generateReceipt(t));
            sb.Append("Money from Rebate Check: $" + Math.Round((total * .11), 2).ToString() + "\n" + "\n" + "\n" + "\n");
            return(sb.ToString());
        }
 private void finished_Click(object sender, EventArgs e)
 {
     AddTransaction(userName, month, TransactionDatabase.TransactionNumber, date, database, items);
     MessageBox.Show(ReceiptGenerator.generateReceipt(database.transactions[TransactionDatabase.TransactionNumber]));
     TransactionDatabase.TransactionNumber += 1;
     confirmDate.Visible         = false;
     confirmMonth.Visible        = false;
     confirmName.Visible         = false;
     confirmProductName.Visible  = false;
     confirmProductPrice.Visible = false;
     userInfo.Visible            = false;
     monthTextBox.Visible        = false;
     dateTextBox.Visible         = false;
     productName.Visible         = false;
     productPrice.Visible        = false;
     finished.Visible            = false;
     prompter.Visible            = false;
     items             = new List <Product>();
     userInfo.Text     = "";
     monthTextBox.Text = "";
     dateTextBox.Text  = "";
     productName.Text  = "";
     productPrice.Text = "";
 }
Exemplo n.º 3
0
        public void getProductInfo()
        {
            string enterNew = "";

            Console.WriteLine("Press enter to enter a new transaction");
            enterNew = Console.ReadLine();
            while (enterNew == "")
            {
                Console.WriteLine("Enter customer name: ");
                string name       = Console.ReadLine();
                bool   validMonth = false;
                string month      = "";
                while (validMonth == false)
                {
                    Console.WriteLine("Month of purchase(simply press enter for June): ");
                    month = Console.ReadLine();
                    if (month == "")
                    {
                        validMonth = true;
                        month      = "June";
                    }
                    else if (month.Trim().ToUpper() != "JANUARY" && month.Trim().ToUpper() != "FEBRUARY" && month.Trim().ToUpper() != "MARCH" && month.Trim().ToUpper() != "APRIL" && month.Trim().ToUpper() != "MAY" && month.Trim().ToUpper() != "JUNE" && month.Trim().ToUpper() != "JULY" && month.Trim().ToUpper() != "AUGUST" && month.Trim().ToUpper() != "SEPTEMBER" && month.Trim().ToUpper() != "OCTOBER" && month.Trim().ToUpper() != "NOVEMBER" && month.Trim().ToUpper() != "DECEMBER")
                    {
                        Console.WriteLine("Please enter valid month for transaction.");
                        Console.WriteLine();
                    }
                    else
                    {
                        validMonth = true;
                    }
                }
                int  date      = 14;
                bool validDate = false;
                int  x;
                while (!validDate)
                {
                    Console.WriteLine("Day of purchase(simply press enter for the 14th): ");
                    string input = Console.ReadLine();
                    if (input == "")
                    {
                        date      = 14;
                        validDate = true;
                    }
                    else if (!Int32.TryParse(input, out x))
                    {
                        Console.WriteLine("Please enter a valid number for the date");
                    }
                    else
                    {
                        date      = Convert.ToInt32(input);
                        validDate = true;
                    }
                }
                Console.WriteLine("Enter the product name: ");
                string product    = Console.ReadLine();
                bool   validPrice = false;
                double z;
                double price = 0;
                while (!validPrice)
                {
                    Console.WriteLine("Enter price of product: ");
                    string priceInput = Console.ReadLine();
                    if (Double.TryParse(priceInput, out z))
                    {
                        price      = Math.Round(Convert.ToDouble(priceInput), 2);
                        validPrice = true;
                    }
                    else
                    {
                        Console.WriteLine("Please enter valid price.");
                    }
                }
                products = AddItem(products, product, price);

                string response = "yes";
                while (response.Equals("yes"))
                {
                    Console.WriteLine("Would you like to add another item? (yes/no): ");
                    response = Console.ReadLine();
                    if (response == "yes")
                    {
                        Console.WriteLine("Enter the product name: ");
                        string product2    = Console.ReadLine();
                        bool   validPrice2 = false;

                        double price2 = 0;
                        while (!validPrice2)
                        {
                            Console.WriteLine("Enter price of product: ");
                            string priceInput = Console.ReadLine();
                            if (Double.TryParse(priceInput, out z))
                            {
                                price2      = Math.Round(Convert.ToDouble(priceInput), 2);
                                validPrice2 = true;
                            }
                            else
                            {
                                Console.WriteLine("Please enter valid price.");
                            }
                        }
                        products = AddItem(products, product2, price2);
                    }
                }
                AddTransaction(name, month, TransactionDatabase.TransactionNumber, date, TDB, products);
                Console.WriteLine(ReceiptGenerator.generateReceipt(TDB.transactions[TransactionDatabase.TransactionNumber]));
                TransactionDatabase.TransactionNumber += 1;
                products = new List <Product>();
                Console.WriteLine("Press enter to enter a new transaction");
                enterNew = Console.ReadLine();
            }
        }