如何使用户根据工作地点查看不同的视图

时间:2017-07-20 04:02:00

标签: c# sql asp.net sql-server

我希望创建条件,如果代码工作位置等于“Kelanis”用户不能选择过去5天,但如果工作地点不等于“kelanis”,则用户没有此限制。

TextBox dt = (TextBox)f.Controls[0].FindControl("TextBox1");
dt.Text = string.Format("{0:MMM dd, yyyy}", DateTime.Now);
CalendarExtender c1 = (CalendarExtender)f.Controls[0].FindControl("CalenderExtender1");

这是我的问题。我想创造条件

c1.StartDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day - 4); // I want this Code execute when Work Location  equal "kelanis". 
c1.StartDate = new DateTime(DateTime.Today.Year, 1, 1);  // execute when work location not equal "kelanis"



c1.EndDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day); // future date has been disable

这是图片MySQL数据库,你可以看到:

enter image description here

我的更新制作这样的条件,但没有被提醒

CalendarExtender cal1 =(CalendarExtender)FormView1.Controls [0] .FindControl(“CalendarExtender1”);

    TextBox dt = (TextBox)FormView1.Controls[0].FindControl("TextBox1");
    dt.Text = string.Format("{0:MMM dd, yyyy}", DateTime.Now);




    if (loc.SelectedText.ToLower() == "kelanis")
    {
        cal1.StartDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day - 4);
        cal1.EndDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);

        pan_risklvl.Visible = true;
        //ddl_risk.InitControl();
        txb_due.Enabled = false;
        lb_call_due.Enabled = false;
        cal1.Enabled = false;
        ddl_risklvl1_SelectedChanged(ddl_risk, EventArgs.Empty);

    }
    else
    {
        cal1.StartDate = new DateTime(DateTime.Today.Year, 1, 1);
        cal1.EndDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);

        pan_risklvl.Visible = false;
        txb_due.Enabled = true;
        lb_call_due.Enabled = true;
        cal1.Enabled = true;


    }

0 个答案:

没有答案