public void SetupSeatingButtons(Room room, Ticket activeTicket)
        {
            int index = 0;

            Seating[] seatings = SeatingManager.GetAllSeating();
            if (room != null)
            {
                labelSelectSeating.Content = Strings.SelectSeating + ": " + room.Description;
                foreach (Seating seat in seatings)
                {
                    if (index < Buttons.Length)
                    {
                        if (seat.RoomId == room.Id)
                        {
                            AssignSeatingIdToButton(Buttons[index], seat.Id);
                            Buttons[index].Text       = Helpers.StringHelper.ThinString(seat.Description);
                            Buttons[index].Visibility = Visibility.Visible;
                            Buttons[index].IsChecked  = ((activeTicket != null) && (activeTicket.SeatingId == seat.Id));
                            index++;
                        }
                    }
                }
            }
            else
            {
                labelSelectSeating.Content = Strings.SEATINGISNOTSETUP;
            }
            HideRemainingButtons(index);
        }
        private void InitializeRooms()
        {
            Room[] rooms = SeatingManager.GetAllRoom();
            FormattedListBoxItem selectedItem = null;

            SelectedRoom = GetUsersPreviouslyUsedRoom();
            if (rooms == null)
            {
                return; // Failed, not setup
            }
            if ((SelectedRoom == null) && (rooms.Length > 0))
            {
                SelectedRoom = rooms[0];
            }
            foreach (Room room in rooms)
            {
                var listItem = new FormattedListBoxItem(room.Id, room.Description, true);
                if (SelectedRoom != null && room.Id == SelectedRoom.Id)
                {
                    selectedItem        = listItem;
                    listItem.IsSelected = true;
                }
                listBoxRooms.Items.Add(listItem);
            }
            listBoxRooms.SelectedItem = selectedItem;
        }
Example #3
0
        private void Delete()
        {
            bool confirmed = false;

            if (listBox1.SelectedItem == null)
            {
                return;
            }
            FormattedListBoxItem selectedItem =
                listBox1.SelectedItem as FormattedListBoxItem;

            if (selectedItem == null)
            {
                return;
            }

            if (ViewMode == SeatingViewMode.Rooms)
            {
                string message = (buttonEditToggle.IsEnabled ?
                                  Strings.AreYouSureYouWantToDeleteTheSelectedRoomAndAllItsSeatings :
                                  Strings.AreYouSureYouWantToDeleteTheSelectedRoom);
                if (PosDialogWindow.ShowDialog(
                        message, Strings.ConfirmDeletion, DialogButtons.OkCancel) == DialogButton.Ok)
                {
                    Room room = selectedItem.ReferenceObject as Room;
                    if (room != null)
                    {
                        SeatingManager.DeleteRoom(room.Id);
                        SeatingManager.DeleteAllSeating(room.Id);
                    }
                    buttonEditToggle.IsEnabled  = false;
                    roomEditorControl.IsEnabled = false;
                    SelectedRoom    = null;
                    SelectedSeating = null;
                    confirmed       = true;
                }
            }
            else if (ViewMode == SeatingViewMode.Seating)
            {
                if (PosDialogWindow.ShowDialog(
                        Strings.AreYouSureYouWantToDeleteTheSelectedSeating,
                        Strings.ConfirmDeletion, DialogButtons.OkCancel) == DialogButton.Ok)
                {
                    Seating seating = selectedItem.ReferenceObject as Seating;
                    if (seating != null)
                    {
                        SeatingManager.DeleteSeating(seating.Id);
                    }
                    seatingEditorControl.IsEnabled = false;
                    SelectedSeating = null;
                    confirmed       = true;
                }
            }
            if (confirmed)
            {
                listBox1.Items.Remove(selectedItem);
                listBox1.SelectedItem  = null;
                buttonDelete.IsEnabled = false;
            }
        }
 private void listBoxRooms_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if ((e.AddedItems == null) || (e.AddedItems.Count == 0))
     {
         return;
     }
     SelectedRoom =
         SeatingManager.GetRoom(((FormattedListBoxItem)listBoxRooms.SelectedItem).Id);
     SetupSeatingButtons();
 }
Example #5
0
 private void InitializeListBox()
 {
     listBox1.SelectedItem = null;
     listBox1.Items.Clear();
     if (ViewMode == SeatingViewMode.Rooms)
     {
         roomEditorControl.SelectedRoom = null;
         FormattedListBoxItem selected = null;
         Room[] rooms = SeatingManager.GetAllRoom();
         foreach (Room room in rooms)
         {
             FormattedListBoxItem item =
                 new FormattedListBoxItem(room, room.Description, true);
             if ((SelectedRoom != null) && (SelectedRoom.Id == room.Id))
             {
                 selected = item;
             }
             listBox1.Items.Add(item);
         }
         listBox1.SelectedItem = selected;
         if (selected != null)
         {
             roomEditorControl.SelectedRoom        =
                 seatingEditorControl.SelectedRoom =
                     selected.ReferenceObject as Room;
         }
         SetEditMode(false);
     }
     else
     {
         if (SelectedRoom != null)
         {
             seatingEditorControl.SelectedSeating = null;
             FormattedListBoxItem  selected = null;
             IEnumerable <Seating> seatings = SeatingManager.GetAllSeating(SelectedRoom.Id);
             foreach (Seating seating in seatings)
             {
                 FormattedListBoxItem item =
                     new FormattedListBoxItem(seating, seating.Description, true);
                 if ((SelectedSeating != null) && (SelectedSeating.Id == seating.Id))
                 {
                     selected = item;
                 }
                 listBox1.Items.Add(item);
             }
             listBox1.SelectedItem = selected;
             if (selected != null)
             {
                 seatingEditorControl.SelectedSeating =
                     selected.ReferenceObject as Seating;
             }
             SetEditMode(false);
         }
     }
 }
        private Room GetUsersPreviouslyUsedRoom()
        {
            EmployeeSetting setting =
                SettingManager.GetEmployeeSetting(SessionManager.ActiveEmployee.Id,
                                                  "LastRoomId");

            if (setting.IntValue != null)
            {
                return(SeatingManager.GetRoom(setting.IntValue.Value));
            }
            return(null);
        }
        public bool UpdateRoom()
        {
            // Add Room
            if (SelectedRoom == null)
            {
                SelectedRoom =
                    SeatingManager.AddRoom(textBoxName.Text, GetTicketType());
                return(SelectedRoom != null);
            }

            // Update Room
            SelectedRoom.SetDescription(textBoxName.Text);
            SelectedRoom.SetTicketingType(GetTicketType());
            return(SelectedRoom.Update());
        }
        public bool UpdateSeating()
        {
            // Add Seating
            if (SelectedSeating == null)
            {
                SelectedSeating = SeatingManager.AddSeating(SelectedRoom.Id,
                                                            GetName(), GetCapacity());
                return(SelectedSeating != null);
            }

            // Update Seating
            SelectedSeating.SetDescription(GetName());
            SelectedSeating.SetCapacity(GetCapacity());
            return(SelectedSeating.Update());
        }
Example #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("    Welcome to flight seat arranger    ");
            var seats  = InputReaders.GetSeatConfig();
            var guests = InputReaders.GetGuestCount();

            var flight        = FlightBuilder.Build(seats, "CoolFlight");
            var waitingGuests = SeatingManager.ArrangeGuests(flight, guests);

            var printLines = SeatMapPrinter.PrintSeatingChart(flight);

            foreach (var line in printLines)
            {
                Console.WriteLine(line);
            }

            Console.ReadLine();
        }
Example #10
0
 // ToDo: These are needed per-say, but what if someone create
 // Multiple Rooms with TicketingTypes of the same value, then this
 // could be useful, otherwise should prevent adding multiple rooms
 // of these types
 private void SetDefaultSeating(Room room)
 {
     SeatingManager.DeleteAllSeating(room.Id);
     if (room.TicketingType == PosModels.Types.TicketType.DriveThru)
     {
         SeatingManager.AddSeating(room.Id, Strings.DriveThru, 0);
     }
     if (room.TicketingType == PosModels.Types.TicketType.Delivery)
     {
         SeatingManager.AddSeating(room.Id, Strings.Delivery, 0);
     }
     if (room.TicketingType == PosModels.Types.TicketType.Pickup)
     {
         SeatingManager.AddSeating(room.Id, Strings.Carryout, 0);
     }
     if (room.TicketingType == PosModels.Types.TicketType.Catering)
     {
         SeatingManager.AddSeating(room.Id, Strings.Catering, 0);
     }
 }
 public void InitializeFromTicket(Ticket activeTicket)
 {
     ActiveTicket = activeTicket;
     personInformationControl.buttonStartTicket.Text =
         ((activeTicket == null) ? Types.Strings.CreateTicket : Types.Strings.ChangeOccasion);
     personInformationControl.ActiveTicket = activeTicket;
     if (ActiveTicket == null)
     {
         TicketType = TicketType.DineIn;
         SetupSeatingButtons();
         return;
     }
     TicketType = ActiveTicket.Type;
     if (ActiveTicket.CustomerId > 0)
     {
         SelectedCustomer = Customer.Get(ActiveTicket.CustomerId);
         personInformationControl.SelectedCustomer = SelectedCustomer;
     }
     if (ActiveTicket.SeatingId > 0)
     {
         Seating seat = SeatingManager.GetSeating(ActiveTicket.SeatingId);
         SelectedRoom = SeatingManager.GetRoom(seat.RoomId);
     }
     else
     {
         Room[] rooms = SeatingManager.GetAllRoom();
         foreach (Room room in rooms)
         {
             if (room.TicketingType == TicketType)
             {
                 SelectedRoom = room;
                 break;
             }
         }
     }
     SetupSeatingButtons();
 }
Example #12
0
        private void UpdateChanges()
        {
            bool updated = false;

            if (ViewMode == SeatingViewMode.Rooms)
            {
                bool isNew   = (roomEditorControl.SelectedRoom == null);
                Room oldRoom = (roomEditorControl.SelectedRoom != null ?
                                SeatingManager.GetRoom(roomEditorControl.SelectedRoom.Id) : null);
                if (roomEditorControl.UpdateRoom())
                {
                    if (isNew)
                    {
                        FormattedListBoxItem item =
                            new FormattedListBoxItem(roomEditorControl.SelectedRoom,
                                                     roomEditorControl.SelectedRoom.Description, true);
                        listBox1.Items.Add(item);
                        SelectedRoom          = roomEditorControl.SelectedRoom;
                        listBox1.SelectedItem = item;
                        SetDefaultSeating(SelectedRoom);
                        updated = true;
                    }
                    else if (listBox1.SelectedItem != null)
                    {
                        FormattedListBoxItem selected = listBox1.SelectedItem as FormattedListBoxItem;
                        if (selected != null)
                        {
                            Room room = selected.ReferenceObject as Room;
                            if (room != null)
                            {
                                selected.Set(room, room.Description);
                                if (oldRoom != null && oldRoom.TicketingType != room.TicketingType)
                                {
                                    SetDefaultSeating(room);
                                }
                            }
                            updated = true;
                        }
                    }
                }
            }
            else if (ViewMode == SeatingViewMode.Seating)
            {
                bool isNew = (seatingEditorControl.SelectedSeating == null);
                if (seatingEditorControl.UpdateSeating())
                {
                    if (isNew)
                    {
                        FormattedListBoxItem item =
                            new FormattedListBoxItem(seatingEditorControl.SelectedSeating,
                                                     seatingEditorControl.SelectedSeating.Description, true);
                        listBox1.Items.Add(item);
                        SelectedSeating       = seatingEditorControl.SelectedSeating;
                        listBox1.SelectedItem = item;
                        updated = true;
                    }
                    else if (listBox1.SelectedItem != null)
                    {
                        FormattedListBoxItem selected = listBox1.SelectedItem as FormattedListBoxItem;
                        if (selected != null)
                        {
                            Seating seating = selected.ReferenceObject as Seating;
                            if (seating != null)
                            {
                                selected.Set(seating, seating.Description);
                            }
                        }
                        updated = true;
                    }
                }
            }
            if (updated)
            {
                SetEditMode(false);
            }
        }
        public void InitializeListBox(TicketSelectionShow show)
        {
            var tickets = new List <Ticket>();

            if (show == TicketSelectionShow.All)
            {
                tickets.AddRange(TicketManager.GetAllTickets());
            }
            else if (show == TicketSelectionShow.Range)
            {
                tickets.AddRange(TicketManager.GetRange(RangeStart, RangeEnd));
            }
            else if (show == TicketSelectionShow.AllDay)
            {
                if (DayOfOperation.Today != null)
                {
                    tickets.AddRange(TicketManager.GetRange(DayOfOperation.Today.StartOfDay, DateTime.Now));
                }
                else
                {
                    DayOfOperation lastDay =
                        DayOfOperation.GetLatestInYear(DayOfOperation.CurrentYear);
                    if (lastDay.EndOfDay != null)
                    {
                        tickets.AddRange(TicketManager.GetRange(lastDay.StartOfDay, lastDay.EndOfDay.Value));
                    }
                }
            }
            else if (show == TicketSelectionShow.AllOpen)
            {
                tickets.AddRange(TicketManager.GetOpenTickets());
            }
            else if (show == TicketSelectionShow.MyOpen)
            {
                tickets.AddRange(TicketManager.GetOpenTickets(SessionManager.ActiveEmployee.Id));
            }
            else if (show == TicketSelectionShow.Closed)
            {
                tickets.AddRange(TicketManager.GetTodaysClosedTickets());
            }
            else if (show == TicketSelectionShow.Canceled)
            {
                tickets.AddRange(TicketManager.GetTodaysCanceledTickets());
            }
            else if (show == TicketSelectionShow.Dispatched)
            {
                tickets.AddRange(TicketManager.GetDispatchedTickets());
            }
            else if (show == TicketSelectionShow.Future)
            {
                tickets.AddRange(TicketManager.GetFutureOrderTickets());
            }

            Items.Clear();
            foreach (Ticket ticket in tickets
                     .Where(ticket => (TicketTypeFilterControl.CurrentFilter == null) ||
                            (TicketTypeFilterControl.CurrentFilter.Value == ticket.Type)))
            {
                string  text;
                Seating seat = SeatingManager.GetSeating(ticket.SeatingId);
                if (seat != null)
                {
                    text = (ticket.OrderId != null ? Types.Strings.Order + ": " + ticket.OrderId.Value + ", " : "") +
                           Types.Strings.Ticket + ": " + ticket.PrimaryKey.Id + (ticket.PartyId != 0 ?
                                                                                 Types.Strings.Party + ticket.PartyId : "") + ", " + seat.Description +
                           Environment.NewLine + Types.Strings.CreateTime + ticket.CreateTime;
                    if (!String.IsNullOrEmpty(ticket.ManagerNote))
                    {
                        text += Environment.NewLine + Types.Strings.Comment +
                                ticket.ManagerNote;
                    }
                }
                else
                {
                    text = (ticket.OrderId != null ?
                            Types.Strings.Order + ": " + ticket.OrderId.Value +
                            ", " : "") + Types.Strings.Ticket + ": " + ticket.PrimaryKey.Id + (ticket.PartyId != 0 ?
                                                                                               Types.Strings.Party + ticket.PartyId : "") + ", " + ticket.Type.GetFriendlyName() +
                           Environment.NewLine + Types.Strings.CreateTime + ticket.CreateTime;
                    if (!String.IsNullOrEmpty(ticket.ManagerNote))
                    {
                        text += Environment.NewLine + Types.Strings.Comment +
                                ticket.ManagerNote;
                    }
                }
                AddItem(ticket, text);
            }
            OrderEntryControl.SetDisplayedTicketTypeToStatusBar();
        }
Example #14
0
        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);
            }
        }