示例#1
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"));
        }
示例#2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            Program      app          = Program.GetInstance();
            ChairService chairManager = app.GetService <ChairService>("chairs");
            RoomService  roomManager  = app.GetService <RoomService>("rooms");

            // Create bulk update
            BulkUpdate bulkUpdate = new BulkUpdate();

            bulkUpdate.Begin();

            // Save room
            Room room = new Room((int)numberInput.Value);

            if (!roomManager.SaveRoom(room))
            {
                GuiHelper.ShowError(ValidationHelper.GetErrorList(room));
                return;
            }

            // Disable save button
            saveButton.Enabled = false;

            // Create chairs
            int    rows    = (int)rowInput.Value;
            int    columns = (int)columnInput.Value;
            double price   = (double)priceInput.Value;

            for (int i = 1; i <= rows; i++)
            {
                for (int j = 1; j <= columns; j++)
                {
                    Chair chair = new Chair(room.id, i, j, price, "default");

                    if (!chairManager.SaveChair(chair))
                    {
                        GuiHelper.ShowError(ValidationHelper.GetErrorList(room));
                    }
                }
            }

            // End bulk update
            bulkUpdate.End();

            // Enable save button
            saveButton.Enabled = true;

            // Redirect to screen
            RoomDetail roomDetail = app.GetScreen <RoomDetail>("roomDetail");

            roomDetail.SetRoom(room);
            app.ShowScreen(roomDetail);
            GuiHelper.ShowInfo("Zaal succesvol aangemaakt");
        }