You would like to build buttons at run-time?
Here is what I did:
I built a generic form with several tabs - like yours. These tabs can be configured to be shown or not. I can share the table layout too if you like.
The generic form has all possible five tabs with 64 buttons for products on three of the tabs and 32 larger buttons on two of the other tabs. Now, the way I configured it was each product could be assigned to one or more forms - forms the Customer "creates" or defines using the application. All the forms are identical to start - 5 tabs as described above, however, each form can be, as I say, configured to have one tab or all 5.
So, back to the products. Each product can be assigned to one or more forms and in different locations on the form.
Maybe on one form the Customer has a tab called "Soft Drinks" and then they have 64 buttons available to them to assign products. So, Coke is placed here. At the bar, they have a tab named "Beverages" The Coke product can be shown here as well - takes only one more row in the form-to-product association table.
The forms table:
CREATE TABLE IF NOT EXISTS forms(
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
DateLastUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
LastUpdatedBy [VAR_CHAR(]15) DEFAULT NULL,
FormName [VAR_CHAR(]45) NOT NULL,
InitialTab TINYINT(1) NOT NULL DEFAULT 0,
Tab1Settings [VAR_CHAR(]150) DEFAULT NULL,
Tab2Settings [VAR_CHAR(]150) DEFAULT NULL,
Tab3Settings [VAR_CHAR(]150) DEFAULT NULL,
Tab4Settings [VAR_CHAR(]150) DEFAULT NULL,
Tab5Settings [VAR_CHAR(]150) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE INDEX ndxFormName (FormName)
)
In the TabXSettings column I have a color,TabName - if null, then the tab is not shown.
To control the behavior of the products-to-buttons behavior I have:
CREATE TABLE IF NOT EXISTS tblformcontrols_2(
idtblformcontrols INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
id_product INT(10) UNSIGNED NOT NULL,
FormName [VAR_CHAR(]45) NOT NULL,
TagNumber INT(11) NOT NULL,
Caption [VAR_CHAR(]45) NOT NULL,
FontSize SMALLINT(5) UNSIGNED NOT NULL,
DateLastUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
LastUpdatedBy [VAR_CHAR(]15) DEFAULT NULL,
ButtonBackgroundColor [VAR_CHAR(]10) NOT NULL,
ButtonImageLocation [VAR_CHAR(]150) DEFAULT NULL,
PRIMARY KEY (idtblformcontrols),
UNIQUE INDEX Index_2 (FormName, TagNumber),
INDEX ndxid_product (id_product)
)
The tabs are "numbered" logically: starting with 100 and going to 500
The buttons are "numbered" logically tab one starts with button 100 to button 107 in the first row, button 110 to button 117 in the second row and so on. Tab two it is 200 to 207 and 210 to 217 and so on.
I can then read the "forms" table and see what tabs to display and in what color. I then read the "formcontrols" table to see what buttons to display and how to colorize them or place images on the buttons.
The "id_product" column in the "formcontrols" table is a logical foreign key back to the products table. I put this value in the TAG property of the button. When the button is pressed, I already know what product is being purchased as I have the ID of the product in the TAG. You could use the Hint property or some other property too.
Hope this helps.