}//end FinishCashProcessing() /// <summary> /// Prints out a particulat string to the reciept and cuts the tape /// </summary> /// <param name="message">the message to be printed on the /// reciept</param> private void PrintReciept(string message) { StringBuilder sb = new StringBuilder(); int lastNewLine = 0; for(int i = 0; i < message.Length; i++) { if (message[i] != '\n') lastNewLine++; else lastNewLine = 0; sb.Append(message[i]); if(lastNewLine >= 39) { sb.Append('\n'); lastNewLine = 0; }//end if we need to add an extra \n character }//end looping for each index of message //actually gets that string printed out with all those newlines string output = sb.ToString(); //write the reciept to the file File.Create("reciept.txt").Dispose(); /* string fullPath = System.IO.Path.GetFullPath("reciept.txt"); using(StreamWriter sw = File.CreateText(fullPath)) { sw.WriteLine(output); }//end use of stream writer= */ sb.Clear(); for (int i = 0; i < output.Length; i++) { if(output[i] != '\n') { sb.Append(output[i]); }//end if we have more to add to this line else { //for some reason this seems to be printing to my reciept file. Why??? RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); }//end else we want to print the line to the printer }//end looping to actually print out everything if (sb.Length > 0) RecieptPrinter.PrintLine(sb.ToString()); //cuts off the end of the reciept so that it can detach RecieptPrinter.CutTape(); }//end PrintReciept(card)
/// <summary> /// Prints out a reciept to the reciepts file after an order has been paid for. /// </summary> /// <param name="type">The PaymentType that was used to complete the order.</param> /// <param name="changeOwed">The amount of change that was owed to the customer.</param> public void PrintReciept(PaymentType type, double changeOwed) { RecieptPrinter.PrintLine("Bleakwind Buffet Order #" + _orderNumber); RecieptPrinter.PrintLine("Time: " + DateTime.Now); RecieptPrinter.PrintLine("\nItems: " + DateTime.Now); foreach (IOrderItem item in this) { string it = " " + item.ToString(); if (it.Length >= 40) { foreach (string s in LimitLine(it)) { RecieptPrinter.PrintLine(s); } } else { RecieptPrinter.PrintLine(it); } foreach (string specialI in item.SpecialInstructions) { string working = " - " + specialI; if (working.Length >= 40) { foreach (string s in LimitLine(working)) { RecieptPrinter.PrintLine(s); } } else { RecieptPrinter.PrintLine(working); } } } RecieptPrinter.PrintLine("\nSubtotal: $" + Math.Truncate(Subtotal * 100) / 100); RecieptPrinter.PrintLine("Tax: $" + Math.Truncate(Tax * 100) / 100); RecieptPrinter.PrintLine("Total: $" + Math.Truncate(Total * 100) / 100); if (type == PaymentType.Card) { RecieptPrinter.PrintLine("Payment Type: Card"); } else { RecieptPrinter.PrintLine("Payment Type: Cash"); } RecieptPrinter.PrintLine("Change: $" + Math.Truncate(changeOwed * 100) / 100); RecieptPrinter.CutTape(); }
/// <summary> /// Prints the things needed for the reciept /// </summary> public void printItems() { foreach (string line in items) { if (line.Length < 40) { RecieptPrinter.PrintLine(line); } else { RecieptPrinter.CutTape(); } } RecieptPrinter.CutTape(); }
public void PrintReceipt(int paymentMethod, double change) { RecieptPrinter.PrintLine("Order " + _order.Number); DateTime time = DateTime.Now; RecieptPrinter.PrintLine(time.ToString()); //A complete list of all items in the order, including their price and special instructions RecieptPrinter.PrintLine("---ORDER---"); foreach (IOrderItem item in _order) { if (item.ToString().Length <= 40) { RecieptPrinter.PrintLine(item.ToString()); } else { string first = item.ToString().Substring(0, 40); string second = item.ToString().Substring(40); } foreach (string text in item.SpecialInstructions) { RecieptPrinter.PrintLine(" -" + text); } } RecieptPrinter.PrintLine("---------------------------------------"); RecieptPrinter.PrintLine("Subtotal: $" + _order.Subtotal.ToString("0.##")); RecieptPrinter.PrintLine("Tax: $" + _order.Tax.ToString("0.##")); RecieptPrinter.PrintLine("Total: $" + _order.Total.ToString("0.##")); if (paymentMethod == 0) { RecieptPrinter.PrintLine("---Cash Payment---"); RecieptPrinter.PrintLine("Change Owed: $" + change.ToString("0.##")); } else if (paymentMethod == 1) { RecieptPrinter.PrintLine("---Card Payment---"); } RecieptPrinter.CutTape(); }
void OnFinalizeClick(object sender, RoutedEventArgs e) { String[] recieptArr = { "Order #" + order.Number.ToString(), GetDataTime(), "SubTotal: " + order.Subtotal.ToString(), "Tax: " + order.Tax.ToString(), "Total: " + order.Total.ToString() }; try { foreach (String str in recieptArr) { if (str.ToCharArray().Length > 40) { throw new Exception("Content for Reciept to long"); } } RecieptPrinter.PrintLine("Order #" + order.Number.ToString()); RecieptPrinter.PrintLine(GetDataTime()); foreach (IOrderItem item in order) { RecieptPrinter.PrintLine(item.ToString() + ":"); foreach (String spec in item.SpecialInstructions) { RecieptPrinter.PrintLine("-" + spec); } } RecieptPrinter.PrintLine(""); RecieptPrinter.PrintLine("SubTotal: " + order.Subtotal.ToString()); RecieptPrinter.PrintLine("Tax: " + order.Tax.ToString()); RecieptPrinter.PrintLine("Total: " + order.Total.ToString()); RecieptPrinter.PrintLine("Payment Type: " + order.PaymentType); RecieptPrinter.PrintLine("Change: " + order.ChangeOwed); RecieptPrinter.CutTape(); DependencyObject parent = this; do { // Get this node's parent parent = LogicalTreeHelper.GetParent(parent); }while (!(parent is null || parent is MainWindow)); MainWindow mw = parent as MainWindow; mw.CancelOrder(); } catch { throw new Exception("Error in Printing Reciept"); } }
private void StringChecker(string s) { string sCut; if (s.Length <= 40) { RecieptPrinter.PrintLine(s); } else { int indexo = s.Length; sCut = s.Substring(0, 40); RecieptPrinter.PrintLine(s.Substring(0, 40)); StringChecker(sCut); } }
private void CreditSelection(object sender, RoutedEventArgs e) { var o = this.FindAncestor <OrderControl>(); uint Ordernum = ((OrderControl)o).orderNum; CardTransactionResult result = CardReader.RunCard((o.DataContext as Order).Total); if (result == CardTransactionResult.Approved) { RecieptPrinting(); RecieptPrinter.CutTape(); o.DataContext = new Order(Ordernum); o.LeftContainer.Child = new MenuSelection(); } else { ErrorReport.Text = "Transaction Failed With: " + result.ToString() + "!"; } }
/// <summary> /// Prints the receipt to the dll /// </summary> /// <param name="typeofPayment"></param> /// <param name="totalChange"></param> public void PrintReciept(string typeofPayment, double totalChange) { RecieptPrinter.PrintLine("Order # " + usethisOrder.OrderNumber.ToString()); RecieptPrinter.PrintLine(DateTime.Now.ToString()); foreach (IOrderItem item in window.newOrder.Items) { RecieptPrinter.PrintLine(item.ToString() + " $" + item.Price); foreach (string specialstruc in item.SpecialInstructions) { RecieptPrinter.PrintLine("-" + specialstruc); } } RecieptPrinter.PrintLine("SubTotal: $" + window.newOrder.Subtotal.ToString()); RecieptPrinter.PrintLine("Tax: $" + window.newOrder.SalesTax.ToString()); RecieptPrinter.PrintLine("Total: $" + window.newOrder.Total.ToString()); RecieptPrinter.PrintLine("Payment Type: " + typeofPayment); RecieptPrinter.PrintLine("Change: $" + totalChange.ToString()); RecieptPrinter.CutTape(); }
public void PrintReceiptCash(double ChangeDue) { //this.order = order; //StreamWriter file = new StreamWriter("../../../debug/receipts2.txt"); RecieptPrinter.PrintLine("Order: " + order.Number.ToString()); DateTime localDate = DateTime.Now; RecieptPrinter.PrintLine(localDate.ToString()); int ComboCount = 0; RecieptPrinter.PrintLine(""); foreach (IOrderItem item in order) { if (item is Combo) { RecieptPrinter.PrintLine("Combo Meal"); RecieptPrinter.PrintLine("_______________________________"); ComboCount = 1; } else { RecieptPrinter.PrintLine(item.ToString()); } foreach (String instruction in item.SpecialInstructions) { RecieptPrinter.PrintLine(" - " + instruction); } if (ComboCount == 1) { ComboCount = 0; RecieptPrinter.PrintLine("_______________________________"); } } RecieptPrinter.PrintLine(""); RecieptPrinter.PrintLine("Subtotal: " + order.Subtotal.ToString()); RecieptPrinter.PrintLine("Tax: " + order.Tax.ToString()); RecieptPrinter.PrintLine("Total: " + order.Total.ToString()); RecieptPrinter.PrintLine("Payment Method: Cash"); RecieptPrinter.PrintLine("Change Due: " + ChangeDue.ToString()); RecieptPrinter.CutTape(); }
/// <summary> /// Updates cash register and prints receipt /// </summary> /// <param name="viewModel">current view model</param> /// <param name="payment">type of payment</param> /// <param name="orderDate">date in which order was created</param> public static void UpdateCashDrawerValues(CashDrawerViewModel viewModel, string payment, DateTime orderDate) { CashDrawer.OpenDrawer(); AddTenured(viewModel); SubtractChange(viewModel); RecieptPrinter.PrintLine($"Order #{viewModel.order.Number}"); RecieptPrinter.PrintLine($"{orderDate}"); for (int i = 0; i < viewModel.order.Count; i++) { RecieptPrinter.PrintLine(viewModel.order[i].ToString()); for (int j = 0; j < viewModel.order[i].SpecialInstructions.Count; j++) { RecieptPrinter.PrintLine($"\t {viewModel.order[i].SpecialInstructions[j]}"); } } RecieptPrinter.PrintLine($"Subtotal: {viewModel.SubTotal}"); RecieptPrinter.PrintLine($"Tax: {viewModel.Tax}"); RecieptPrinter.PrintLine($"Total: {viewModel.Total}"); RecieptPrinter.PrintLine($"{payment}"); RecieptPrinter.PrintLine($"Change Due: {viewModel.ChangeOwed}"); //FIXME make sure using right prop here RecieptPrinter.CutTape(); }
/// <summary> /// Prints the Reciept of the current Order in a text file /// </summary> /// <param name="paymentMethod">the type of customer payment</param> /// <param name="changeOwed">the changed owed to the customer</param> public void PrintReciept(string paymentMethod, double changeOwed) //can I set a Button inside of Cash and credit Classes? { RecieptPrinter.PrintLine("Order # " + currentOrder.newOrder.OrderNumber.ToString()); //order number RecieptPrinter.PrintLine(DateTime.Now.ToString()); //date&time foreach (IOrderItem food in currentOrder.newOrder.ListOrder) { RecieptPrinter.PrintLine(food.ToString() + " $" + food.Price); foreach (string custom in food.SpecialInstructions) { RecieptPrinter.PrintLine("-" + custom); } } RecieptPrinter.PrintLine("SubTotal: $" + currentOrder.newOrder.Subtotal.ToString()); //subtotal RecieptPrinter.PrintLine("Tax: $" + currentOrder.newOrder.Tax.ToString()); //Tax RecieptPrinter.PrintLine("Total: $" + currentOrder.newOrder.Total.ToString()); //Total //make a parameter for which payment method was used? RecieptPrinter.PrintLine("Payment Type: " + paymentMethod); //payment method RecieptPrinter.PrintLine("Changed: $" + changeOwed.ToString()); //0.00 for credit/debit RecieptPrinter.CutTape(); //make sure 1 reciept line is no longer than 40 characters }
public void PrintReceiptCard() { RecieptPrinter.PrintLine("Order:" + order.Number.ToString()); DateTime localDate = DateTime.Now; RecieptPrinter.PrintLine(localDate.ToString()); RecieptPrinter.PrintLine(""); int ComboCount = 0; foreach (IOrderItem item in order) { if (item is Combo) { RecieptPrinter.PrintLine("Combo Meal"); RecieptPrinter.PrintLine("_______________________________"); ComboCount = 1; } else { RecieptPrinter.PrintLine(item.ToString()); } foreach (String instruction in item.SpecialInstructions) { RecieptPrinter.PrintLine(" - " + instruction); } if (ComboCount == 1) { ComboCount = 0; RecieptPrinter.PrintLine("_______________________________"); } } RecieptPrinter.PrintLine(""); RecieptPrinter.PrintLine("Subtotal: " + order.Subtotal.ToString()); RecieptPrinter.PrintLine("Tax: " + order.Tax.ToString()); RecieptPrinter.PrintLine("Total: " + order.Total.ToString()); RecieptPrinter.PrintLine("Payment Method: Cash"); RecieptPrinter.PrintLine("Change Due: 0"); RecieptPrinter.CutTape(); }
/// <summary> /// the method used to end the current payment and print the receipt /// </summary> /// <param name="x"> the type of paymenty used </param> public void endPayment(string x) { amountDue.Content = "$0.00"; PaymentOptions.Child = null; RecieptPrinter.PrintLine("Order #" + currentOrder._orderNumber.ToString()); RecieptPrinter.PrintLine("10/15/2020 12:36"); foreach (object temp in currentOrder.orders) { if (temp is Combo item) { RecieptPrinter.PrintLine(item.ToString()); RecieptPrinter.PrintLine("Price: $" + Math.Round(item.Price, 2, MidpointRounding.AwayFromZero)); foreach (string thing in item.SpecialInstructions) { RecieptPrinter.PrintLine("- " + thing); } } else { IOrderItem orderItem = (IOrderItem)temp; RecieptPrinter.PrintLine(orderItem.ToString()); RecieptPrinter.PrintLine("Price: $" + orderItem.Price.ToString()); foreach (string thing in orderItem.SpecialInstructions) { RecieptPrinter.PrintLine("- " + thing); } } } RecieptPrinter.PrintLine("Subtotal: $" + Math.Round(currentOrder._subTotal, 2, MidpointRounding.AwayFromZero).ToString()); RecieptPrinter.PrintLine("Tax: $" + Math.Round(currentOrder._tax, 2, MidpointRounding.AwayFromZero).ToString()); RecieptPrinter.PrintLine("Total: $" + Math.Round(currentOrder._total, 2, MidpointRounding.AwayFromZero).ToString()); RecieptPrinter.PrintLine("Payment in " + x); RecieptPrinter.PrintLine("Change $" + Math.Round(changeDue, 2, MidpointRounding.AwayFromZero).ToString()); RecieptPrinter.CutTape(); currentOrder.parent.overrideBorder.Child = null; currentOrder.resetOrder(); }
/// <summary> /// Method for printing the reciept /// </summary> /// <param name="card">Whether the customer is paying with a card or not</param> private void PrintReceipt(bool card) { DateTime currentTime = DateTime.Now; if (DataContext is Order order) { RecieptPrinter.PrintLine("Order Number:\t" + Order.OrderNumber.ToString()); RecieptPrinter.PrintLine("\n" + currentTime.ToString() + "\n\n"); foreach (IOrderItem item in order) { RecieptPrinter.PrintLine(item.ToString() + "\t" + item.Price.ToString("C2") + "\n"); int temp = 0; while (temp < item.SpecialInstructions.Count) { RecieptPrinter.PrintLine("\t" + item.SpecialInstructions[temp].ToString() + "\n"); temp++; } } RecieptPrinter.PrintLine("\nSubtotal:\t" + order.Subtotal.ToString("C2")); RecieptPrinter.PrintLine("\nTax:\t" + order.Tax.ToString("C2")); RecieptPrinter.PrintLine("\nTotal:\t\t" + order.Total.ToString("C2")); if (card) { RecieptPrinter.PrintLine("\nPayment Type:\tCredit\n\n\n"); RecieptPrinter.CutTape(); } else { RecieptPrinter.PrintLine("\nPayment Type:\tCash"); RecieptPrinter.CutTape(); } } }
/// <summary> /// Creates Printable Order reciebt /// </summary> public void PrintOrder(string method, string payment, string change) { List <string> printable = new List <string>(); string topline = "Bleakwind Buffet"; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2)) + topline + String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2))); topline = "Phone Number: 785-123-4567"; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2)) + topline + String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2))); topline = "12345 Food Drive"; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2)) + topline + String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2))); topline = "Manhattan, KS"; printable.Add(String.Join("", Enumerable.Repeat(" ", ((40 - topline.Length) / 2) + 1)) + topline + String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2))); printable.Add(String.Join("", Enumerable.Repeat(" ", 40))); topline = "Order #" + price.OrderNumber; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2)) + topline + String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2))); printable.Add(String.Join("", Enumerable.Repeat(" ", 40))); printable.Add(String.Join("", Enumerable.Repeat("-", 40))); foreach (IOrderItem k in price) { string priceLine = " | $" + Math.Round(k.Price, 2); string blankLine = " | " + String.Join("", Enumerable.Repeat(" ", Math.Round(k.Price, 2).ToString().Length)); int wordCount = 40 - priceLine.Length; int WordsInLine = 0; bool firstLine = true; string curLine = ""; string[] words = k.ToString().Replace("\n", " ").Split(' '); if (k is ComboMeal comb) { string phrase = "Combo Meal:"; printable.Add(phrase + String.Join("", Enumerable.Repeat(" ", (40 - phrase.Length - priceLine.Length))) + priceLine); IOrderItem curItem = comb.Entree; for (int i = 0; i < 3; i++) { words = curItem.ToString().Replace("\n", " ").Split(' '); curLine = ""; firstLine = false; WordsInLine = 0; wordCount = 40 - blankLine.Length; foreach (string word in words) { if (word.Length > wordCount && WordsInLine == 0) // if line wanted to print is too long to be printed in one line { printable.Add(word.Substring(0, wordCount) + blankLine); string unUsed = word.Substring(wordCount); bool toolong = true; while (toolong) { if (unUsed.Length > wordCount) { printable.Add(word.Substring(0, wordCount) + blankLine); unUsed = word.Substring(wordCount); } else { printable.Add(word.Substring(0, wordCount) + blankLine); toolong = false; } } } // if line wanted to print is too long to be printed in one line else if (word.Length > wordCount && word.Length > (40 - blankLine.Length))// if line wanted to add new word but the word is too long for one line { printable.Add(curLine + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); wordCount = 40 - blankLine.Length; curLine = ""; WordsInLine = 0; printable.Add(word.Substring(0, wordCount) + blankLine); string unUsed = word.Substring(wordCount); bool toolong = true; while (toolong) { if (unUsed.Length > wordCount) { printable.Add(word.Substring(0, wordCount) + blankLine); unUsed = word.Substring(wordCount); } else { wordCount -= word.Length; printable.Add(word.Substring(0, wordCount) + Enumerable.Repeat(" ", wordCount) + blankLine); toolong = false; } } wordCount = 40 - blankLine.Length; }// if line wanted to add new word but the word is too long for one line else if (word.Length > (wordCount - 1)) { printable.Add(curLine + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); curLine = word; wordCount = 40 - blankLine.Length - word.Length; WordsInLine = 1; } else if (word.Length == (wordCount - 1)) { printable.Add(curLine + " " + word + blankLine); curLine = ""; wordCount = 40 - blankLine.Length; WordsInLine = 0; } else { curLine += " " + word; wordCount -= (word.Length + 1); WordsInLine += 1; } } if (curLine.Length != 0) { printable.Add(curLine + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); } string startLine = "\t-"; wordCount = 40 - blankLine.Length - startLine.Length; foreach (string instruction in curItem.SpecialInstructions) { if (instruction.Length > wordCount) { printable.Add(startLine + instruction.Substring(0, wordCount) + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); wordCount = 40 - blankLine.Length - startLine.Length; } else { wordCount -= instruction.Length; printable.Add(startLine + instruction + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); wordCount = 40 - blankLine.Length - startLine.Length; } } if (i == 0) { curItem = comb.Side; } else if (i == 1) { curItem = comb.Drink; } } } else { foreach (string word in words) { if (word.Length > wordCount && WordsInLine == 0) // if line wanted to print is too long to be printed in one line { if (firstLine) { printable.Add(word.Substring(0, wordCount) + priceLine); string unUsed = word.Substring(wordCount); firstLine = false; bool toolong = true; while (toolong) { if (unUsed.Length > wordCount) { printable.Add(word.Substring(0, wordCount) + blankLine); unUsed = word.Substring(wordCount); } else { wordCount -= word.Length; printable.Add(word.Substring(0, wordCount) + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); toolong = false; } } wordCount = 40 - blankLine.Length; } else { printable.Add(word.Substring(0, wordCount) + blankLine); string unUsed = word.Substring(wordCount); firstLine = false; bool toolong = true; while (toolong) { if (unUsed.Length > wordCount) { printable.Add(word.Substring(0, wordCount) + blankLine); unUsed = word.Substring(wordCount); } else { printable.Add(word.Substring(0, wordCount) + blankLine); toolong = false; } } } } // if line wanted to print is too long to be printed in one line else if (word.Length > wordCount && word.Length > (40 - priceLine.Length))// if line wanted to add new word but the word is too long for one line { if (firstLine) { printable.Add(curLine + String.Join("", Enumerable.Repeat(" ", wordCount)) + priceLine); firstLine = false; } else { printable.Add(curLine + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); } wordCount = 40 - blankLine.Length; curLine = ""; WordsInLine = 0; printable.Add(word.Substring(0, wordCount) + blankLine); string unUsed = word.Substring(wordCount); firstLine = false; bool toolong = true; while (toolong) { if (unUsed.Length > wordCount) { printable.Add(word.Substring(0, wordCount) + blankLine); unUsed = word.Substring(wordCount); } else { wordCount -= word.Length; printable.Add(word.Substring(0, wordCount) + Enumerable.Repeat(" ", wordCount) + blankLine); toolong = false; } } wordCount = 40 - blankLine.Length; }// if line wanted to add new word but the word is too long for one line else if (word.Length > (wordCount - 1)) { if (firstLine) { printable.Add(curLine + String.Join("", Enumerable.Repeat(" ", wordCount)) + priceLine); firstLine = false; } else { printable.Add(curLine + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); } curLine = word; wordCount = 40 - blankLine.Length - word.Length; WordsInLine = 1; } else if (word.Length == (wordCount - 1)) { if (firstLine) { printable.Add(curLine + " " + word + priceLine); firstLine = false; } else { printable.Add(curLine + " " + word + blankLine); } curLine = ""; wordCount = 40 - blankLine.Length; WordsInLine = 0; } else { curLine += " " + word; wordCount -= (word.Length + 1); WordsInLine += 1; } } if (curLine.Length != 0) { if (firstLine == true) { printable.Add(curLine + String.Join("", Enumerable.Repeat(" ", wordCount)) + priceLine); } else { printable.Add(curLine + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); } } string startLine = "\t-"; wordCount = 40 - blankLine.Length - startLine.Length; foreach (string instruction in k.SpecialInstructions) { if (instruction.Length > wordCount) { printable.Add(startLine + instruction.Substring(0, wordCount) + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); wordCount = 40 - blankLine.Length - startLine.Length; } else { wordCount -= instruction.Length; printable.Add(startLine + instruction + String.Join("", Enumerable.Repeat(" ", wordCount)) + blankLine); wordCount = 40 - blankLine.Length - startLine.Length; } } } printable.Add(String.Join("", Enumerable.Repeat("-", 40))); } topline = "SubTotal: " + price.Subtotal; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length))) + topline); topline = "Tax: " + price.Tax; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length))) + topline); topline = "Total: " + price.Total; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length))) + topline); printable.Add(String.Join("", Enumerable.Repeat(" ", 40))); topline = "Payment Method: " + method; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2)) + topline + String.Join("", Enumerable.Repeat(" ", (40 - topline.Length) / 2))); topline = "Amount Paid: " + payment; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length))) + topline); topline = "Change Given: " + change; printable.Add(String.Join("", Enumerable.Repeat(" ", (40 - topline.Length))) + topline); /* * string printing = ""; * foreach (string r in printable) * { * printing += r + r.Length.ToString() + "\n"; * } * MessageBox.Show(printing); * /*/ foreach (string r in printable) { RecieptPrinter.PrintLine(r); } RecieptPrinter.CutTape(); //*/ }
/// <summary> /// Helper method to print receipt when called. /// </summary> /// <param name="change">Total change owed to the customer.</param> private void PrintReceipt(double change) { RecieptPrinter.PrintLine("Order #" + Convert.ToString(currentOrder.Number)); RecieptPrinter.PrintLine(""); //RecieptPrinter.PrintLine(date and time) foreach (IOrderItem item in currentOrder) { if (item is Combo co) { RecieptPrinter.PrintLine("$" + co.Price + " " + co.Name); } else if (item is AretinoAppleJuice aj) { RecieptPrinter.PrintLine("$" + aj.Price + " " + aj.Name); } else if (item is CandlehearthCoffee cc) { RecieptPrinter.PrintLine("$" + cc.Price + " " + cc.Name); } else if (item is MarkarthMilk mm) { RecieptPrinter.PrintLine("$" + mm.Price + " " + mm.Name); } else if (item is SailorSoda ss) { RecieptPrinter.PrintLine("$" + ss.Price + " " + ss.Name); } else if (item is WarriorWater ww) { RecieptPrinter.PrintLine("$" + ww.Price + " " + ww.Name); } else if (item is BriarheartBurger bb) { RecieptPrinter.PrintLine("$" + bb.Price + " " + bb.Name); } else if (item is DoubleDraugr dd) { RecieptPrinter.PrintLine("$" + dd.Price + " " + dd.Name); } else if (item is GardenOrcOmelette goo) { RecieptPrinter.PrintLine("$" + goo.Price + " " + goo.Name); } else if (item is PhillyPoacher pp) { RecieptPrinter.PrintLine("$" + pp.Price + " " + pp.Name); } else if (item is SmokehouseSkeleton sms) { RecieptPrinter.PrintLine("$" + sms.Price + " " + sms.Name); } else if (item is ThalmorTriple tt) { RecieptPrinter.PrintLine("$" + tt.Price + " " + tt.Name); } else if (item is ThugsTBone ttb) { RecieptPrinter.PrintLine("$" + ttb.Price + " " + ttb.Name); } else if (item is DragonbornWaffleFries dwf) { RecieptPrinter.PrintLine("$" + dwf.Price + " " + dwf.Name); } else if (item is FriedMiraak fm) { RecieptPrinter.PrintLine("$" + fm.Price + " " + fm.Name); } else if (item is MadOtarGrits mog) { RecieptPrinter.PrintLine("$" + mog.Price + " " + mog.Name); } else if (item is VokunSalad vs) { RecieptPrinter.PrintLine("$" + vs.Price + " " + vs.Name); } foreach (string instruction in item.SpecialInstructions) { RecieptPrinter.PrintLine(" -" + instruction); } } RecieptPrinter.PrintLine(""); RecieptPrinter.PrintLine("Subtotal: $" + String.Format("{0:0.00}", Convert.ToString(currentOrder.Subtotal))); RecieptPrinter.PrintLine("Tax: $" + String.Format("{0:0.00}", Convert.ToString(currentOrder.Tax))); RecieptPrinter.PrintLine("Total: $" + String.Format("{0:0.00}", Convert.ToString(currentOrder.Total))); RecieptPrinter.PrintLine("Payment Method: Cash"); RecieptPrinter.PrintLine("Change: " + Math.Round(change, 2)); RecieptPrinter.CutTape(); }
/// <summary> /// cut register tape to remove /// </summary> public void CutTape() { RecieptPrinter.CutTape(); }
/// <summary> /// items to print on a credit card receipt /// </summary> /// <param name="text">text to print</param> public void PrintLine(string text) { RecieptPrinter.PrintLine(text); }
private void RecieptPrinting() { int spaces; StringBuilder sb = new StringBuilder(); Order o = (this.DataContext as Order); for (int i = 0; i < 45; i++) { sb.Append("_"); } RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); sb.Append("Order "); sb.Append(o.OrderNumber.ToString()); RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); sb.Append("Date: "); sb.Append(DateTime.Now.ToString()); RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); foreach (IOrderItem item in o) { sb.Append(" -"); sb.Append(item); spaces = SpacesNeeded(item.ToString().Length, item.Price); for (int i = 0; i < spaces; i++) { sb.Append(" "); } sb.AppendFormat("{0:C}", item.Price); RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); if (item.SpecialInstructions != null) { foreach (string instruction in item.SpecialInstructions) { sb.Append(" "); sb.Append(instruction); RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); } } } for (int i = 0; i < 45; i++) { sb.Append("."); } RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); sb.Append("Subtotal:"); spaces = 3 + SpacesNeeded("Subtotal:".Length, o.Subtotal); for (int i = 0; i < spaces; i++) { sb.Append(" "); } sb.AppendFormat("{0:C}", o.Subtotal); RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); sb.Append("Tax:"); spaces = 3 + SpacesNeeded("Tax:".Length, o.Tax); for (int i = 0; i < spaces; i++) { sb.Append(" "); } sb.AppendFormat("{0:C}", o.Tax); RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); sb.Append("Total after tax:"); spaces = SpacesNeeded("Total after tax:".Length, o.Total); for (int i = 0; i < spaces; i++) { sb.Append(" "); } sb.AppendFormat("{0:C}", o.Total); RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); RecieptPrinter.PrintLine("Processed by: Credit"); sb.Clear(); sb.Append("Change:"); spaces = SpacesNeeded("Change:".Length + 3, 0.00); for (int i = 0; i < spaces; i++) { sb.Append(" "); } sb.Append("$0.00"); RecieptPrinter.PrintLine(sb.ToString()); sb.Clear(); }