When a User logging into a WinForm (C#.net) application, how can i assign dynamically a defined Menu application according to a Data Base Role?
Thanks in advance for your support, time and for share your knowledge, it really helps.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jan MontanoPosted Jan 4, 2009, 8:07 PM
my menu
---------
Admin (mnuAdmin)
-- adminsub1 (mnuAdminSub1)
-- adminsub2 (mnuAdminSub2)
Guest (mnuGuest)
-- guestsub1 (mnuGuestSub1)
-- guestsub2 (mnuGuestSub2)
PowerUser (mnuPowerUser)
-- powerusersub1 (mnuPowerUserSub1)
-- powerusersub2 (mnuPowerUserSub2)
something like this after calling the logon method.
----------------
Role role = logon(userid, password)
switch (role)
case role.Admin:
mnuGuest.Visible = false
mnuPowerUser.Visible = false
case role.PowerUser:
.....mnuPowerUserSub1.Enabled = false
you could also specifiy role funtions and which role are able to perform it in the database. you could then use that data to know which menus/submenus to disable/hide/enable/show
Hope this helps.
azariel moronPosted Jan 4, 2009, 10:50 AM
Answer 1) Yes, i already have a database with the Roles and Users for each Role (SQL Server).
Answer 2) Yes, i already can retrieve data from the database.
Answer 3) Yes, i have created menus in my aplication, but there is only one menu, the main menu.
I want to differentiate (dinamically hide/show/disable/enable) the main menu depending on what user logging into my applitacion.
The menu has a menuStrip (with items) and a ToolStrip (with buttons).
Jan MontanoPosted Jan 4, 2009, 6:12 AM
What in particular are you having trouble with?
1. Do you already have a database table with the roles?
2. Do you already know how to retrieve data from a database?
3. Have you already created menus in your application? What are the menus/submenus you created?
azariel moronPosted Jan 2, 2009, 11:18 AM
Somebody has another idea? please i will apreciate it.
Jan MontanoPosted Jan 2, 2009, 1:27 AM
Normally, you predefine all menus needed by users. then upon logon, you hide/show/disable/enable menus based on the role of the user.