/// <summary>
        /// Handles a click on the OK button. Creates a task for publishing the selected item.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The arguments.</param>
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");

            PublishSchedule publishSchedule = new PublishSchedule
            {
                ItemToPublish   = InnerItem,
                PublishDate     = SelectedPublishDate,
                SourceDatabase  = _database,
                TargetDatabases = SelectedTargets,
                TargetLanguages = SelectedLanguages,
                Unpublish       = Unpublish,
                PublishMode     = SmartPublish.Checked ? PublishMode.Smart : PublishMode.Full,
                PublishChildren = PublishChildren.Checked,
                SchedulerEmail  = Context.User.Profile.Email,
                IsPublished     = false
            };

            ValidationResult validationResult = ScheduledPublishValidator.Validate(publishSchedule);

            if (!validationResult.IsValid)
            {
                SheerResponse.Alert(string.Join(Environment.NewLine, validationResult.ValidationErrors));
                return;
            }

            _scheduledPublishRepo.CreatePublishSchedule(publishSchedule);

            base.OnOK(sender, args);
        }
        /// <summary>
        /// Handles a click on the OK button. Save the new publishing schedules
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The arguments.</param>
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");

            using (new LanguageSwitcher(LanguageManager.DefaultLanguage))
            {
                foreach (string key in Context.ClientPage.ClientRequest.Form.Keys)
                {
                    if (key != null && key.StartsWith("dt_", StringComparison.InvariantCulture))
                    {
                        string id = StringUtil.Mid(key, 3, 38);

                        DateTimePicker dtEditPicker = AllSchedules.FindControl("dt_" + id) as DateTimePicker;

                        Assert.IsNotNull(dtEditPicker, "dtEditPicker");

                        DateTime        dateTime        = DateUtil.IsoDateToDateTime(dtEditPicker.Value);
                        PublishSchedule publishSchedule = new PublishSchedule(_database.GetItem(new ID(id)));

                        //Scheudled time has changed
                        if (publishSchedule.PublishDate != dateTime)
                        {
                            publishSchedule.PublishDate = dateTime;

                            ValidationResult validationResult = ScheduledPublishValidator.Validate(publishSchedule);
                            if (!validationResult.IsValid)
                            {
                                SheerResponse.Alert(string.Join(Environment.NewLine, validationResult.ValidationErrors));
                                return;
                            }

                            _scheduledPublishRepo.UpdatePublishSchedule(publishSchedule);
                        }
                    }
                    else if (key != null && key.StartsWith("del_", StringComparison.InvariantCulture))
                    {
                        string   id             = StringUtil.Mid(key, 4, 38);
                        Checkbox deleteCheckbox = AllSchedules.FindControl("del_" + id) as Checkbox;

                        Assert.IsNotNull(deleteCheckbox, "deleteCheckbox");

                        bool doDelete = deleteCheckbox.Checked;
                        if (doDelete)
                        {
                            Item publishOption = _database.GetItem(new ID(id));
                            _scheduledPublishRepo.DeleteItem(publishOption);
                        }
                    }
                }
            }

            base.OnOK(sender, args);
        }
        /// <summary>
        /// Handles a click on the OK button. Creates a task for publishing the selected item.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The arguments.</param>
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");

            using (new LanguageSwitcher(LanguageManager.DefaultLanguage))
            {
                PublishSchedule publishSchedule = new PublishSchedule
                {
                    ItemToPublish       = InnerItem,
                    PublishDate         = SelectedPublishDate,
                    SourceDatabase      = _database,
                    TargetDatabases     = SelectedTargets,
                    TargetLanguages     = SelectedLanguages,
                    Unpublish           = Unpublish,
                    PublishMode         = SmartPublish.Checked ? PublishMode.Smart : PublishMode.Full,
                    PublishChildren     = PublishChildren.Checked,
                    PublishRelatedItems = PublishRelatedItems.Checked,
                    SchedulerUsername   = Context.User.Name,
                    RecurrenceType      = RecurrenceType,
                    HoursToNextPublish  = HoursToNextPublishValue,
                    IsPublished         = false
                };

                if (Unpublish)
                {
                    publishSchedule.TargetLanguages = LanguageManager.GetLanguages(_database);
                }

                ValidationResult validationResult = ScheduledPublishValidator.Validate(publishSchedule);
                if (!validationResult.IsValid)
                {
                    SheerResponse.Alert(string.Join(Environment.NewLine, validationResult.ValidationErrors));
                    return;
                }

                _scheduledPublishRepo.CreatePublishSchedule(publishSchedule);
            }

            base.OnOK(sender, args);
        }