Click here to Skip to main content
Rate this: bad
good
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 23:19pm
Edited 31-Dec-12 23: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 at 1-Jan-13 4:35am
   
thx OriginalGriff644K
 
not but i want normal user make entry with current date in system.
prashant patil 4987 at 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 at 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 at 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
0 Sergey Alexandrovich Kryukov 210
1 CHill60 210
2 Peter Leow 180
3 Zoltán Zörgő 175
4 Richard Deeming 166
0 Sergey Alexandrovich Kryukov 9,278
1 OriginalGriff 6,806
2 Peter Leow 4,432
3 Zoltán Zörgő 3,944
4 Richard MacCutchan 2,782


Advertise | Privacy | Mobile
Web01 | 2.8.150129.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2015
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