![]() ![]() ' go one by one all user items For i = 0 To dsUser.Tables( 0).Rows.Count - 1 Dim id_hierar As String ' hierarchy for the item (parents ' and parents parents and so on) Dim parent As String ' temp var to store parent index ' set the hierarchy as primary key to find ' the menu item "parents"ĭsItems.Tables( 0).PrimaryKey = New DataColumn() ' Load all menu items and sub-items to menu Dim dsItems As New DataSetĭim i As Integer ' create a dataset with all items possible Dim adap As New OleDb.OleDbDataAdapter( " ", conn)Ī = " SELECT * FROM ITEMS" Since it is mandatory for the user to also have the parent items the function LoadMenuItems() gets from the database all the items that must be seen, so the user can access the ones he has permission to. The first Hashtable is called HashMenu and it contains all the information about the menu items that the user can access. The code builds two Hashtables to map the items with the respective functions to call when the menu item is clicked. When the user logs in, the application gets all the information about the user from the database. Contains all menu items - text is the text displayed in the menu and func is the function to call when the item is clicked (it can also be the name of the UserControl, so the Activator can call it to the main panel in the form). ![]() Contains username, user ID and password.The database is very simple: it contains three tables: In this simple example, I just made a message box for each menu, that says what to do with each menu item based on the information in the database. Then with the activator class, I loaded the UserControl to a panel in the main form of the application. So in the database, each function had the name of the DLL and the name of the UserControl to call for each specific menu item. In my application, I made all the functions as UserControls. I built tables for users and privileges in an Access database and loaded them to the menu application when the user logged in. Since I couldn't find one, I came up with a simple idea. I searched around for a menu based on a database, where each user in the database would "see" a different menu in the application depending on his permissions and privileges.
0 Comments
Leave a Reply. |