Example #1
0
        private void DeleteButton_Click(object sender, EventArgs args)
        {
            Program      app          = Program.GetInstance();
            ChairService chairManager = app.GetService <ChairService>("chairs");

            // Find the chair
            Chair chair = chairManager.GetChairByRoomAndPosition(room, row, column);

            if (chair == null)
            {
                GuiHelper.ShowError("Er bestaat geen stoel op deze positie");
                return;
            }

            // Ask for confirmation
            if (!GuiHelper.ShowConfirm("Weet je zeker dat je deze stoel wilt verwijderen?"))
            {
                return;
            }

            // Delete it
            if (!chairManager.DeleteChair(chair))
            {
                GuiHelper.ShowError("Kon stoel niet verwijderen");
                return;
            }

            saveButton.Text      = "Stoel aanmaken";
            deleteButton.Enabled = false;
            GuiHelper.ShowInfo("Stoel succesvol verwijderd");
        }
Example #2
0
        private void AddButton_Click(object sender, EventArgs args)
        {
            Program      app          = Program.GetInstance();
            ChairService chairManager = app.GetService <ChairService>("chairs");

            // Find or create chair
            Chair chair = chairManager.GetChairByRoomAndPosition(room, row, column);
            bool  isNew = false;

            if (chair == null)
            {
                chair = new Chair(room.id, row, column, 0, "default");
                isNew = true;
            }

            chair.price = (double)priceInput.Value;

            // Save chair
            if (!chairManager.SaveChair(chair))
            {
                GuiHelper.ShowError(ValidationHelper.GetErrorList(chair));
                return;
            }

            saveButton.Text      = "Stoel opslaan";
            deleteButton.Enabled = true;
            GuiHelper.ShowInfo("Stoel succesvol " + (isNew ? "aangemaakt" : "aangepast"));
        }
        void ChairButton_Click(object sender, EventArgs e, string buttonString)
        {
            Program            app                = Program.GetInstance();
            ChairService       chairService       = app.GetService <ChairService>("chairs");
            ReservationService reservationService = app.GetService <ReservationService>("reservations");
            ReservationCreate  reservationScreen  = app.GetScreen <ReservationCreate>("reservationCreate");

            // Parse button data
            string[] parts = buttonString.Replace("button", "").Split('-');
            int      row   = ValidationHelper.ParseInt(parts[0]);
            int      col   = ValidationHelper.ParseInt(parts[1]);

            // Get chair
            Chair chair = chairService.GetChairByRoomAndPosition(show.GetRoom(), row, col);

            if (reservationService.IsChairTaken(chair, show) || reservationScreen.ContainsChair(chair))
            {
                GuiHelper.ShowError("Deze stoel is niet beschikbaar");
                return;
            }

            reservationScreen.AddChair(chair);

            // Redirect to screen
            app.ShowScreen(reservationScreen);
        }
Example #4
0
        public override void OnShow()
        {
            Program      app          = Program.GetInstance();
            ChairService chairManager = app.GetService <ChairService>("chairs");
            Chair        chair        = chairManager.GetChairByRoomAndPosition(room, row, column);

            base.OnShow();

            columnValue.Text = "Kolom  " + column;
            rowValue.Text    = "Rij  " + row;

            // Update price input
            priceInput.Value = chair != null ? (decimal)chair.price : 0;

            // Update save button
            saveButton.Text      = chair != null ? "Stoel opslaan" : "Stoel aanmaken";
            deleteButton.Enabled = chair != null;
        }
        public override bool Validate()
        {
            Program      app          = Program.GetInstance();
            RoomService  roomService  = app.GetService <RoomService>("rooms");
            ChairService chairService = app.GetService <ChairService>("chairs");

            // Make sure the room exists
            Room room = roomService.GetRoomById(roomId);

            if (room == null)
            {
                AddError("roomId", "Ongeldige zaal");
                return(false);
            }

            // Make sure the row + number combo is unique
            Chair chair = chairService.GetChairByRoomAndPosition(room, row, number);

            if (chair != null && chair.id != id)
            {
                AddError("number", "Nummer moet uniek zijn voor de gekozen rij");
                return(false);
            }

            // Make sure price is 0 or higher
            if (price < 0)
            {
                AddError("price", "Prijs mag niet negatief zijn");
                return(false);
            }

            // Make a valid type was selected
            if (!TYPES.Contains(type))
            {
                AddError("type", "Ongeldig type");
                return(false);
            }

            return(true);
        }
        public override void OnShow()
        {
            Program      app          = Program.GetInstance();
            ChairService chairService = app.GetService <ChairService>("chairs");
            RoomService  roomService  = app.GetService <RoomService>("rooms");

            base.OnShow();
            subTitle.Text = "Zaal " + room.number;

            container.Controls.Clear();
            container.RowStyles.Clear();
            container.ColumnStyles.Clear();

            // Create grid
            List <Chair> chairs = chairService.GetChairsByRoom(room);

            int maximum       = chairs.Count;
            int highestRow    = 0;
            int highestColumn = 0;

            for (int x = 1; x < maximum; x++)
            {
                if (highestRow < chairs[x].row)
                {
                    highestRow = chairs[x].row;
                }

                if (highestColumn < chairs[x].number)
                {
                    highestColumn = chairs[x].number;
                }
            }

            container.ColumnCount = highestColumn;
            container.RowCount    = highestRow;

            for (int i = 0; i < highestColumn; i++)
            {
                container.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / highestColumn));
            }

            for (int i = 0; i < highestRow; i++)
            {
                container.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / highestRow));
            }

            for (int i = 0; i < highestRow; i++)
            {
                for (int j = 0; j < highestColumn; j++)
                {
                    Button button = new Button();
                    bool   taken  = chairService.GetChairByRoomAndPosition(room, i + 1, j + 1) != null;

                    button.Text = string.Format(taken ? "{0}-{1}" : "Leeg", i + 1, j + 1);
                    button.Name = string.Format("button" + (i + 1) + "-" + (j + 1));
                    button.Dock = DockStyle.Fill;

                    button.Click += (sender, e) => {
                        ChairButton_Click(sender, e, button.Name);
                    };

                    container.Controls.Add(button, j, i);
                }
            }
        }
        public override void OnShow()
        {
            Program            app                = Program.GetInstance();
            ChairService       chairService       = app.GetService <ChairService>("chairs");
            RoomService        roomService        = app.GetService <RoomService>("rooms");
            ReservationService reservationService = app.GetService <ReservationService>("reservations");
            ReservationCreate  reservationCreate  = app.GetScreen <ReservationCreate>("reservationCreate");

            base.OnShow();

            container.Controls.Clear();
            container.RowStyles.Clear();
            container.ColumnStyles.Clear();

            // Get chairs and room size
            List <Chair> chairs = chairService.GetChairsByRoom(show.GetRoom());

            int Maximum      = chairs.Count;
            int highestRow   = 0;
            int highestColum = 0;

            for (int x = 1; x < Maximum; x++)
            {
                if (highestRow < chairs[x].row)
                {
                    highestRow = chairs[x].row;
                }

                if (highestColum < chairs[x].number)
                {
                    highestColum = chairs[x].number;
                }
            }

            container.ColumnCount = highestColum;
            container.RowCount    = highestRow;

            for (int i = 0; i < highestColum; i++)
            {
                container.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / highestColum));
            }

            for (int i = 0; i < highestRow; i++)
            {
                container.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / highestRow));
            }

            for (int i = 0; i < highestRow; i++)
            {
                for (int j = 0; j < highestColum; j++)
                {
                    Chair chair = chairService.GetChairByRoomAndPosition(show.GetRoom(), i + 1, j + 1);

                    // Ignore if chair doesn't exist
                    if (chair == null)
                    {
                        continue;
                    }

                    if (reservationService.IsChairTaken(chair, show) || reservationCreate.ContainsChair(chair))
                    {
                        Button button = new Button();

                        button.Text      = string.Format("Niet beschikbaar");
                        button.BackColor = Color.Red;
                        button.Name      = string.Format("button" + (i + 1) + "-" + (j + 1));

                        button.Dock = DockStyle.Fill;

                        button.Click += (sender, e) => {
                            ChairButton_Click(sender, e, button.Name);
                        };

                        container.Controls.Add(button, j, i);
                    }
                    else
                    {
                        Button button = new Button();

                        button.Text      = string.Format("R" + i + "-N" + j + " prijs: " + chair.price);
                        button.BackColor = Color.Green;
                        button.Name      = string.Format("button" + (i + 1) + "-" + (j + 1));
                        button.Dock      = DockStyle.Fill;

                        button.Click += (sender, e) => {
                            ChairButton_Click(sender, e, button.Name);
                        };

                        container.Controls.Add(button, j, i);
                    }
                }
            }
        }