Exemplo n.º 1
0
    public static SchedulerSettings GetSchedulerSettings(this System.Web.Mvc.HtmlHelper customHtml)
    {
        SchedulerSettings settings = new SchedulerSettings();

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

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

        settings.Storage.EnableReminders = false;
        settings.GroupType = SchedulerGroupType.Resource;
        settings.Views.DayView.Styles.ScrollAreaHeight = 400;
        settings.Start = DateTime.Now;

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

        settings.OptionsForms.SetAppointmentFormTemplateContent(c => {
            var container = (CustomAppointmentTemplateContainer)c;
            ModelAppointment modelAppointment = new ModelAppointment()
            {
                ID          = container.Appointment.Id == null ? -1 : (int)container.Appointment.Id,
                Subject     = container.Appointment.Subject,
                Location    = container.Appointment.Location,
                StartTime   = container.Appointment.Start,
                EndTime     = container.Appointment.End,
                AllDay      = container.Appointment.AllDay,
                Description = container.Appointment.Description,
                EventType   = (int)container.Appointment.Type,
                Status      = container.Appointment.StatusId,
                Label       = container.Appointment.LabelId,
                CustomInfo  = container.CustomInfo,
                OwnerId     = Convert.ToInt32(container.Appointment.ResourceId)
            };

            customHtml.ViewBag.DeleteButtonEnabled = container.CanDeleteAppointment;

            (container.ResourceDataSource as ListEditItemCollection).RemoveAt(0);
            customHtml.ViewBag.ResourceDataSource = container.ResourceDataSource;
            customHtml.ViewBag.StatusDataSource   = container.StatusDataSource;
            customHtml.ViewBag.LabelDataSource    = container.LabelDataSource;
            //ViewBag.ReminderDataSource = container.ReminderDataSource;
            customHtml.RenderPartial("CustomAppointmentFormPartial", modelAppointment);
        });
        return(settings);
    }
Exemplo n.º 2
0
        public static SchedulerSettings GetSchedulerSettings(this System.Web.Mvc.HtmlHelper customHtml)
        {
            SchedulerSettings settings = new SchedulerSettings();

            settings.Name = "scheduler";

            settings.InitClientAppointment = (sched, evargs) => {
                evargs.Properties.Add(DevExpress.Web.ASPxScheduler.ClientSideAppointmentFieldNames.AppointmentType, evargs.Appointment.Type);
                evargs.Properties.Add(DevExpress.Web.ASPxScheduler.ClientSideAppointmentFieldNames.Subject, evargs.Appointment.Subject);
            };

            settings.PopupMenuShowing = (sched, evargs) => {
                if (evargs.Menu.MenuId == SchedulerMenuItemId.AppointmentMenu)
                {
                    evargs.Menu.ClientSideEvents.PopUp = "OnAppointmentMenuPopup";
                }
            };

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

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

            settings.Storage.EnableReminders = true;
            settings.GroupType = SchedulerGroupType.Resource;
            settings.Views.DayView.Styles.ScrollAreaHeight = 400;
            settings.Start = DateTime.Now;

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

            settings.OptionsForms.RecurrenceFormName = "appointmentRecurrenceForm";

            settings.OptionsForms.SetAppointmentFormTemplateContent(c => {
                var container = (CustomAppointmentTemplateContainer)c;
                ModelAppointment modelAppointment = new ModelAppointment()
                {
                    ID          = container.Appointment.Id == null ? -1 : (int)container.Appointment.Id,
                    Subject     = container.Appointment.Subject,
                    Location    = container.Appointment.Location,
                    StartTime   = container.Appointment.Start,
                    EndTime     = container.Appointment.End,
                    AllDay      = container.Appointment.AllDay,
                    Description = container.Appointment.Description,
                    EventType   = (int)container.Appointment.Type,
                    Status      = Convert.ToInt32(container.Appointment.StatusKey),
                    Label       = Convert.ToInt32(container.Appointment.LabelKey),
                    CustomInfo  = container.CustomInfo,

                    CompanyID = container.CompanyID,
                    ContactID = container.ContactID,

                    HasReminder = container.Appointment.HasReminder,
                    Reminder    = container.Appointment.Reminder,
                    OwnerId     = Convert.ToInt32(container.Appointment.ResourceId)
                };

                customHtml.ViewBag.DeleteButtonEnabled = container.CanDeleteAppointment;

                (container.ResourceDataSource as ListEditItemCollection).RemoveAt(0);
                customHtml.ViewBag.ResourceDataSource = container.ResourceDataSource;
                customHtml.ViewBag.StatusDataSource   = container.StatusDataSource;
                customHtml.ViewBag.LabelDataSource    = container.LabelDataSource;
                customHtml.ViewBag.AppointmentRecurrenceFormSettings = CreateAppointmentRecurrenceFormSettings(container);
                customHtml.ViewBag.ReminderDataSource = container.ReminderDataSource;
                customHtml.ViewBag.IsBaseAppointment  = container.Appointment.Type == AppointmentType.Normal || container.Appointment.Type == AppointmentType.Pattern;

                customHtml.ViewBag.CompaniesDataSource = GetCompanies();
                customHtml.ViewBag.ContactsDataSource  = GetCompanyContacts(container.CompanyID);

                customHtml.RenderPartial("CustomAppointmentFormPartial", modelAppointment);
            });
            return(settings);
        }