コード例 #1
0
        private void CompleteOrder()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Order Number: " + order.Number + " | ");
            sb.Append(DateTime.Today.Month + "/" + DateTime.Today.Day + "/" + DateTime.Today.Year + " | ");
            IEnumerator <IOrderItem> en = order.GetEnumerator();

            while (en.Current != null)
            {
                List <string> instructions = en.Current.SpecialInstructions;
                sb.Append(en.Current.ToString() + " " + en.Current.Price + " ");
                foreach (string s in instructions)
                {
                    sb.Append(s + " ");
                }
                sb.Append("| ");
            }
            sb.Append(order.Subtotal + " | ");
            sb.Append(order.Tax + " | ");
            sb.Append(order.Total + " | ");
            sb.Append("Paid by card | ");
            sb.Append("No change owed |");
            int    length  = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(sb.Length) / 40.0));
            string reciept = sb.ToString();

            for (int i = 0; i < length - 1; i++)
            {
                int start = i == 0 ? 0 : (i * 40) - 1;
                RecieptPrinter.PrintLine(reciept.Substring(start, 40));
            }
            RecieptPrinter.PrintLine(reciept.Substring(((length - 1) * 40) - 1));
            RecieptPrinter.CutTape();
        }