Пример #1
0
    public override void DataBind()
    {
        base.DataBind();

        CustomAppointmentFormTemplateContainer container = (CustomAppointmentFormTemplateContainer)Parent;
        Appointment             apt = container.Appointment;
        IAppointmentStorageBase appointmentStorage = container.Control.Storage.Appointments;
        IAppointmentLabel       label  = appointmentStorage.Labels.GetById(apt.LabelKey);
        IAppointmentStatus      status = appointmentStorage.Statuses.GetById(apt.StatusKey);

        edtLabel.ValueType      = apt.LabelKey.GetType();
        edtLabel.SelectedIndex  = appointmentStorage.Labels.IndexOf(label);
        edtStatus.ValueType     = apt.StatusKey.GetType();
        edtStatus.SelectedIndex = appointmentStorage.Statuses.IndexOf(status);

        PopulateResourceEditors(apt, container);

        AppointmentRecurrenceForm1.Visible = container.ShouldShowRecurrence;

        if (apt.HasReminder)
        {
            cbReminder.Value    = apt.Reminder.TimeBeforeStart.ToString();
            chkReminder.Checked = true;
        }
        else
        {
            cbReminder.ClientEnabled = false;
        }

        if (TimeZonesEnabled)
        {
            cbTimeZone.DataSource = TimeZoneInfo.GetSystemTimeZones();
            cbTimeZone.ValueField = "Id";
            cbTimeZone.TextField  = "DisplayName";
            cbTimeZone.DataBind();
            cbTimeZone.Value   = container.TimeZoneId;
            cbTimeZone.Enabled = apt.Type == AppointmentType.Normal || apt.Type == AppointmentType.Pattern;
        }

        //btnOk.ClientSideEvents.Click = container.SaveHandler;
        btnCancel.ClientSideEvents.Click = container.CancelHandler;
        btnDelete.ClientSideEvents.Click = container.DeleteHandler;
        JSProperties.Add("cpHasExceptions", apt.HasExceptions);
        //btnDelete.Enabled = !container.IsNewAppointment;
    }
        public static SchedulerSettings CreateSchedulerSettings(this HtmlHelper htmlHelper)
        {
            SchedulerSettings settings = new SchedulerSettings();

            settings.Name = "scheduler";
            settings.CallbackRouteValues        = new { Controller = "Home", Action = "SchedulerPartial" };
            settings.EditAppointmentRouteValues = new { Controller = "Home", Action = "EditAppointment" };

            settings.Storage.Appointments.Assign(DefaultAppointmentStorage);
            settings.Storage.Resources.Assign(DefaultResourceStorage);

            settings.AppointmentFormShowing = (sender, e) => {
                MVCxScheduler scheduler = sender as MVCxScheduler;
                if (scheduler != null)
                {
                    e.Container = new CustomAppointmentFormTemplateContainer(scheduler);
                }
            };

            settings.OptionsForms.SetAppointmentFormTemplateContent(c => {
                CustomAppointmentFormTemplateContainer container = (CustomAppointmentFormTemplateContainer)c;
                ValidationSchedule schedule = new ValidationSchedule()
                {
                    ID        = container.Appointment.Id == null ? -1 : (int)container.Appointment.Id,
                    Subject   = container.Appointment.Subject,
                    StartTime = container.Appointment.Start,
                    EndTime   = container.Appointment.End,
                    Price     = container.Price,
                };

                htmlHelper.ViewData["DeleteButtonEnabled"] = container.CanDeleteAppointment;

                htmlHelper.RenderPartial("CustomAppointmentFormPartial", schedule);
            });

            settings.Storage.Appointments.ResourceSharing = true;
            settings.Start = new DateTime(2008, 7, 11);
            return(settings);
        }