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();
 }
        private Room GetUsersPreviouslyUsedRoom()
        {
            EmployeeSetting setting =
                SettingManager.GetEmployeeSetting(SessionManager.ActiveEmployee.Id,
                                                  "LastRoomId");

            if (setting.IntValue != null)
            {
                return(SeatingManager.GetRoom(setting.IntValue.Value));
            }
            return(null);
        }
 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();
 }
Beispiel #4
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);
            }
        }