Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I have created a program which has to work with database.As a database i am using SQL Server 2008.

This program will use 10 users and one admin.It will record work of this 10 users.

in this program i have 10 menuStrip items each of them has the same name table in database. when you will click on menuStrip item,it will open own form and user can register his work which he or she done. Each user will have his own job.

So what i am trying to do is, to make for users to see just related menuStrip items visible,the rest of it not. And only admin will be able to see all 10 menuStrip items.i have created login form and when user will sign in,in the mainWindow will be shown the username in the label "User".
if labelUser=admin then the button which is opening AdminPanel is visible otherwise not.

And on that AdminPanel you can see the list of users in dataGridView1 and name of tables in dataGridView2 which is same to menuStrip items.In the middle of AdminPanel there is a groupBox with two textBoxes and under them 3 checkBoxes which is specifying for user to "Read" or "Read & Edit" or "invisible".

When admin will click save it will be saved in the table "PriveleBox" in database.

Finally my question is :) is it possible to make when user in login form will press Sign in button first program go through the “PrivelegBox” table and by that it will make window appeareance for user.For example menustripItem[1]=visible the rest are not or few items visible and the rest not?
Posted
Updated 7-Jan-15 2:33am
v3
Comments
BillWoodruff 6-Jan-15 9:02am    
This is a single-instance Application running on a server with multiple users, and one admin at a given time ? Or ... ?

More detail on how you are managing the log-in, ui-configuration, now, would be useful.

Are you implementing your own version of username/password entry, log-in validation, and Groups/Roles/Privileges ?

Your UI spec seems very complete; are you having any trouble implementing it ?

"when you will click on menuStrip item,it will open own form and user can register his work which he or she done. Each user will have his own job."

Have you considered using UserControls instead of separate Forms for each User ?
Rustam777 6-Jan-15 23:01pm    
It seems to me only you understood my question) it is a single Application which is running on a server with multiple users and with one admin at a given time. Yes I am implementing my own login form and it works fine but i dont know how to connect menustripItems to tables and when user in login form will write his username with password and when he will click on Sign in button, program must first check PriveleBox table in database because there will be record for that user which menuStripItems are visible or not visible or just readOnly and by that must show main window.
BillWoodruff 7-Jan-15 14:13pm    
I have written a WinForm app in the past that simulated the kind of UI you are talking about, but I think that it is so far from being useful to you that it's not worth writing at length about. There were no real security constraints in that app.

The strategy I used was a simple linkage of current User to their "view (a UserControl) via a Dictionary<ToolStripItem,UserControl> : when the user selected a different view by clicking a MenuItem, I used a Dictionary look-up to retrieve the associated view (UserControl) and made it visible, brought it to the front of the z-order, etc.

In my app, I had the Admin UserControl, and individual-user UserControls, all inherit from a common UserControl base. Doing that requires a few tricks when/if you need to make sure Controls on the common base are removed from other UserControls that inherit.

For your app, it occurs to me that if each "normal user" has a running version of the App that includes the special UI for the Admin ... even though that's "hidden away" and supposedly blocked by security restrictions ... that's dangerous. I would guess you would want to have a log-in process first, and then when user-status is clear, you'd load your main-app and load assemblies that embodied either an Admin or User view.
ZurdoDev 6-Jan-15 10:17am    
Of course it's possible since you are in control of the code. Where exactly are you stuck then?
Rustam777 6-Jan-15 23:55pm    
thank u. I am actually not stuck in code, all codes works fine, i just want to make for users some menuStrip items visible and some not. By writing condition if(username_label=="user"){then menustripItem[1].visible=true or false and so on...for each user} For now i have this solution but i want to make it when user will click Sign in button in login form program first will go to database and will check in the table PrivelegeBox which items must be visible and editable or invisible or just readable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900