Beispiel #1
0
 public void GenerateRecipt()
 {
     output.Append($"Date: {DateTime.Now:MMMM dd, yyyy HH:mm}{Environment.NewLine}");
     output.Append($"Stay Charge: ${DaysCharge.ToString()}{Environment.NewLine}");
     output.Append($"Miscellaneous Charge: ${MiscCharge.ToString()}{Environment.NewLine}");
     output.Append($"Tax: ${TotalTax.ToString()}{Environment.NewLine}");
     output.Append($"Total: ${TotalWithTax.ToString()}{Environment.NewLine}");
     output.AppendLine();
     File.AppendAllText(fullName, output.ToString());
 }
        /// <summary>
        /// Creates the reciept to be sent to the printer
        /// </summary>
        /// <param name="cardOrCash">0 if card 1 if cash</param>
        private void PrintReceipt(int cardOrCash)
        {
            ReceiptPrinter rp = new ReceiptPrinter();
            StringBuilder  sb = new StringBuilder();

            sb.Append("---------- COWBOY CAFE ----------\n");
            sb.Append(DateTime.Now + "\n");
            sb.Append("Order #: " + PrevOrderNumber + "\n");

            /* Iterate over all items */
            foreach (IOrderItem i in Items)
            {
                sb.Append(i.ToString() + "\t\t" + i.Price.ToString("C2") + "\n");

                /* Iterate through the special instruction for the item i */
                foreach (string s in i.SpecialInstructions)
                {
                    sb.Append(s + "\n");
                }

                sb.Append("\n");
            }

            sb.Append("Subtotal: " + Subtotal.ToString("C2") + "\n");
            sb.Append("Tax: " + Tax.ToString("C2") + "\n");
            sb.Append("Total: " + TotalWithTax.ToString("C2") + "\n\n");

            if (cardOrCash == 1)
            {
                sb.Append("Paid: " + Paid.ToString("C2") + "\n");
                sb.Append("Change: " + Change.ToString("C2") + "\n");
            }
            else
            {
                sb.Append("Credit Card was used!\n");
            }

            string sr = sb.ToString();

            MessageBox.Show(sr);
            rp.Print(sr);
            ShowDrawerContents();
            SetNewOrder();
        }