void buttonOk_Click(object sender, RoutedEventArgs e) { // Yuck, but it works DateTime nowTime = DateTime.Now; int? intValue = OrderEntryCommands.GetPrepTime().IntValue; if (intValue != null) { DateTime earliestTime = nowTime + new TimeSpan(0, intValue.Value - 1, 60 - nowTime.Second); if (SelectedDateTime != null && SelectedDateTime.Value < (earliestTime - new TimeSpan(0, 1, 0))) { PosDialogWindow.ShowDialog( Strings.FutureTimeTooEarly + earliestTime.ToLongTimeString(), Strings.FutureTimeTooEarlyError); } else { KeepChanges = true; // Closes the dialog window Window.GetWindow(this).Close(); } } }
private static void PrintTicketItems(IEnumerable <TicketItem> ticketItems, PrintDestination printDestination, PosPrinter printer, Ticket ticket, TicketItemPrintOptions printOptions) { DateTime realStartTime = SqlDateTime.MaxValue.Value; if (ticket.StartTime != null) { int?intValue = OrderEntryCommands.GetPrepTime().IntValue; if (intValue != null) { realStartTime = (ticket.StartTime.Value - new TimeSpan(0, 0, ticket.StartTime.Value.Second) - new TimeSpan(0, intValue.Value, 0)); } } bool showMakeTags = (((printDestination == PrintDestination.Kitchen1) || (printDestination == PrintDestination.Kitchen2) || (printDestination == PrintDestination.Kitchen3)) && ((ticket.StartTime == null) || (realStartTime <= DateTime.Now))); // Hide make tags on ticket voids and cancels if ((printOptions == TicketItemPrintOptions.AllAsVoid) || (printOptions == TicketItemPrintOptions.AllAsCancelMade) || (printOptions == TicketItemPrintOptions.AllAsCancelUnmade) || (printOptions == TicketItemPrintOptions.TicketRefund) || (printOptions == TicketItemPrintOptions.TicketItemReturn) || (printOptions == TicketItemPrintOptions.TicketItemVoid)) { showMakeTags = false; } foreach (TicketItem ticketItem in ticketItems) { PrintTicketItemToReceipt(printer, ticketItem, showMakeTags, printOptions, ticket.Type); } }
private static void PrintHeaderInformation(PrintDestination printDestination, PosPrinter printer, Ticket ticket, TicketItemPrintOptions printOptions) { // Print the receipt header image string filename = "receipt-header.gif"; if (File.Exists(filename)) { PrintToReceipt(printer, PrinterEscapeCodes.SetCenter); printer.PrintBitmap(PrinterStation.Receipt, filename, 200, PosPrinter.PrinterBitmapCenter); } // Occasion / Seating Information if (ConfigurationManager.UseSeating) { PrintLineToReceipt(printer, PrinterEscapeCodes.SetCenter + ticket.Type.GetFriendlyName()); } // Print Ticket Number PrintLineToReceipt(printer, ((ticket.OrderId == null) ? "" : Strings.Order + ticket.OrderId.Value + ", ") + Strings.Ticket + ticket.PrimaryKey.Id); Person person = PersonManager.GetPersonByEmployeeId(ticket.EmployeeId); PrintLineToReceipt(printer, Strings.Employee + ": " + person.FirstName + " " + person.LastName.Substring(0, 1)); if (ticket.SeatingId > 0) { Seating seating = SeatingManager.GetSeating(ticket.SeatingId); PrintLineToReceipt(printer, Strings.Table + seating.Description); } // Print date and time (now, future time, or ticket close time) DateTime time = DateTime.Now; int? intValue = OrderEntryCommands.GetPrepTime().IntValue; if (printOptions == TicketItemPrintOptions.AllAsVoid) { PrintLineToReceipt(printer, PrinterEscapeCodes.SetCenter + Strings.TicketVoid); } else if (printOptions == TicketItemPrintOptions.TicketRefund) { PrintLineToReceipt(printer, PrinterEscapeCodes.SetCenter + Strings.TicketRefund); } else if (printOptions == TicketItemPrintOptions.AllAsCancelMade) { PrintLineToReceipt(printer, PrinterEscapeCodes.SetCenter + Strings.TicketCancelMade); } else if (printOptions == TicketItemPrintOptions.AllAsCancelUnmade) { PrintLineToReceipt(printer, PrinterEscapeCodes.SetCenter + Strings.TicketCancelUnmade); } else if (printOptions == TicketItemPrintOptions.TicketItemVoid) { PrintLineToReceipt(printer, PrinterEscapeCodes.SetCenter + Strings.TicketItemVoid); } else if (printOptions == TicketItemPrintOptions.TicketItemReturn) { PrintLineToReceipt(printer, PrinterEscapeCodes.SetCenter + Strings.TicketItemReturn); } else if (ticket.StartTime.HasValue && intValue.HasValue && ((ticket.StartTime.Value - new TimeSpan(0, 0, ticket.StartTime.Value.Second) - new TimeSpan(0, intValue.Value, 0)) >= time) && !ticket.IsClosed) { PrintLineToReceipt(printer, PrinterEscapeCodes.SetCenter + Strings.FutureOrder); time = ticket.StartTime.Value; } else if (ticket.StartTime.HasValue && !ticket.IsClosed) { PrintLineToReceipt(printer, PrinterEscapeCodes.SetCenter + Strings.MakeNow); time = ticket.StartTime.Value; } if (ticket.IsClosed && ticket.CloseTime.HasValue) { time = ticket.CloseTime.Value; } PrintLineToReceipt(printer, time.ToShortDateString() + PrinterEscapeCodes.SetRight + time.ToShortTimeString()); // Newline PrintLineToReceipt(printer); // Customer's Information bool isKitchen = ((printDestination == PrintDestination.Kitchen1) || (printDestination == PrintDestination.Kitchen2) || (printDestination == PrintDestination.Kitchen3)); if (!isKitchen && (ticket.CustomerId > 0)) { person = PersonManager.GetPersonByCustomerId(ticket.CustomerId); PrintLineToReceipt(printer, person.FirstName + " " + person.LastName); if ((ticket.Type == TicketType.Delivery) || (ticket.Type == TicketType.Catering)) { ZipCode zipCode = ZipCode.Get(person.ZipCodeId); ZipCodeCity zipCodeCity = ZipCodeCity.Get(zipCode.CityId); ZipCodeState zipCodeState = ZipCodeState.Get(zipCodeCity.StateId); PrintLineToReceipt(printer, person.AddressLine1); if (!string.IsNullOrEmpty(person.AddressLine2)) { PrintLineToReceipt(printer, person.AddressLine2); } PrintLineToReceipt(printer, zipCodeCity.City + ", " + zipCodeState.Abbreviation + " " + zipCode.PostalCode.ToString("D5")); } if (person.PhoneNumberId1 > 0) { PhoneNumber phoneNumber = PhoneNumber.Get(person.PhoneNumberId1); PrintLineToReceipt(printer, phoneNumber.GetFormattedPhoneNumber()); } // Newline PrintLineToReceipt(printer); } }