Click here to Skip to main content
15,915,702 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello every one


I am doing project in windows Application in(.net) using C# .my problem is i have create 3 department type of user those who Authorised of our own department but

i want to create one Authorised person whose delte or update in department but In Window Application we can't create Session so any one can help me out is any idea to create session type
window is create for each and every on e user and only one of user those one Athorised for Editing or Delteing that can delet or edit (Edit/delte button enable for authorised user) or any other those who has not authorised the edit or delete button is disable . Plz help me if u can

Thanks in Advance :)
Posted
Comments
ZurdoDev 27-Mar-13 7:17am    
The is not clear at all. You know Windows Apps do not have Session so what exactly are you trying to do?
[no name] 27-Mar-13 7:19am    
Why would you need to? What would you think a "session" object has to do with authorization?
Anil Honey 206 27-Mar-13 7:59am    
Windows its self tell's One man can Acess the Application.One Application Multiple users its not Possible.
Anil Honey 206 27-Mar-13 8:02am    
If Authorized User Uses the Application you can give permission for Update and Delete Button should be enable true.If unauthorized person's enable false,Through programming we can do this.

In this situation you need to have the Permission concept.Once the user is login to your system then you should have a set of permissions which specify wheather the edit or delete permission is given to that particular user or not.This you can achieve using database table or simple text file where you can store permissions of that user and based on that only you can enable or disable the edit or delete button.

Good luck
 
Share this answer
 
Comments
Syed Shahabuddin 28-Mar-13 1:54am    
Thanks u very much sir :)
Best and quick solution

Create 3 table

1. ControlPoint with column Names: ControlId,ControlName,ControlProperty
Example 1, btnSave, Enable/Visible (It's property of that controls)

2. Roles with column Names: RoleId,RoleDesc
Example 101, Admin
102, Manager
103, StoreKeeper

3. RolePermission with Column named RolePermissionsId,FK_RoleId,FK_ControlId,IsAllowed
Example : 1, 101 , 1, True Check based on what you wants to set to that role
2, 102 , 1, False


C#
//Read Control points based on Roles defined in table and call this method on form load.

protected bool SetFormAccess(Form frm)
        {
            Control item = null;
            string ctrlName = "";
            bool isAllow = false;
            //write function to get entity based on role
            DataTable dt = GetControlList(string RoleId);

            foreach (DataRow dr in dt.Rows)
            {
                ctrlName = dr["ControlName"].ToString();
                isAllow = Convert.ToBoolean(dr["IsAllowed"]);

                //Find object in forms control collection 
                foreach (Control c in frm.Controls)
                {
                   if (c.Name == ctrlName)
                       item = c;
                }

                if (item != null)
                {
                    if (dr["ControlProperty"].ToString() == "Enabled")
                        item.Enabled = isAllow;
                    else if (dr["ControlProperty"].ToString() == "Visible")
                        item.Visible = isAllow;
                    else
                        item.Enabled = isAllow;
                }

            }
            return true;
        }
 
Share this answer
 
v3
Comments
Syed Shahabuddin 28-Mar-13 1:55am    
Thanks Rajesh sir I hope it will be very helpful thank u soo much
:)
Rajesh Manjarekar 28-Mar-13 17:55pm    
NP... Just let me know its really helped you then please do rate my solution. If you have any queries then let me know.

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