Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have datetimepicker on form , and 1 txtbox where we have name of users.

now i want allow superuser "sa" to access full calander, but i want normal user make entry with current date in system.
i have use following code but not working for me.
how to resloved this??

thx in advance!!!
C#
if (txtSupervisor.Text == "sa")
                {
                    SettingManger.Instance.IsAdmin = Enumerator.AdminType.SUPERADMIN;


                }
                else if (txtSupervisor.Text != "sa")
                {
                    dateTimePicker1.MinDate = dateTimePicker1.MaxDate = DateTime.Now;
                }
Posted
Updated 31-Dec-12 22:45pm
v3

Why not just use the Enabled property?
C#
myDateTimePicker.Enabled = (txtSupervisor.Text == "sa");
It restricts the input, and lets the user know he can't change it...


[edit]Typo: "Enabeld" for "Enabled" - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
Master Vinu 1-Jan-13 4:35am    
thx OriginalGriff644K

not but i want normal user make entry with current date in system.
prashant patil 4987 1-Jan-13 4:44am    
@vinayak:
hey but it make no sense, means user just select current date from datepicker. why u not just set Date.Now().

m agree with OriginalGriff.
Master Vinu 1-Jan-13 4:46am    
ya thx all,

but i want normal user make entry with only current date in system, and "sa" means superuser can select any date and make entry,
thats my question
Jibesh 1-Jan-13 5:34am    
He means disable for other user and enable for sa user. If normal user is allowed to enter only the current system time then no need to enable it for entering. in that way user is notified that this field is non editable thats how a good UI behave. are you doing anything diff here?
C#
if (SettingManger.Instance.User != "sa")
                {

                    dateTimePicker1.MinDate = dateTimePicker1.MaxDate = DateTime.Now;

                }
 
Share this answer
 

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