0

我已经开发了 Telerik Radscheduler,因为我已经编写了如下代码,我想禁用/启用事件的 perticuler 时隙,在此禁用工作正常但启用不工作我不明白为什么它不是启用允许插入。请帮助我在需要更改以解决此问题的地方...

        protected void RadScheduler1_TimeSlotCreated1(object sender, TimeSlotCreatedEventArgs e)
  {

    //Getting Business hour time
    mybusinesscalendarEntities objEntity = new mybusinesscalendarEntities();
    var Result = from bhours in objEntity.businesshours where bhours.BusinessId == businessid select bhours;
    if (Result.Count() > 0)
    {
        var Hours = (from bhours in objEntity.businesshours where bhours.BusinessId == businessid select bhours).First();


        //Get particular day businee hour timings and disable the time slot 

        string Day = System.DateTime.Today.DayOfWeek.ToString();
        if (Day == "Monday")
        {
            string WorkDay = Hours.MondayFromTime.Value.ToShortTimeString();
            string WorkDayStart = WorkDay.Remove(WorkDay.Length - 2, 2);
            string WorkDayEnd = Hours.MondayToTime.Value.ToShortTimeString();
            string WorkDayEndTime = WorkDayEnd.Remove(WorkDayEnd.Length - 2, 2);
            if ((e.TimeSlot.Start.TimeOfDay < TimeSpan.Parse(WorkDayStart.Trim())) || (e.TimeSlot.Start.TimeOfDay > TimeSpan.Parse(WorkDayEndTime.Trim())))
            {
                e.TimeSlot.CssClass = "Disabled";
                RadScheduler1.ReadOnly = true;
            }

            else

            {

                RadScheduler1.ReadOnly = false;
                RadScheduler1.AllowInsert = true;
                RadScheduler1.AllowEdit = true;
                RadScheduler1.AllowDelete = true;

            }
4

1 回答 1

0

如果您的最后一个时间段被创建(最后一次事件被触发)这部分评估为真。

        if ((e.TimeSlot.Start.TimeOfDay < TimeSpan.Parse(WorkDayStart.Trim())) || (e.TimeSlot.Start.TimeOfDay > TimeSpan.Parse(WorkDayEndTime.Trim())))
        {
            e.TimeSlot.CssClass = "Disabled";
            RadScheduler1.ReadOnly = true;
        }

然后您的整个调度程序将处于只读模式。这意味着没有编辑插入删除移动等。

您的意图似乎是禁用特定的时间段。我认为您不打算在此特定事件中设置这些属性。

            RadScheduler1.ReadOnly = false;
            RadScheduler1.AllowInsert = true;
            RadScheduler1.AllowEdit = true;
            RadScheduler1.AllowDelete = true;

通过注释掉设置 readonly、allowinster、allowedit、allowdelete 属性的行进行测试,因为它们不是每个时间段,而是整个调度程序

于 2011-08-02T07:16:20.543 回答