Click here to Skip to main content
12,397,575 members (61,270 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
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!!!
if (txtSupervisor.Text == "sa")
                {
                    SettingManger.Instance.IsAdmin = Enumerator.AdminType.SUPERADMIN;
 

                }
                else if (txtSupervisor.Text != "sa")
                {
                    dateTimePicker1.MinDate = dateTimePicker1.MaxDate = DateTime.Now;
                }
Posted 31-Dec-12 22:19pm
Updated 31-Dec-12 22:45pm
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Why not just use the Enabled property?
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]
  Permalink  
v2
Comments
vinayak chavan 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.
vinayak chavan 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?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

if (SettingManger.Instance.User != "sa")
                {
 
                    dateTimePicker1.MinDate = dateTimePicker1.MaxDate = DateTime.Now;
 
                }
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100