private static void Print(PrintDestination printDestination, PosPrinter printer, Ticket ticket, List <TicketItem> ticketItems, TicketItemPrintOptions printOptions, bool checkPrintDestination) { bool isKitchen = ((printDestination == PrintDestination.Kitchen1) || (printDestination == PrintDestination.Kitchen2) || (printDestination == PrintDestination.Kitchen3)); if (!HasPrintableTicketItems(ticketItems, printDestination, printOptions, checkPrintDestination)) { return; } #if DEBUG PrintLineToReceipt(printer, "** Debug: Printer Destination is \'" + printDestination + "\' **"); #endif // Header PrintHeaderInformation(printDestination, printer, ticket, printOptions); // Ticket Items PrintTicketItems(ticketItems, printDestination, printer, ticket, printOptions); // Footer if (!isKitchen) { PrintFooterInformation(printer, ticket); } }
public static void Print(PrintDestination printDestination, PosPrinter printer, Ticket ticket, TicketItemPrintOptions printOptions) { List <TicketItem> ticketItems = new List <TicketItem>(TicketItem.GetAll(ticket.PrimaryKey)); Print(printDestination, printer, ticket, ticketItems, printOptions, false); }
private void TogglePrintDestination(PrintDestination destination) { if (_haltEvents) { return; } PrintDestinations = ((checkBoxPrintDestinationJournal.IsSelected ? PrintDestination.Journal : PrintDestination.None) | (checkBoxPrintDestinationReceipt.IsSelected ? PrintDestination.Receipt : PrintDestination.None) | (checkBoxPrintDestinationKitchen1.IsSelected ? PrintDestination.Kitchen1 : PrintDestination.None) | (checkBoxPrintDestinationKitchen2.IsSelected ? PrintDestination.Kitchen2 : PrintDestination.None) | (checkBoxPrintDestinationKitchen3.IsSelected ? PrintDestination.Kitchen3 : PrintDestination.None) | (checkBoxPrintDestinationBar1.IsSelected ? PrintDestination.Bar1 : PrintDestination.None) | (checkBoxPrintDestinationBar2.IsSelected ? PrintDestination.Bar2 : PrintDestination.None) | (checkBoxPrintDestinationBar3.IsSelected ? PrintDestination.Bar3 : PrintDestination.None)); DoChangedValueEvent(ItemFieldName.PrintDestination); }
/// <summary> /// Adds an entry to the Item table /// </summary> public static Item Add(int categoryId, string itemName, string shortName, double price, int opSet1, int opSet2, int opSet3, PrintDestination printDestinations, bool active, int taxId, TimeSpan?prepareTime, bool isReturnable, bool isTaxExemptable, bool isFired, bool isOutOfStock, bool isGrouping, byte[] buttonImage = null) { Item result = null; bool isDiscontinued = false; SqlConnection cn = GetConnection(); using (SqlCommand sqlCmd = new SqlCommand("AddItem", cn)) { sqlCmd.CommandType = CommandType.StoredProcedure; BuildSqlParameter(sqlCmd, "@ItemCategoryId", SqlDbType.Int, categoryId); BuildSqlParameter(sqlCmd, "@ItemName", SqlDbType.Text, itemName); BuildSqlParameter(sqlCmd, "@ItemShortName", SqlDbType.Text, shortName); BuildSqlParameter(sqlCmd, "@ItemDefaultPrice", SqlDbType.Float, price); BuildSqlParameter(sqlCmd, "@ItemItemOptionSetId1", SqlDbType.Int, opSet1); BuildSqlParameter(sqlCmd, "@ItemItemOptionSetId2", SqlDbType.Int, opSet2); BuildSqlParameter(sqlCmd, "@ItemItemOptionSetId3", SqlDbType.Int, opSet3); BuildSqlParameter(sqlCmd, "@ItemPrintOptionSetId", SqlDbType.SmallInt, printDestinations); BuildSqlParameter(sqlCmd, "@ItemActive", SqlDbType.Bit, active); BuildSqlParameter(sqlCmd, "@ItemTaxId", SqlDbType.Int, taxId); BuildSqlParameter(sqlCmd, "@ItemPrepareTime", SqlDbType.Time, prepareTime); BuildSqlParameter(sqlCmd, "@ItemIsReturnable", SqlDbType.Bit, isReturnable); BuildSqlParameter(sqlCmd, "@ItemIsTaxExemptable", SqlDbType.Bit, isTaxExemptable); BuildSqlParameter(sqlCmd, "@ItemIsFired", SqlDbType.Bit, isFired); BuildSqlParameter(sqlCmd, "@ItemIsOutOfStock", SqlDbType.Bit, isOutOfStock); BuildSqlParameter(sqlCmd, "@ItemIsDiscontinued", SqlDbType.Bit, isDiscontinued); BuildSqlParameter(sqlCmd, "@ItemIsGrouping", SqlDbType.Bit, isGrouping); BuildSqlParameter(sqlCmd, "@ItemButtonImage", SqlDbType.VarBinary, buttonImage); BuildSqlParameter(sqlCmd, "@ItemId", SqlDbType.Int, ParameterDirection.ReturnValue); if (sqlCmd.ExecuteNonQuery() > 0) { result = new Item(Convert.ToInt32(sqlCmd.Parameters["@ItemId"].Value), categoryId, itemName, shortName, price, opSet1, opSet2, opSet3, printDestinations, active, taxId, prepareTime, isReturnable, isTaxExemptable, isFired, isOutOfStock, isDiscontinued, isGrouping, buttonImage); } } FinishedWithConnection(cn); return(result); }
private Item(int id, int categoryId, string fullName, string shortName, double price, int condimentOptions, int sideOptions, int preparationOptions, PrintDestination printDestinations, bool active, int taxId, TimeSpan?prepareTime, bool isReturnable, bool isTaxExemptable, bool isFired, bool isOutOfStock, bool isDiscontinued, bool isGrouping, byte[] buttonImage) { Id = id; CategoryId = categoryId; FullName = fullName; ShortName = shortName; Price = price; ItemOptionSetIds = new int[] { preparationOptions, sideOptions, condimentOptions }; PrintDestinations = printDestinations; IsActive = active; TaxId = taxId; PrepareTime = prepareTime; IsReturnable = isReturnable; IsTaxExemptable = isTaxExemptable; IsFired = isFired; IsOutOfStock = isOutOfStock; IsDiscontinued = isDiscontinued; IsGrouping = isGrouping; ButtonImage = buttonImage; }
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); } }
public void Print(PrintDestination printDestination) { MessageBox.Show("Print"); }
public void Print(PrintDestination printDestination) { }
public bool UpdateItem() { int categoryId = itemEditorDetailsControl.CategoryId; string fullName = itemEditorDetailsControl.FullName; string shortName = itemEditorDetailsControl.ShortName; double price = itemEditorDetailsControl.Price; PrintDestination printOptionSet = itemEditorDetailsControl.PrintDestinations; bool isActive = itemEditorDetailsControl.IsActive; int taxId = itemEditorDetailsControl.TaxId; int itemOptionSet1 = itemEditorOptionControl.OptionSetId1; int itemOptionSet2 = itemEditorOptionControl.OptionSetId2; int itemOptionSet3 = itemEditorOptionControl.OptionSetId3; bool isReturnable = itemEditorDetailsControl.IsReturnable; bool isTaxExemptable = itemEditorDetailsControl.IsTaxExemptable; bool isFired = itemEditorDetailsControl.IsFired; bool isOutOfStock = itemEditorDetailsControl.IsOutOfStock; bool isGrouping = itemEditorDetailsControl.IsGrouping; // TODO: Implement for delivery and future times TimeSpan?prepareTime = null; // Verify Category is set if (categoryId <= 0) { PosDialogWindow.ShowDialog( Strings.ItemEditorErrorNoCategory, Strings.ItemEditorInvalidCategory); return(false); } // Verify name is valid and unique try { if (string.IsNullOrEmpty(fullName)) { throw new Exception(Strings.ItemEditorErrorNoName); } Item current = Item.Get(fullName); if (current != null) { if ((ActiveItem == null) || ((ActiveItem != null) && (current.Id != ActiveItem.Id))) { throw new Exception(Strings.ItemEditorErrorExistingName); } } } catch (Exception ex) { PosDialogWindow.ShowDialog(ex.Message, Strings.ItemEditorInvalidName); return(false); } // Is there an ActiveItem? Item activeItem = ActiveItem; if (activeItem == null) { activeItem = Item.Add(categoryId, fullName, shortName, price, itemOptionSet1, itemOptionSet2, itemOptionSet3, printOptionSet, isActive, taxId, prepareTime, isReturnable, isTaxExemptable, isFired, isOutOfStock, isGrouping); } else { LogItemChanges(activeItem, itemOptionSet1, itemOptionSet2, itemOptionSet3); // Update the category values for the ActiveItem activeItem.SetCategory(categoryId); activeItem.SetFullName(fullName); activeItem.SetShortName(shortName); if (Math.Abs(price - activeItem.Price) > double.Epsilon) { LogPriceChange(activeItem.Id, activeItem.Price, price); } activeItem.SetPrice(price); activeItem.SetOptionSet1(itemOptionSet1); activeItem.SetOptionSet2(itemOptionSet2); activeItem.SetOptionSet3(itemOptionSet3); activeItem.SetActive(isActive); activeItem.SetPrintOptionSet(printOptionSet); activeItem.SetTaxId(taxId); activeItem.SetPrepareTime(prepareTime); activeItem.SetIsReturnable(isReturnable); activeItem.SetIsTaxExemptable(isTaxExemptable); activeItem.SetIsFired(isFired); activeItem.SetIsOutOfStock(isOutOfStock); activeItem.SetIsGrouping(isGrouping); // Update the database activeItem.Update(); } // Update ItemPricing List <int> removedIds = new List <int>(); if (itemEditorSpecialPricing.RemovedItems != null) { foreach (ItemEditorSpecialPricingControl.ItemPricingModel removed in itemEditorSpecialPricing.RemovedItems) { removedIds.Add(removed.Id); ItemPricing.Delete(removed.Id); LogPriceChange(removed.Id, removed.ItemId, removed.Price, null, removed.DayOfWeek, null, removed.StartTime, null, removed.EndTime, null); } } if (itemEditorSpecialPricing.NewItems != null) { foreach (ItemEditorSpecialPricingControl.ItemPricingModel added in itemEditorSpecialPricing.NewItems) { // ToDo: Placeholder Constants ItemPricing itemPricing = ItemPricing.Add(activeItem.Id, added.DayOfWeek, added.StartTime, added.EndTime, added.Price, null, null, null, true); LogPriceChange(itemPricing.Id, added.ItemId, null, added.Price, null, added.DayOfWeek, null, added.StartTime, null, added.EndTime); } } if (itemEditorSpecialPricing.ExistingItems != null) { foreach (ItemEditorSpecialPricingControl.ItemPricingModel existing in itemEditorSpecialPricing.ExistingItems) { if (removedIds.Contains(existing.Id)) { continue; } double? oldPrice = null, newPrice = null; Days? oldDayOfWeek = null, newDayOfWeek = null; TimeSpan? oldStartTime = null, newStartTime = null, oldEndTime = null, newEndTime = null; ItemPricing itemPricing = ItemPricing.Get(existing.Id); if (Math.Abs(itemPricing.Price - existing.Price) > double.Epsilon) { oldPrice = itemPricing.Price; newPrice = existing.Price; } if (itemPricing.DayOfWeek != existing.DayOfWeek) { oldDayOfWeek = itemPricing.DayOfWeek; newDayOfWeek = existing.DayOfWeek; } if (itemPricing.StartTime != existing.StartTime) { oldStartTime = itemPricing.StartTime; newStartTime = existing.StartTime; } if (itemPricing.EndTime != existing.EndTime) { oldEndTime = itemPricing.EndTime; newEndTime = existing.EndTime; } itemPricing.SetItemId(existing.ItemId); itemPricing.SetDayOfTheWeek(existing.DayOfWeek); itemPricing.SetPrice(existing.Price); itemPricing.SetStartTime(existing.StartTime); itemPricing.SetEndTime(existing.EndTime); itemPricing.Update(); LogPriceChange(itemPricing.Id, itemPricing.ItemId, oldPrice, newPrice, oldDayOfWeek, newDayOfWeek, oldStartTime, newStartTime, oldEndTime, newEndTime); } } if (ActiveItem == null) { ActiveItem = activeItem; } itemEditorGroupingControl.Update(ActiveItem.Id); itemEditorIngredientsControl.Update(ActiveItem.Id); itemEditorSpecialPricing.ActiveItem = ActiveItem; return(true); }
public void SetPrintOptionSet(PrintDestination printDestinations) { PrintDestinations = printDestinations; }
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); } }
private static bool HasPrintableTicketItems(IEnumerable <TicketItem> ticketItems, PrintDestination printDestination, TicketItemPrintOptions printOptions, bool checkPrintDestination) { foreach (TicketItem ticketItem in ticketItems) { if (checkPrintDestination && !ticketItem.PrintsTo(printDestination)) { continue; } if ((printOptions == TicketItemPrintOptions.All) || (printOptions == TicketItemPrintOptions.AllAsVoid) || (printOptions == TicketItemPrintOptions.AllAsCancelMade) || (printOptions == TicketItemPrintOptions.AllAsCancelUnmade)) { return(true); } if ((printOptions == TicketItemPrintOptions.OnlyChanged) && (ticketItem.IsChanged || ticketItem.OrderTime == null)) { return(true); } if ((printOptions == TicketItemPrintOptions.AllNonCanceled) && !ticketItem.IsCanceled) { return(true); } if ((printOptions == TicketItemPrintOptions.AllUnfired) && (ticketItem.FireTime == null) && !ticketItem.IsCanceled && Item.GetIsFired(ticketItem.ItemId)) { return(true); } } return(false); }
/// <summary> /// Print for item voids and item returns /// </summary> private static void Print(PrintDestination printDestination, PosPrinter printer, Ticket ticket, TicketItemPrintOptions printOptions, TicketItem[] ticketItems, bool checkPrintDestination) { if (checkPrintDestination) { bool found = false; foreach (TicketItem ticketItem in ticketItems) { if (ticketItem.PrintsTo(printDestination)) { found = true; break; } } if (!found) { return; } } bool isKitchen = ((printDestination == PrintDestination.Kitchen1) || (printDestination == PrintDestination.Kitchen2) || (printDestination == PrintDestination.Kitchen3)); #if DEBUG PrintLineToReceipt(printer, "** Debug: Printer Destination is \'" + printDestination + "\' **"); #endif // Header PrintHeaderInformation(printDestination, printer, ticket, printOptions); // Ticket Items double totalReturnAmount = 0; double totalTaxAmount = 0; foreach (TicketItem ticketItem in ticketItems) { double[] results = PrintTicketItemToReceipt(printer, ticketItem, false, printOptions, ticket.Type); if (results == null) { continue; } totalReturnAmount += results[0]; totalTaxAmount += results[1]; } totalReturnAmount += totalTaxAmount; // Footer if ((printOptions != TicketItemPrintOptions.TicketItemReturn) && !isKitchen) { PrintFooterInformation(printer, ticket); } else if (!isKitchen) { PrintLineToReceipt(printer); PrintLineToReceipt(printer, Strings.TaxTotal + PrinterEscapeCodes.SetRight + totalTaxAmount.ToString("C2")); PrintLineToReceipt(printer, Strings.ReturnTotal + PrinterEscapeCodes.SetRight + totalReturnAmount.ToString("C2")); } }
/// <summary> /// Print for item voids and item returns /// </summary> public static void Print(PrintDestination printDestination, PosPrinter printer, Ticket ticket, TicketItemPrintOptions printOptions, TicketItem[] ticketItems) { Print(printDestination, printer, ticket, printOptions, ticketItems, false); }
public bool PrintsTo(PrintDestination destination) { Item item = Item.Get(ItemId); return((item.PrintDestinations & destination) != 0); }