授权在Windows窗体中选择日期时间 [英] authorization to select datetime in windows form

查看:360
本文介绍了授权在Windows窗体中选择日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单上有datetimepicker,1个txtbox我们有用户名。



现在我想让超级用户sa访问完全压缩,但我希望普通用户在系统中输入当前日期。

i使用以下代码但不能为我工作。

如何重温这个?



thx提前!!!

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;
                }

推荐答案

为什么不使用Enabled属性?

Why not just use the Enabled property?
myDateTimePicker.Enabled = (txtSupervisor.Text == "sa");

它限制输入,并让用户知道他不能改变它...





错字:Enabeld表示已启用 - OriginalGriff [/ edit]

It restricts the input, and lets the user know he can''t change it...


[edit]Typo: "Enabeld" for "Enabled" - OriginalGriff[/edit]


if (SettingManger.Instance.User != "sa")
                {

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

                }


这篇关于授权在Windows窗体中选择日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆